Skip to content
Merged
Show file tree
Hide file tree
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
85 changes: 29 additions & 56 deletions turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ pub struct BackendOptions {
/// forever.
pub dependency_tracking: bool,

/// Enables children tracking.
///
/// When disabled: Strongly consistent reads are only eventually consistent. All tasks are
/// considered as active. Collectibles are disabled.
pub children_tracking: bool,

/// Enables active tracking.
///
/// Automatically disabled when `dependency_tracking` is disabled.
Expand All @@ -148,7 +142,6 @@ impl Default for BackendOptions {
fn default() -> Self {
Self {
dependency_tracking: true,
children_tracking: true,
active_tracking: true,
storage_mode: Some(StorageMode::ReadWrite),
small_preallocation: false,
Expand Down Expand Up @@ -386,10 +379,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
self.options.active_tracking
}

fn should_track_children(&self) -> bool {
self.options.children_tracking
}

fn track_cache_hit(&self, task_type: &CachedTaskType) {
self.task_statistics
.map(|stats| stats.increment_cache_hit(task_type.native_fn));
Expand Down Expand Up @@ -509,7 +498,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
}
}

if self.should_track_children() && matches!(consistency, ReadConsistency::Strong) {
if matches!(consistency, ReadConsistency::Strong) {
// Ensure it's an root node
loop {
let aggregation_number = get_aggregation_number(&task);
Expand Down Expand Up @@ -1597,27 +1586,23 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
})),
});

if self.should_track_children() {
// Make all current collectibles outdated (remove left-over outdated collectibles)
enum Collectible {
Current(CollectibleRef, i32),
Outdated(CollectibleRef),
}
let collectibles = iter_many!(task, Collectible { collectible } value => Collectible::Current(collectible, *value))
// Make all current collectibles outdated (remove left-over outdated collectibles)
enum Collectible {
Current(CollectibleRef, i32),
Outdated(CollectibleRef),
}
let collectibles = iter_many!(task, Collectible { collectible } value => Collectible::Current(collectible, *value))
.chain(iter_many!(task, OutdatedCollectible { collectible } => Collectible::Outdated(collectible)))
.collect::<Vec<_>>();
for collectible in collectibles {
match collectible {
Collectible::Current(collectible, value) => {
let _ = task
.insert(CachedDataItem::OutdatedCollectible { collectible, value });
}
Collectible::Outdated(collectible) => {
if !task.has_key(&CachedDataItemKey::Collectible { collectible }) {
task.remove(&CachedDataItemKey::OutdatedCollectible {
collectible,
});
}
for collectible in collectibles {
match collectible {
Collectible::Current(collectible, value) => {
let _ =
task.insert(CachedDataItem::OutdatedCollectible { collectible, value });
}
Collectible::Outdated(collectible) => {
if !task.has_key(&CachedDataItemKey::Collectible { collectible }) {
task.remove(&CachedDataItemKey::OutdatedCollectible { collectible });
}
}
}
Expand Down Expand Up @@ -1883,18 +1868,18 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
.get(&cell.type_id).is_none_or(|start_index| cell.index >= *start_index))
}));
}
if self.should_track_children() {
old_edges.extend(
task.iter(CachedDataItemType::OutdatedCollectible)
.filter_map(|(key, value)| match (key, value) {
(
CachedDataItemKey::OutdatedCollectible { collectible },
CachedDataItemValueRef::OutdatedCollectible { value },
) => Some(OutdatedEdge::Collectible(collectible, *value)),
_ => None,
}),
);
}

old_edges.extend(
task.iter(CachedDataItemType::OutdatedCollectible)
.filter_map(|(key, value)| match (key, value) {
(
CachedDataItemKey::OutdatedCollectible { collectible },
CachedDataItemValueRef::OutdatedCollectible { value },
) => Some(OutdatedEdge::Collectible(collectible, *value)),
_ => None,
}),
);

if self.should_track_dependencies() {
old_edges.extend(iter_many!(task, OutdatedCellDependency { target } => OutdatedEdge::CellDependency(target)));
old_edges.extend(iter_many!(task, OutdatedOutputDependency { target } => OutdatedEdge::OutputDependency(target)));
Expand Down Expand Up @@ -2080,9 +2065,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
task.remove(&CachedDataItemKey::Dirty {});
}

