Skip to content

Commit e5eb40f

Browse files
committed
review
1 parent 00cf6a1 commit e5eb40f

4 files changed

Lines changed: 16 additions & 20 deletions

File tree

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2919,20 +2919,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
29192919

29202920
if this.should_evict() {
29212921
if !check_idle_ended!() {
2922-
let evict_span = tracing::info_span!(
2923-
parent: background_span.id(),
2924-
"evict tasks",
2925-
full = tracing::field::Empty,
2926-
data_and_meta = tracing::field::Empty,
2927-
data_only = tracing::field::Empty,
2928-
meta_only = tracing::field::Empty,
2929-
);
2930-
let _guard = evict_span.enter();
2931-
let counts = this.storage.evict_after_snapshot();
2932-
evict_span.record("full", counts.full);
2933-
evict_span.record("data_and_meta", counts.data_and_meta);
2934-
evict_span.record("data_only", counts.data_only);
2935-
evict_span.record("meta_only", counts.meta_only);
2922+
this.storage.evict_after_snapshot();
29362923
}
29372924
}
29382925

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl Storage {
388388
/// - `No`: skip
389389
///
390390
/// Must be called when NOT in snapshot mode (i.e., after `end_snapshot()`).
391-
pub fn evict_after_snapshot(&self) -> EvictionCounts {
391+
pub fn evict_after_snapshot(&self) {
392392
let span = tracing::trace_span!(
393393
"evict_after_snapshot",
394394
task_cache = tracing::field::Empty,
@@ -489,7 +489,6 @@ impl Storage {
489489
span.record("data_only", totals.data_only);
490490
span.record("meta_only", totals.meta_only);
491491
span.record("skipped", skipped);
492-
totals
493492
}
494493
}
495494

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,9 @@ impl TaskStorage {
500500
}
501501

502502
// This is common after a round of eviction we end up with tasks with only transient state
503+
// There is no need to search for it, we can just assume any task in this state is preserved
504+
// for a reason. NOTE: new tasks have the restored flags set as part of construction so the
505+
// only way for a task to end up in this situation is through eviction
503506
if !flags.data_restored() && !flags.meta_restored() {
504507
return (
505508
key_evictability,
@@ -510,7 +513,8 @@ impl TaskStorage {
510513
// Back off if another thread is currently restoring this task's data from
511514
// disk. Without this check, eviction could clear data that was already
512515
// determined to be "restored" by the restoring thread (which released the
513-
// lock to do I/O), causing the restoring thread to skip re-reading it.
516+
// lock to do I/O), causing the restoring thread to skip re-reading it. Instead we respect
517+
// in flight restoration
514518
if flags.meta_restoring() || flags.data_restoring() {
515519
return (
516520
key_evictability,
@@ -526,6 +530,8 @@ impl TaskStorage {
526530
&& !flags.data_modified_during_snapshot()
527531
&& self.transient_cell_data().is_none_or(|m| m.is_empty())
528532
// If transient tasks depend on our cells or output we cannot be evicted
533+
534+
// TODO: this is the most expensive part of the scan since there can be many cell and output dependents as well as many cells
529535
&& self
530536
.cell_dependents()
531537
.is_none_or(|cd| !cd.iter().any(|(_, _, t)| t.is_transient()))
@@ -543,11 +549,12 @@ impl TaskStorage {
543549
let meta_evictable = flags.meta_restored()
544550
&& !flags.meta_modified()
545551
&& !flags.meta_modified_during_snapshot()
552+
&& self.get_output().is_none_or(|o| !o.is_transient())
553+
// TODO: this is the most expensive part of the scan since there can be many dependents and uppers
546554
&& self
547555
.collectibles_dependents()
548556
.is_none_or(|d| !d.iter().any(|(_trait_id, task)| task.is_transient()))
549-
&& !self.upper().iter().any(|(k, _)| k.is_transient())
550-
&& self.get_output().is_none_or(|o| !o.is_transient());
557+
&& !self.upper().iter().any(|(k, _)| k.is_transient());
551558

552559
// === Combined decision ===
553560
(

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ pub(crate) static VALUES: Lazy<Box<[&'static ValueType]>> = Lazy::new(|| {
202202
.copied()
203203
.collect(),
204204
|v, mut id| {
205-
assert!(id.get() & SESSION_STATEFUL_BIT == 0);
205+
assert!(
206+
id.get() & SESSION_STATEFUL_BIT == 0,
207+
"SESSION_STATEFUL_BIT already set? do we have more than 32k value types"
208+
);
206209
if v.is_session_stateful {
207210
id |= SESSION_STATEFUL_BIT;
208211
}

0 commit comments

Comments
 (0)