Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a8905ddf
Unverified
Commit
a8905ddf
authored
Sep 09, 2026
by
Luke Sandberg
Committed by
GitHub
Sep 09, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deflake gc_interrupt_is_self_healing (#98445)
parent
b8797762
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
28 deletions
+18
-28
gc_interrupt.rs
turbopack/crates/turbo-tasks-backend/tests/gc_interrupt.rs
+18
-28
No files found.
turbopack/crates/turbo-tasks-backend/tests/gc_interrupt.rs
View file @
a8905ddf
...
@@ -92,51 +92,41 @@ async fn gc_min_progress_floor_beats_a_waiting_operation() {
...
@@ -92,51 +92,41 @@ async fn gc_min_progress_floor_beats_a_waiting_operation() {
tt
.stop_and_wait
()
.await
;
tt
.stop_and_wait
()
.await
;
}
}
/// What an interrupted pass abandons must still be collectible by a later pass.
/// Garbage an interrupted pass abandons must still be collectible by a later pass.
///
/// The two phases are sequential, not concurrent: nothing here forces a pass to overlap with an
/// operation. Phase 1 relies only on the zero `min_progress` floor, which makes *any* waiter
/// observed by `GcBudget::should_stop` interrupt the pass immediately, so interrupts happen
/// readily across the rounds instead of needing a mid-range floor that might interrupt none of
/// them and assert nothing. Because that is still scheduling-dependent, the loop asserts only
/// that at least one round interrupted — which is the premise phase 2 needs. Phase 2 then runs a
/// deliberately *uninterruptible* pass (`gc_for_testing`) after phase 1 is fully over, and that
/// pass is what must recover everything the interrupted rounds abandoned.
#[tokio
::
test(flavor
=
"multi_thread"
,
worker_threads
=
4
)]
#[tokio
::
test(flavor
=
"multi_thread"
,
worker_threads
=
4
)]
async
fn
gc_interrupt_is_self_healing
()
{
async
fn
gc_interrupt_is_self_healing
()
{
// A floor short enough that passes still interrupt readily, but long enough that each one
// collects something first. At a zero floor `should_stop` trips on the very first job, before
// any shard is scanned, so rounds routinely collect nothing and phase 2 does all the work.
//
let
(
tt
,
_persistence_dir
)
=
let
(
tt
,
_persistence_dir
)
=
create_tt_with_gc_min_progress
(
"gc_interrupt_is_self_healing"
,
Duration
::
ZERO
);
create_tt_with_gc_min_progress
(
"gc_interrupt_is_self_healing"
,
Duration
::
from_micros
(
100
)
);
build_generation
(
&
tt
,
0
)
.await
;
build_generation
(
&
tt
,
0
)
.await
;
// Phase 1: accumulate garbage under passes that
keep interrupting
.
// Phase 1: accumulate garbage under passes that
interrupt as the scheduler allows
.
const
ROUNDS
:
u32
=
10
;
const
ROUNDS
:
u32
=
10
;
let
mut
collected_
while_interrupting
=
0u
size
;
let
mut
collected_
in_phase_1
=
0u
size
;
let
mut
interrupted_rounds
=
0u
size
;
let
mut
interrupted_rounds
=
0u
size
;
for
gen_value
in
1
..=
ROUNDS
{
for
gen_value
in
1
..=
ROUNDS
{
build_generation
(
&
tt
,
gen_value
)
.await
;
build_generation
(
&
tt
,
gen_value
)
.await
;
let
outcome
=
tt
.backend
()
.snapshot_and_evict_for_testing
(
&
tt
);
let
outcome
=
tt
.backend
()
.snapshot_and_evict_for_testing
(
&
tt
);
let
stats
=
outcome
.gc_stats
();
let
stats
=
outcome
.gc_stats
();
// Reported, never asserted on: when the totals below disagree, the per-round split is the
// first thing worth seeing.
println!
(
"round {gen_value}: {stats}"
);
println!
(
"round {gen_value}: {stats}"
);
collected_
while_interrupting
+=
stats
.collected
;
collected_
in_phase_1
+=
stats
.collected
;
interrupted_rounds
+=
usize
::
from
(
stats
.interrupted
);
interrupted_rounds
+=
usize
::
from
(
stats
.interrupted
);
}
}
// The premise of phase 2: without an interrupt, nothing was abandoned to heal from.
// Phase 2: a completing pass must recover exactly what phase 1 left behind.
assert
!
(
interrupted_rounds
>
0
,
"no pass interrupted across {ROUNDS} rounds at a zero floor: nothing was abandoned, so
\
this test proves nothing"
);
// Phase 2: a completing pass must recover what was left behind.
let
healed
=
tt
.backend
()
.gc_for_testing
(
&
tt
);
let
healed
=
tt
.backend
()
.gc_for_testing
(
&
tt
);
let
produced
=
(
2
*
WIDTH
as
usize
)
*
(
ROUNDS
as
usize
);
let
produced
=
(
2
*
WIDTH
as
usize
)
*
(
ROUNDS
as
usize
);
let
total_collected
=
collected_
while_interrupting
+
healed
;
let
total_collected
=
collected_
in_phase_1
+
healed
;
println!
(
println!
(
"self-healing: collected_
while_interrupting={collected_while_interrupting
}
\
"self-healing: collected_
in_phase_1={collected_in_phase_1} healed={healed
}
\
healed={healed}
total_collected={total_collected} produced={produced}
\
total_collected={total_collected} produced={produced}
\
interrupted_rounds={interrupted_rounds}/{ROUNDS}"
interrupted_rounds={interrupted_rounds}/{ROUNDS}"
);
);
...
@@ -146,9 +136,9 @@ async fn gc_interrupt_is_self_healing() {
...
@@ -146,9 +136,9 @@ async fn gc_interrupt_is_self_healing() {
// show up here as a shortfall.
// show up here as a shortfall.
assert_eq!
(
assert_eq!
(
total_collected
,
produced
,
total_collected
,
produced
,
"collected {total_collected} of {produced} garbage tasks ({collected_
while_interrupting}
\
"collected {total_collected} of {produced} garbage tasks ({collected_
in_phase_1} in phase
\
across {interrupted_rounds} interrupted rounds, {healed} in the completing pass):
\
1 across {interrupted_rounds}/{ROUNDS} interrupted rounds, {healed} in the completing
\
interrupted passes are losing garbage rather than leaving it"
pass):
interrupted passes are losing garbage rather than leaving it"
);
);
tt
.stop_and_wait
()
.await
;
tt
.stop_and_wait
()
.await
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment