From d3b57f0321ec51882a27498b869ced79569b3bd0 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 20 Jun 2024 10:56:24 +0200 Subject: [PATCH 1/3] move stateful flag into Done state --- crates/turbo-tasks-memory/src/task.rs | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/turbo-tasks-memory/src/task.rs b/crates/turbo-tasks-memory/src/task.rs index 20232fec49d9f..78833223267ba 100644 --- a/crates/turbo-tasks-memory/src/task.rs +++ b/crates/turbo-tasks-memory/src/task.rs @@ -172,9 +172,6 @@ struct TaskState { /// dirty, scheduled, in progress state_type: TaskStateType, - /// true, when the task has state and that can't be dropped - stateful: bool, - /// Children are only modified from execution children: TaskIdSet, @@ -200,7 +197,6 @@ impl TaskState { event: Event::new(move || format!("TaskState({})::event", description())), outdated_dependencies: Default::default(), }, - stateful: false, children: Default::default(), collectibles: Default::default(), output: Default::default(), @@ -219,7 +215,6 @@ impl TaskState { event: Event::new(move || format!("TaskState({})::event", description())), outdated_dependencies: Default::default(), }, - stateful: false, children: Default::default(), collectibles: Default::default(), output: Default::default(), @@ -249,7 +244,6 @@ impl PartialTaskState { event: Event::new(move || format!("TaskState({})::event", description())), outdated_dependencies: Default::default(), }, - stateful: false, children: Default::default(), collectibles: Default::default(), prepared_type: PrepareTaskType::None, @@ -280,7 +274,6 @@ impl UnloadedTaskState { event: Event::new(move || format!("TaskState({})::event", description())), outdated_dependencies: Default::default(), }, - stateful: false, children: Default::default(), collectibles: Default::default(), prepared_type: PrepareTaskType::None, @@ -355,6 +348,9 @@ enum TaskStateType { /// on invalidation this will move to Dirty or Scheduled depending on active /// flag Done { + /// true, when the task has state and that can't be dropped + stateful: bool, + /// Cells/Outputs/Collectibles that the task has read during execution. /// The Task will keep these tasks alive as invalidations that happen /// there might affect this task. @@ -973,8 +969,10 @@ impl Task { } state.cells.shrink_to_fit(); } - state.stateful = stateful; - state.state_type = Done { dependencies }; + state.state_type = Done { + stateful, + dependencies, + }; if !count_as_finished { let mut change = TaskChange { unfinished: -1, @@ -1554,13 +1552,20 @@ impl Task { let mut cells_to_drop = Vec::new(); let result = if let TaskMetaStateWriteGuard::Full(mut state) = self.state_mut() { - if state.gc.generation > generation || state.stateful { + if state.gc.generation > generation { return false; } match &mut state.state_type { - TaskStateType::Done { dependencies } => { + TaskStateType::Done { + dependencies, + stateful, + .. + } => { dependencies.shrink_to_fit(); + if *stateful { + return false; + } } TaskStateType::Dirty { .. } => {} _ => { @@ -1659,8 +1664,6 @@ impl Task { output, collectibles, mut aggregation_node, - // can be dropped as it will be recomputed on next execution - stateful: _, // can be dropped as it can be recomputed prepared_type: _, // can be dropped as always Dirty, event has been notified above From 5a168feb6443185730b6c203193cd5cd20104976 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 20 Jun 2024 23:50:34 +0200 Subject: [PATCH 2/3] fixup stateful --- crates/turbo-tasks-memory/src/task.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/turbo-tasks-memory/src/task.rs b/crates/turbo-tasks-memory/src/task.rs index 78833223267ba..175c82069c883 100644 --- a/crates/turbo-tasks-memory/src/task.rs +++ b/crates/turbo-tasks-memory/src/task.rs @@ -1093,6 +1093,7 @@ impl Task { } Done { ref mut dependencies, + .. } => { let outdated_dependencies = take(dependencies); // add to dirty lists and potentially schedule From 7bc9be5b03e29091c024da13698d84d97fffd721 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 21 Jun 2024 10:02:14 +0200 Subject: [PATCH 3/3] fix unload --- crates/turbo-tasks-memory/src/task.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/turbo-tasks-memory/src/task.rs b/crates/turbo-tasks-memory/src/task.rs index 175c82069c883..373fe89a9284b 100644 --- a/crates/turbo-tasks-memory/src/task.rs +++ b/crates/turbo-tasks-memory/src/task.rs @@ -1625,7 +1625,11 @@ impl Task { match state_type { Done { ref mut dependencies, + stateful, } => { + if *stateful { + return false; + } change_job = aggregation_node.apply_change( &aggregation_context, TaskChange {