Skip to content

Commit c38833d

Browse files
authored
Revert "Turbopack: skip invalidating a task on cell/output change when the dependency is outdated" (#84526)
Reverts #84376
1 parent d4eb891 commit c38833d

File tree

10 files changed

+17
-199
lines changed

10 files changed

+17
-199
lines changed

test/e2e/app-dir/no-double-tailwind-execution/app/globals.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/app-dir/no-double-tailwind-execution/app/layout.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/e2e/app-dir/no-double-tailwind-execution/app/page.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/e2e/app-dir/no-double-tailwind-execution/next.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/e2e/app-dir/no-double-tailwind-execution/no-double-tailwind-execution.test.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

test/e2e/app-dir/no-double-tailwind-execution/package.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/app-dir/no-double-tailwind-execution/postcss.config.mjs

Lines changed: 0 additions & 5 deletions
This file was deleted.

turbopack/crates/turbo-tasks-backend/src/backend/operation/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,6 @@ pub enum AnyOperation {
601601
ConnectChild(connect_child::ConnectChildOperation),
602602
Invalidate(invalidate::InvalidateOperation),
603603
UpdateOutput(update_output::UpdateOutputOperation),
604-
UpdateCell(update_cell::UpdateCellOperation),
605604
CleanupOldEdges(cleanup_old_edges::CleanupOldEdgesOperation),
606605
AggregationUpdate(aggregation_update::AggregationUpdateQueue),
607606
Nested(Vec<AnyOperation>),
@@ -613,7 +612,6 @@ impl AnyOperation {
613612
AnyOperation::ConnectChild(op) => op.execute(ctx),
614613
AnyOperation::Invalidate(op) => op.execute(ctx),
615614
AnyOperation::UpdateOutput(op) => op.execute(ctx),
616-
AnyOperation::UpdateCell(op) => op.execute(ctx),
617615
AnyOperation::CleanupOldEdges(op) => op.execute(ctx),
618616
AnyOperation::AggregationUpdate(op) => op.execute(ctx),
619617
AnyOperation::Nested(ops) => {
@@ -628,7 +626,6 @@ impl AnyOperation {
628626
impl_operation!(ConnectChild connect_child::ConnectChildOperation);
629627
impl_operation!(Invalidate invalidate::InvalidateOperation);
630628
impl_operation!(UpdateOutput update_output::UpdateOutputOperation);
631-
impl_operation!(UpdateCell update_cell::UpdateCellOperation);
632629
impl_operation!(CleanupOldEdges cleanup_old_edges::CleanupOldEdgesOperation);
633630
impl_operation!(AggregationUpdate aggregation_update::AggregationUpdateQueue);
634631

@@ -642,5 +639,6 @@ pub use self::{
642639
cleanup_old_edges::OutdatedEdge,
643640
connect_children::connect_children,
644641
prepare_new_children::prepare_new_children,
642+
update_cell::UpdateCellOperation,
645643
update_collectible::UpdateCollectibleOperation,
646644
};
Lines changed: 11 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,17 @@
1-
use std::mem::take;
2-
3-
use serde::{Deserialize, Serialize};
4-
use smallvec::SmallVec;
51
use turbo_tasks::{CellId, TaskId, backend::CellContent};
62

73
#[cfg(feature = "trace_task_dirty")]
84
use crate::backend::operation::invalidate::TaskDirtyCause;
95
use crate::{
106
backend::{
117
TaskDataCategory,
12-
operation::{
13-
AggregationUpdateQueue, ExecuteContext, Operation, TaskGuard,
14-
invalidate::make_task_dirty_internal,
15-
},
8+
operation::{ExecuteContext, InvalidateOperation, TaskGuard},
169
storage::{get_many, remove},
1710
},
18-
data::{CachedDataItem, CachedDataItemKey, CellRef},
11+
data::{CachedDataItem, CachedDataItemKey},
1912
};
2013

21-
#[derive(Serialize, Deserialize, Clone, Default)]
22-
#[allow(clippy::large_enum_variant)]
23-
pub enum UpdateCellOperation {
24-
InvalidateWhenCellDependency {
25-
cell_ref: CellRef,
26-
dependent_tasks: SmallVec<[TaskId; 4]>,
27-
queue: AggregationUpdateQueue,
28-
},
29-
AggregationUpdate {
30-
queue: AggregationUpdateQueue,
31-
},
32-
#[default]
33-
Done,
34-
}
14+
pub struct UpdateCellOperation;
3515

3616
impl UpdateCellOperation {
3717
pub fn run(task_id: TaskId, cell: CellId, content: CellContent, mut ctx: impl ExecuteContext) {
@@ -59,7 +39,7 @@ impl UpdateCellOperation {
5939
// This is a hack for the streaming hack. Stateful tasks are never recomputed, so this forces invalidation for them in case of this hack.
6040
task.has_key(&CachedDataItemKey::Stateful {}))
6141
{
62-
let dependent_tasks = get_many!(
42+
let dependent = get_many!(
6343
task,
6444
CellDependent { cell: dependent_cell, task }
6545
if dependent_cell == cell
@@ -69,78 +49,17 @@ impl UpdateCellOperation {
6949
drop(task);
7050
drop(old_content);
7151

72-
UpdateCellOperation::InvalidateWhenCellDependency {
73-
cell_ref: CellRef {
74-
task: task_id,
75-
cell,
52+
InvalidateOperation::run(
53+
dependent,
54+
#[cfg(feature = "trace_task_dirty")]
55+
TaskDirtyCause::CellChange {
56+
value_type: cell.type_id,
7657
},
77-
dependent_tasks,
78-
queue: AggregationUpdateQueue::new(),
79-
}
80-
.execute(&mut ctx);
58+
ctx,
59+
);
8160
} else {
8261
drop(task);
8362
drop(old_content);
8463
}
8564
}
8665
}
87-
88-
impl Operation for UpdateCellOperation {
89-
fn execute(mut self, ctx: &mut impl ExecuteContext) {
90-
loop {
91-
ctx.operation_suspend_point(&self);
92-
match self {
93-
UpdateCellOperation::InvalidateWhenCellDependency {
94-
cell_ref,
95-
ref mut dependent_tasks,
96-
ref mut queue,
97-
} => {
98-
if let Some(dependent_task_id) = dependent_tasks.pop() {
99-
if ctx.is_once_task(dependent_task_id) {
100-
// once tasks are never invalidated
101-
continue;
102-
}
103-
let dependent = ctx.task(dependent_task_id, TaskDataCategory::All);
104-
if dependent.has_key(&CachedDataItemKey::OutdatedCellDependency {
105-
target: cell_ref,
106-
}) {
107-
// cell dependency is outdated, so it hasn't read the cell yet
108-
// and doesn't need to be invalidated
109-
continue;
110-
}
111-
if !dependent
112-
.has_key(&CachedDataItemKey::CellDependency { target: cell_ref })
113-
{
114-
// cell dependency has been removed, so the task doesn't depend on the
115-
// cell anymore and doesn't need to be
116-
// invalidated
117-
continue;
118-
}
119-
make_task_dirty_internal(
120-
dependent,
121-
dependent_task_id,
122-
true,
123-
#[cfg(feature = "trace_task_dirty")]
124-
TaskDirtyCause::CellChange {
125-
value_type: cell_ref.cell.type_id,
126-
},
127-
queue,
128-
ctx,
129-
);
130-
}
131-
if dependent_tasks.is_empty() {
132-
self = UpdateCellOperation::AggregationUpdate { queue: take(queue) };
133-
}
134-
}
135-
UpdateCellOperation::AggregationUpdate { ref mut queue } => {
136-
if queue.process(ctx) {
137-
self = UpdateCellOperation::Done
138-
}
139-
}
140-
UpdateCellOperation::Done => {
141-
return;
142-
}
143-
}
144-
}
145-
}
146-
}

turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
TaskDataCategory,
1313
operation::{
1414
AggregationUpdateQueue, ExecuteContext, Operation, TaskGuard,
15-
invalidate::make_task_dirty_internal,
15+
invalidate::{make_task_dirty, make_task_dirty_internal},
1616
},
1717
storage::{get, get_many},
1818
},
@@ -25,6 +25,7 @@ use crate::{
2525
#[derive(Serialize, Deserialize, Clone, Default)]
2626
pub enum UpdateOutputOperation {
2727
MakeDependentTasksDirty {
28+
#[cfg(feature = "trace_task_dirty")]
2829
task_id: TaskId,
2930
dependent_tasks: SmallVec<[TaskId; 4]>,
3031
children: SmallVec<[TaskId; 4]>,
@@ -131,6 +132,7 @@ impl UpdateOutputOperation {
131132
}
132133

133134
UpdateOutputOperation::MakeDependentTasksDirty {
135+
#[cfg(feature = "trace_task_dirty")]
134136
task_id,
135137
dependent_tasks,
136138
children,
@@ -146,35 +148,15 @@ impl Operation for UpdateOutputOperation {
146148
ctx.operation_suspend_point(&self);
147149
match self {
148150
UpdateOutputOperation::MakeDependentTasksDirty {
151+
#[cfg(feature = "trace_task_dirty")]
149152
task_id,
150153
ref mut dependent_tasks,
151154
ref mut children,
152155
ref mut queue,
153156
} => {
154157
if let Some(dependent_task_id) = dependent_tasks.pop() {
155-
if ctx.is_once_task(dependent_task_id) {
156-
// once tasks are never invalidated
157-
continue;
158-
}
159-
let dependent = ctx.task(dependent_task_id, TaskDataCategory::All);
160-
if dependent.has_key(&CachedDataItemKey::OutdatedOutputDependency {
161-
target: task_id,
162-
}) {
163-
// output dependency is outdated, so it hasn't read the output yet
164-
// and doesn't need to be invalidated
165-
continue;
166-
}
167-
if !dependent
168-
.has_key(&CachedDataItemKey::OutputDependency { target: task_id })
169-
{
170-
// output dependency has been removed, so the task doesn't depend on the
171-
// output anymore and doesn't need to be invalidated
172-
continue;
173-
}
174-
make_task_dirty_internal(
175-
dependent,
158+
make_task_dirty(
176159
dependent_task_id,
177-
true,
178160
#[cfg(feature = "trace_task_dirty")]
179161
TaskDirtyCause::OutputChange { task_id },
180162
queue,

0 commit comments

Comments
 (0)