TaskPool
: Prefer task completion over executing new tasks (#18009)
# Objective - Systems that use the task pool, either explicitly or implicitly using parallel queries, will often end up executing tasks from different systems. - This can cause random tasks to block the main or render schedule at random, adding frame variance and increasing frame times when CPU bound. - This profile is a common occurrence on `main`. `propagate_parent_transforms` takes more than twice as long as it should, blocking the main schedule for that time, because it uses `task pool.scope`, which has decided to execute tasks from the render schedule on the main schedule.  ## Solution - In task pool scope execution, prefer to check if the current task is complete instead of ticking the executor to find new work. ## Testing - Ran the scene viewer with tracy to look for images like the one in the objective section. - Things look much, much better, and I could not find any occurrences:  
This commit is contained in:
parent
f2b37c733e
commit
831ecf030c
@ -486,7 +486,7 @@ impl TaskPool {
|
||||
.is_ok();
|
||||
}
|
||||
};
|
||||
execute_forever.or(get_results).await
|
||||
get_results.or(execute_forever).await
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -505,7 +505,7 @@ impl TaskPool {
|
||||
let _result = AssertUnwindSafe(tick_forever).catch_unwind().await.is_ok();
|
||||
}
|
||||
};
|
||||
execute_forever.or(get_results).await
|
||||
get_results.or(execute_forever).await
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -527,7 +527,7 @@ impl TaskPool {
|
||||
.is_ok();
|
||||
}
|
||||
};
|
||||
execute_forever.or(get_results).await
|
||||
get_results.or(execute_forever).await
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -545,7 +545,7 @@ impl TaskPool {
|
||||
let _result = AssertUnwindSafe(tick_forever).catch_unwind().await.is_ok();
|
||||
}
|
||||
};
|
||||
execute_forever.or(get_results).await
|
||||
get_results.or(execute_forever).await
|
||||
}
|
||||
|
||||
/// Spawns a static future onto the thread pool. The returned [`Task`] is a
|
||||
|
Loading…
Reference in New Issue
Block a user