diff --git a/crates/turbo-tasks-memory/src/gc.rs b/crates/turbo-tasks-memory/src/gc.rs index 96c7be4800cd9b..e95f39c67575d6 100644 --- a/crates/turbo-tasks-memory/src/gc.rs +++ b/crates/turbo-tasks-memory/src/gc.rs @@ -80,10 +80,12 @@ struct OldGeneration { generation: NonZeroU32, } +#[derive(Default)] struct ProcessGenerationResult { priority: Option, content_dropped_count: usize, unloaded_count: usize, + already_unloaded_count: usize, } struct ProcessDeactivationsResult { @@ -233,11 +235,7 @@ impl GcQueue { }) = old_generation else { // No old generation to process - return ProcessGenerationResult { - priority: None, - content_dropped_count: 0, - unloaded_count: 0, - }; + return ProcessGenerationResult::default(); }; // Check all tasks for the correct generation let mut indices = Vec::with_capacity(tasks.len()); @@ -256,11 +254,7 @@ impl GcQueue { if indices.is_empty() { // No valid tasks in old generation to process - return ProcessGenerationResult { - priority: None, - content_dropped_count: 0, - unloaded_count: 0, - }; + return ProcessGenerationResult::default(); } // Sorting based on sort_by_cached_key from std lib @@ -316,6 +310,7 @@ impl GcQueue { // GC the tasks let mut content_dropped_count = 0; let mut unloaded_count = 0; + let mut already_unloaded_count = 0; for task in tasks[..tasks_to_collect].iter() { backend.with_task(*task, |task| { match task.run_gc(generation, self, backend, turbo_tasks) { @@ -327,6 +322,9 @@ impl GcQueue { GcResult::Unloaded => { unloaded_count += 1; } + GcResult::AlreadyUnloaded => { + already_unloaded_count += 1; + } } }); } @@ -335,6 +333,7 @@ impl GcQueue { priority: Some(max_priority), content_dropped_count, unloaded_count, + already_unloaded_count, } } @@ -363,11 +362,13 @@ impl GcQueue { priority, content_dropped_count, unloaded_count, + already_unloaded_count, } = self.process_old_generation(backend, turbo_tasks); span.record("deactivations_count", deactivations_count); span.record("content_dropped_count", content_dropped_count); span.record("unloaded_count", unloaded_count); + span.record("already_unloaded_count", already_unloaded_count); if let Some(priority) = &priority { span.record("priority", debug(priority)); } else { diff --git a/crates/turbo-tasks-memory/src/task.rs b/crates/turbo-tasks-memory/src/task.rs index 4e2f16cd374281..6213f6e9cb8eb9 100644 --- a/crates/turbo-tasks-memory/src/task.rs +++ b/crates/turbo-tasks-memory/src/task.rs @@ -446,6 +446,7 @@ pub enum GcResult { /// from the graph and only makes sense when the task isn't currently /// active. Unloaded, + AlreadyUnloaded, } pub enum ReadCellError { @@ -1754,9 +1755,9 @@ impl Task { } TaskMetaStateWriteGuard::Partial(mut state) => { state.aggregation_node.shrink_to_fit(); - GcResult::Unloaded + GcResult::AlreadyUnloaded } - TaskMetaStateWriteGuard::Unloaded(_) => GcResult::Unloaded, + TaskMetaStateWriteGuard::Unloaded(_) => GcResult::AlreadyUnloaded, TaskMetaStateWriteGuard::TemporaryFiller => unreachable!(), } }