Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions turbopack/crates/turbo-tasks/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,10 @@ pub struct TurboTasks<B: Backend + 'static> {
currently_scheduled_foreground_jobs: AtomicUsize,
currently_scheduled_background_jobs: AtomicUsize,
scheduled_tasks: AtomicUsize,
/// Total number of scheduled tasks that have finished processing.
///
/// Used by utoopack progress reporting.
completed_scheduled_tasks: AtomicUsize,
/// Diagnostics for reads and inline execution, see `TurboTasks::inline_execution_stats`.
/// Zero-sized without the `inline_execution_stats` feature.
inline_counters: InlineExecutionCounters,
Expand Down Expand Up @@ -876,6 +880,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
currently_scheduled_foreground_jobs: AtomicUsize::new(0),
currently_scheduled_background_jobs: AtomicUsize::new(0),
scheduled_tasks: AtomicUsize::new(0),
completed_scheduled_tasks: AtomicUsize::new(0),
inline_counters: InlineExecutionCounters::default(),
priority_runner: Arc::new(PriorityRunner::new(TurboTasksExecutor)),
start: Default::default(),
Expand Down Expand Up @@ -1222,6 +1227,10 @@ impl<B: Backend + 'static> TurboTasks<B> {
.load(Ordering::Acquire)
}

pub fn get_completed_scheduled_task_count(&self) -> usize {
self.completed_scheduled_tasks.load(Ordering::Relaxed)
}

/// Counters describing how reads and inline execution interacted. Diagnostics only; a dump of
/// these can be requested with `TURBO_ENGINE_INLINE_STATS=1`.
#[cfg(feature = "inline_execution_stats")]
Expand Down Expand Up @@ -1561,6 +1570,8 @@ impl<B: Backend> Executor<TurboTasks<B>, ScheduledTask, TaskPriority> for TurboT
// other tasks can run in the right priority order.
this.schedule(task_id, stale_priority);
}
this.completed_scheduled_tasks
.fetch_add(1, Ordering::Relaxed);
Comment on lines +1573 to +1574

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make the downstream-only completion counter opt-in

When TurboTasks runs without Utoopack progress reporting—including every caller in this repository—each scheduled task now performs an additional atomic read-modify-write on one shared counter. Task-heavy builds execute these completions concurrently across workers, so this adds hot-path contention and overhead for a metric that is never read; gate the instrumentation behind a consumer-enabled feature/runtime option or use lower-contention aggregation.

AGENTS.md reference: turbopack/AGENTS.md:L1-L3

Useful? React with 👍 / 👎.

this.finish_foreground_job();
})
.await
Expand Down
Loading