From 6b2dca9f21bac957adcd6400e0455656d3e89ee6 Mon Sep 17 00:00:00 2001 From: yuzheng14 <422450117@qq.com> Date: Mon, 31 Aug 2026 16:01:55 +0800 Subject: [PATCH] feat(turbo-tasks): expose completed task count --- turbopack/crates/turbo-tasks/src/manager.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/turbopack/crates/turbo-tasks/src/manager.rs b/turbopack/crates/turbo-tasks/src/manager.rs index 24699d5c3ef9..60565a04bc6c 100644 --- a/turbopack/crates/turbo-tasks/src/manager.rs +++ b/turbopack/crates/turbo-tasks/src/manager.rs @@ -674,6 +674,10 @@ pub struct TurboTasks { 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, @@ -876,6 +880,7 @@ impl TurboTasks { 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(), @@ -1222,6 +1227,10 @@ impl TurboTasks { .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")] @@ -1561,6 +1570,8 @@ impl Executor, 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); this.finish_foreground_job(); }) .await