Skip to content

Commit bef280b

Browse files
committed
split operation_suspend_point in inlined and cold part
1 parent 719de07 commit bef280b

File tree

1 file changed

+16
-6
lines changed
  • turbopack/crates/turbo-tasks-backend/src/backend

1 file changed

+16
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,33 +201,43 @@ impl TurboTasksBackendInner {
201201
unsafe { ExecuteContext::new_with_tx(self, tx, turbo_tasks) }
202202
}
203203

204+
#[inline]
204205
fn suspending_requested(&self) -> bool {
205206
(self.in_progress_operations.load(Ordering::Relaxed) & SNAPSHOT_REQUESTED_BIT) != 0
206207
}
207208

209+
#[inline]
208210
fn operation_suspend_point(&self, suspend: impl FnOnce() -> AnyOperation) {
209-
if self.suspending_requested() {
211+
#[cold]
212+
fn operation_suspend_point_cold(
213+
this: &TurboTasksBackendInner,
214+
suspend: impl FnOnce() -> AnyOperation,
215+
) {
210216
let operation = Arc::new(suspend());
211-
let mut snapshot_request = self.snapshot_request.lock();
217+
let mut snapshot_request = this.snapshot_request.lock();
212218
if snapshot_request.snapshot_requested {
213219
snapshot_request
214220
.suspended_operations
215221
.insert(operation.clone().into());
216-
let value = self.in_progress_operations.fetch_sub(1, Ordering::AcqRel) - 1;
222+
let value = this.in_progress_operations.fetch_sub(1, Ordering::AcqRel) - 1;
217223
assert!((value & SNAPSHOT_REQUESTED_BIT) != 0);
218224
if value == SNAPSHOT_REQUESTED_BIT {
219-
self.operations_suspended.notify_all();
225+
this.operations_suspended.notify_all();
220226
}
221-
self.snapshot_completed
227+
this.snapshot_completed
222228
.wait_while(&mut snapshot_request, |snapshot_request| {
223229
snapshot_request.snapshot_requested
224230
});
225-
self.in_progress_operations.fetch_add(1, Ordering::AcqRel);
231+
this.in_progress_operations.fetch_add(1, Ordering::AcqRel);
226232
snapshot_request
227233
.suspended_operations
228234
.remove(&operation.into());
229235
}
230236
}
237+
238+
if self.suspending_requested() {
239+
operation_suspend_point_cold(self, suspend);
240+
}
231241
}
232242

233243
pub(crate) fn start_operation(&self) -> OperationGuard<'_> {

0 commit comments

Comments
 (0)