Skip to content

Commit 354900c

Browse files
authored
chore(turbo-tasks-backend): Remove unused support for nested database operations (#80816)
Supporting nested operations adds a lot of complexity. I have a feeling it's partially responsible for some of the lifetime stuff here. It doesn't look like it's actually needed? Sanity checked with: ``` cargo check --features turbo-tasks-backend/lmdb ```
1 parent 4a1b510 commit 354900c

File tree

1 file changed

+2
-87
lines changed
  • turbopack/crates/turbo-tasks-backend/src/backend/operation

1 file changed

+2
-87
lines changed

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

Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod update_output;
1010

1111
use std::{
1212
fmt::{Debug, Formatter},
13-
mem::{take, transmute},
13+
mem::transmute,
1414
};
1515

1616
use serde::{Deserialize, Serialize};
@@ -45,25 +45,6 @@ enum TransactionState<'a, 'tx, B: BackingStorage> {
4545
Owned(Option<B::ReadTransaction<'tx>>),
4646
}
4747

48-
impl<'a, 'tx1, B: BackingStorage> TransactionState<'a, 'tx1, B> {
49-
fn borrow<'l, 'tx2>(&'l self) -> TransactionState<'l, 'tx2, B>
50-
where
51-
'a: 'l,
52-
'tx1: 'a + 'tx2,
53-
'tx2: 'l,
54-
{
55-
match self {
56-
TransactionState::None => TransactionState::None,
57-
TransactionState::Borrowed(tx) => {
58-
TransactionState::Borrowed(tx.map(B::lower_read_transaction))
59-
}
60-
TransactionState::Owned(tx) => {
61-
TransactionState::Borrowed(tx.as_ref().map(B::lower_read_transaction))
62-
}
63-
}
64-
}
65-
}
66-
6748
pub trait ExecuteContext<'e>: Sized {
6849
fn session_id(&self) -> SessionId;
6950
fn task(&mut self, task_id: TaskId, category: TaskDataCategory) -> impl TaskGuard + 'e;
@@ -79,30 +60,18 @@ pub trait ExecuteContext<'e>: Sized {
7960
where
8061
T: Clone + Into<AnyOperation>;
8162
fn suspending_requested(&self) -> bool;
82-
type Backend;
83-
fn run_operation(
84-
&mut self,
85-
parent_op_ref: &mut impl Operation,
86-
run: impl FnOnce(&mut ExecuteContextImpl<'_, '_, Self::Backend>),
87-
);
8863
fn get_task_desc_fn(&self, task_id: TaskId) -> impl Fn() -> String + Send + Sync + 'static;
8964
fn get_task_description(&self, task_id: TaskId) -> String;
9065
fn should_track_children(&self) -> bool;
9166
fn should_track_dependencies(&self) -> bool;
9267
fn should_track_activeness(&self) -> bool;
9368
}
9469

95-
pub struct ParentRef<'a> {
96-
op: &'a AnyOperation,
97-
parent: &'a Option<ParentRef<'a>>,
98-
}
99-
10070
pub struct ExecuteContextImpl<'e, 'tx, B: BackingStorage>
10171
where
10272
Self: 'e,
10373
'tx: 'e,
10474
{
105-
parent: Option<ParentRef<'e>>,
10675
backend: &'e TurboTasksBackendInner<B>,
10776
turbo_tasks: &'e dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
10877
_operation_guard: Option<OperationGuard<'e, B>>,
@@ -121,7 +90,6 @@ where
12190
backend,
12291
turbo_tasks,
12392
_operation_guard: Some(backend.start_operation()),
124-
parent: None,
12593
transaction: TransactionState::None,
12694
}
12795
}
@@ -135,7 +103,6 @@ where
135103
backend,
136104
turbo_tasks,
137105
_operation_guard: Some(backend.start_operation()),
138-
parent: None,
139106
transaction: TransactionState::Borrowed(transaction),
140107
}
141108
}
@@ -292,65 +259,13 @@ where
292259
}
293260

294261
fn operation_suspend_point<T: Clone + Into<AnyOperation>>(&mut self, op: &T) {
295-
if self.parent.is_some() {
296-
self.backend.operation_suspend_point(|| {
297-
let mut nested = Vec::new();
298-
nested.push(op.clone().into());
299-
let mut cur = self.parent.as_ref();
300-
while let Some(ParentRef { op, parent }) = cur {
301-
nested.push((*op).clone());
302-
cur = parent.as_ref();
303-
}
304-
AnyOperation::Nested(nested)
305-
});
306-
} else {
307-
self.backend.operation_suspend_point(|| op.clone().into());
308-
}
262+
self.backend.operation_suspend_point(|| op.clone().into());
309263
}
310264

311265
fn suspending_requested(&self) -> bool {
312266
self.backend.suspending_requested()
313267
}
314268

315-
type Backend = B;
316-
317-
fn run_operation(
318-
&mut self,
319-
parent_op_ref: &mut impl Operation,
320-
run: impl FnOnce(&mut ExecuteContextImpl<'_, '_, B>),
321-
) {
322-
let parent_op = take(parent_op_ref);
323-
let parent_op: AnyOperation = parent_op.into();
324-
let this = &*self;
325-
fn run_with_inner_ctx<'a, B: BackingStorage>(
326-
backend: &'a TurboTasksBackendInner<B>,
327-
turbo_tasks: &'a dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
328-
parent: ParentRef<'a>,
329-
transaction: TransactionState<'a, '_, B>,
330-
run: impl FnOnce(&mut ExecuteContextImpl<'_, '_, B>),
331-
) {
332-
let mut inner_ctx: ExecuteContextImpl<'_, '_, B> = ExecuteContextImpl {
333-
backend,
334-
turbo_tasks,
335-
_operation_guard: None,
336-
parent: Some(parent),
337-
transaction,
338-
};
339-
run(&mut inner_ctx);
340-
}
341-
run_with_inner_ctx(
342-
self.backend,
343-
self.turbo_tasks,
344-
ParentRef {
345-
op: &parent_op,
346-
parent: &this.parent,
347-
},
348-
self.transaction.borrow(),
349-
run,
350-
);
351-
*parent_op_ref = parent_op.try_into().unwrap();
352-
}
353-
354269
fn get_task_desc_fn(&self, task_id: TaskId) -> impl Fn() -> String + Send + Sync + 'static {
355270
self.backend.get_task_desc_fn(task_id)
356271
}

0 commit comments

Comments
 (0)