[turbopack] Store TaskDirtyCause in Dirtyness and pass to NativeFunction::span#94057
Merged
Conversation
…ion::span
Track the cause of task invalidation in `Dirtyness::Dirty` (gated by a new
`task_dirty_cause` feature) and surface it to the tracing span when the
task executes, so traces can show why a task was re-run.
- Replace `Dirtyness::Dirty(TaskPriority)` with a struct variant
`Dirty { parent_priority, cause: TaskDirtyCause }` where `cause` is only
present under the `task_dirty_cause` feature.
- Move `TaskDirtyCause` from `turbo-tasks-backend` into `turbo-tasks` so the
span signature can reference it. Replace `OutputChange.task_description`
with `OutputChange { function: FunctionId }` and add a new
`ResolveOutputChange { function: FunctionId }` variant used when the
task's output is `OutputValue::Output(_)`.
- `NativeFunction::span` now takes a feature-gated
`cause: Option<&TaskDirtyCause>` argument and records it as a `cause`
field on `turbo_tasks::function`. The `cause` is read from the dirty
state in `try_start_task_execution` before execution starts.
- Split the `trace_task_dirty` feature: the new `task_dirty_cause`
feature owns the storage/parameter plumbing, and `trace_task_dirty`
now depends on it.
Contributor
Tests PassedCommit: bb70074 |
mischnic
approved these changes
May 26, 2026
Contributor
Stats skippedCommit: bb70074 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Track the cause of task invalidation in turbo-tasks and surface it to the tracing span when a task executes, so traces can show why a task was re-run.
A new
task_dirty_causeCargo feature gates the storage and parameter plumbing for this information. The existingtrace_task_dirtyfeature now depends on it.Why?
When investigating Turbopack performance and incremental-recompute behavior, traces show which tasks ran but not what invalidated them. Recording the
TaskDirtyCauseon theturbo_tasks::functionspan makes it possible to attribute task re-runs to their triggering change (cell update, output change, collectible change, etc.) directly from a trace.How?
Dirtyness::Dirty(TaskPriority)with a struct variantDirty { parent_priority, cause: TaskDirtyCause }. Thecausefield is only present when thetask_dirty_causefeature is enabled.TaskDirtyCausefromturbo-tasks-backendintoturbo-tasksso the span signature inturbo-taskscan reference it.OutputChange { task_description }withOutputChange { function: FunctionId }, and add a newResolveOutputChange { function: FunctionId }variant used when the task's output isOutputValue::Output(_). This avoids constructing aStringfor the cause at invalidation time.NativeFunction::spannow accepts a feature-gatedcause: Option<&TaskDirtyCause>argument and records it as acausefield on theturbo_tasks::functionspan. The cause is read from the dirty state intry_start_task_executionbefore execution starts.trace_task_dirtyfeature: the newtask_dirty_causefeature owns the storage/parameter plumbing, andtrace_task_dirtynow depends on it. This lets consumers opt into the storage cost without the full tracing overhead, and keeps the default build unaffected.Closes PACK-