-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove old edges when task recomputation completes
- Loading branch information
Showing
4 changed files
with
223 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
turbopack/crates/turbo-tasks-backend/src/backend/operation/cleanup_old_edges.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use turbo_tasks::TaskId; | ||
|
||
use super::{ExecuteContext, Operation}; | ||
use crate::data::{CachedDataItemKey, CellRef}; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Default)] | ||
pub enum CleanupOldEdgesOperation { | ||
RemoveEdges { | ||
task_id: TaskId, | ||
outdated: Vec<OutdatedEdge>, | ||
}, | ||
#[default] | ||
Done, | ||
// TODO Add aggregated edge | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
Check failure on line 18 in turbopack/crates/turbo-tasks-backend/src/backend/operation/cleanup_old_edges.rs GitHub Actions / rust check / build
|
||
pub enum OutdatedEdge { | ||
Child(TaskId), | ||
CellDependency(CellRef), | ||
Check failure on line 21 in turbopack/crates/turbo-tasks-backend/src/backend/operation/cleanup_old_edges.rs GitHub Actions / rust check / build
|
||
OutputDependency(TaskId), | ||
} | ||
|
||
impl CleanupOldEdgesOperation { | ||
pub fn run(task_id: TaskId, outdated: Vec<OutdatedEdge>, ctx: ExecuteContext<'_>) { | ||
CleanupOldEdgesOperation::RemoveEdges { task_id, outdated }.execute(&ctx); | ||
} | ||
} | ||
|
||
impl Operation for CleanupOldEdgesOperation { | ||
fn execute(mut self, ctx: &ExecuteContext<'_>) { | ||
loop { | ||
ctx.operation_suspend_point(&self); | ||
match self { | ||
CleanupOldEdgesOperation::RemoveEdges { | ||
task_id, | ||
ref mut outdated, | ||
} => { | ||
if let Some(edge) = outdated.pop() { | ||
match edge { | ||
OutdatedEdge::Child(child_id) => { | ||
let mut task = ctx.task(task_id); | ||
task.remove(&CachedDataItemKey::Child { task: child_id }); | ||
// TODO remove aggregated edge | ||
} | ||
OutdatedEdge::CellDependency(CellRef { | ||
task: cell_task_id, | ||
cell, | ||
}) => { | ||
{ | ||
let mut task = ctx.task(cell_task_id); | ||
task.remove(&CachedDataItemKey::CellDependent { | ||
cell, | ||
task: task_id, | ||
}); | ||
} | ||
{ | ||
let mut task = ctx.task(task_id); | ||
task.remove(&CachedDataItemKey::CellDependency { | ||
target: CellRef { | ||
task: cell_task_id, | ||
cell, | ||
}, | ||
}); | ||
} | ||
} | ||
OutdatedEdge::OutputDependency(output_task_id) => { | ||
{ | ||
let mut task = ctx.task(output_task_id); | ||
task.remove(&CachedDataItemKey::OutputDependent { | ||
task: task_id, | ||
}); | ||
} | ||
{ | ||
let mut task = ctx.task(task_id); | ||
task.remove(&CachedDataItemKey::OutputDependency { | ||
target: output_task_id, | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if outdated.is_empty() { | ||
self = CleanupOldEdgesOperation::Done; | ||
} | ||
continue; | ||
} | ||
CleanupOldEdgesOperation::Done => { | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters