turbo-tasks-backend: resolve task priority when creating child contexts (#100767)
### What? `ExecuteContext::child_context()` in `turbo-tasks-backend` now reads the current task priority on the calling thread. The resulting `ChildExecuteContext` stores a priority that is already known, instead of an optional one. ### Why? Both users of `child_context()` hand the child context to `scope_bounded` helper threads: - the parallel path of `connect_children` (≥10k new children) - the parallel invalidation of output dependents Before this change the child context copied an override that is usually unset. On a helper thread, `get_current_task_priority()` then fell back to the task-local task state. That state only exists on the thread running the task, so helper threads got `TaskPriority::initial()`. Tasks scheduled or made dirty from those chunks (e.g. via `make_task_dirty_internal`) therefore got a priority that depended on which thread ran the chunk. ### How? The priority is resolved in `child_context()`, on the thread that creates the context. An explicit override still wins; otherwise the task-local priority is read before the work moves to another thread. Making the field non-optional means a child context can no longer carry an unresolved priority. Putting the fix in `child_context()` covers both parallel users, and any future one. Neither user relied on the late lookup, because the child context always runs on another thread. Paths that don't go parallel are unchanged. Verification: - `cargo check -p turbo-tasks-backend --all-targets` - `cargo clippy -p turbo-tasks-backend --all-targets` - `cargo nextest run -p turbo-tasks-backend` (329 passed) This PR does not add a regression test for priority on the parallel paths. Such a test could build on the existing `dirty_parent_priority_for_testing` hook used in `tests/invalidate_all.rs`. <!-- NEXT_JS_LLM --> <!-- fleet 458ef681-a3c9-47b5-a9fe-b400713e9995 --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment