Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move stateful flag into Done state #8559

Merged
merged 3 commits into from
Jun 26, 2024
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
34 changes: 21 additions & 13 deletions crates/turbo-tasks-memory/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1095,6 +1093,7 @@ impl Task {
}
Done {
ref mut dependencies,
..
} => {
let outdated_dependencies = take(dependencies);
// add to dirty lists and potentially schedule
Expand Down Expand Up @@ -1554,13 +1553,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 { .. } => {}
_ => {
Expand Down Expand Up @@ -1619,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 {
Expand Down Expand Up @@ -1659,8 +1669,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
Expand Down
Loading