if self.should_track_children()
&& (old_dirty_state.is_some() || new_dirty_state.is_some())
{
if old_dirty_state.is_some() || new_dirty_state.is_some() {
let mut dirty_containers = get!(task, AggregatedDirtyContainerCount)
.cloned()
.unwrap_or_default();
Expand Down Expand Up @@ -2284,10 +2267,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
reader_id: TaskId,
turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
) -> AutoMap<RawVc, i32, BuildHasherDefault<FxHasher>, 1> {
if !self.should_track_children() {
return AutoMap::default();
}

let mut ctx = self.execute_context(turbo_tasks);
let mut collectibles = AutoMap::default();
{
Expand Down Expand Up @@ -2363,9 +2342,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
) {
self.assert_valid_collectible(task_id, collectible);
if !self.should_track_children() {
return;
}

let RawVc::TaskCell(collectible_task, cell) = collectible else {
panic!("Collectibles need to be resolved");
Expand Down Expand Up @@ -2394,9 +2370,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
) {
self.assert_valid_collectible(task_id, collectible);
if !self.should_track_children() {
return;
}

let RawVc::TaskCell(collectible_task, cell) = collectible else {
panic!("Collectibles need to be resolved");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ impl AggregationUpdateQueue {
/// Runs the job and all dependent jobs until it's done. It can persist the operation, so
/// following code might not be executed when persisted.
pub fn run(job: AggregationUpdateJob, ctx: &mut impl ExecuteContext) {
debug_assert!(ctx.should_track_children());
let mut queue = Self::new();
queue.push(job);
queue.execute(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ pub enum ConnectChildOperation {

impl ConnectChildOperation {
pub fn run(parent_task_id: TaskId, child_task_id: TaskId, mut ctx: impl ExecuteContext) {
if !ctx.should_track_children() {
let mut child_task = ctx.task(child_task_id, TaskDataCategory::All);
if !child_task.has_key(&CachedDataItemKey::Output {})
&& child_task.add(CachedDataItem::new_scheduled(
TaskExecutionReason::Connect,
|| ctx.get_task_desc_fn(child_task_id),
))
{
ctx.schedule_task(child_task);
}
return;
}

let mut parent_task = ctx.task(parent_task_id, TaskDataCategory::All);
let Some(InProgressState::InProgress(box InProgressStateInner { new_children, .. })) =
get_mut!(parent_task, InProgress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ pub fn make_task_dirty_internal(
)
.entered();

let should_schedule = if ctx.should_track_children() {
let should_schedule = {
let aggregated_update = dirty_container.update_with_dirty_state(&DirtyState {
clean_in_session: None,
});
Expand All @@ -291,8 +291,6 @@ pub fn make_task_dirty_internal(
));
}
!ctx.should_track_activeness() || task.has_key(&CachedDataItemKey::Activeness {})
} else {
true
};

if should_schedule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ pub trait ExecuteContext<'e>: Sized {
fn suspending_requested(&self) -> bool;
fn get_task_desc_fn(&self, task_id: TaskId) -> impl Fn() -> String + Send + Sync + 'static;
fn get_task_description(&self, task_id: TaskId) -> String;
fn should_track_children(&self) -> bool;
fn should_track_dependencies(&self) -> bool;
fn should_track_activeness(&self) -> bool;
}
Expand Down Expand Up @@ -289,10 +288,6 @@ where
self.backend.get_task_description(task_id)
}

fn should_track_children(&self) -> bool {
self.backend.should_track_children()
}

fn should_track_dependencies(&self) -> bool {
self.backend.should_track_dependencies()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ impl UpdateCollectibleOperation {
mut count: i32,
mut ctx: impl ExecuteContext,
) {
if !ctx.should_track_children() {
// Collectibles are not supported without children tracking
return;
}
let mut task = ctx.task(task_id, TaskDataCategory::All);
if count < 0 {
// Ensure it's an root node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl UpdateOutputOperation {
pub fn run(
task_id: TaskId,
output: Result<RawVc, TurboTasksExecutionError>,
mut ctx: impl ExecuteContext,
mut ctx: impl ExecuteContext<'_>,
) {
let mut dependent_tasks = Default::default();
let mut children = Default::default();
Expand All @@ -66,9 +66,7 @@ impl UpdateOutputOperation {
// Skip updating the output when the task is stale
break 'output;
}
if ctx.should_track_children() {
children = new_children.iter().copied().collect();
}
children = new_children.iter().copied().collect();

let current_output = get!(task, Output);
let output_value = match output {
Expand Down
Loading