turbo-tasks-gc: Defer most aggregation graph management until after GC has settled - #98591
Open
lukesandberg wants to merge 1 commit into
Open
turbo-tasks-gc: Defer most aggregation graph management until after GC has settled#98591lukesandberg wants to merge 1 commit into
lukesandberg wants to merge 1 commit into
Conversation
lukesandberg
added this pull request to stack #98592
September 11, 2026 23:52
Contributor
Tests PassedCommit: 9eae998 |
lukesandberg
force-pushed
the
gc-08-gc-fixes
branch
2 times, most recently
from
September 12, 2026 17:29
c40516c to
2ef1efe
Compare
lukesandberg
force-pushed
the
gc-08-gc-fixes
branch
from
September 13, 2026 17:20
c96a1ef to
4053847
Compare
lukesandberg
force-pushed
the
gc-08-gc-fixes
branch
from
September 13, 2026 18:49
4053847 to
c59bf08
Compare
lukesandberg
force-pushed
the
gc-08-gc-fixes
branch
from
September 13, 2026 19:14
c59bf08 to
31c5333
Compare
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
commented
Sep 13, 2026
lukesandberg
force-pushed
the
gc-08-gc-fixes
branch
from
September 13, 2026 22:32
31c5333 to
e859bff
Compare
lukesandberg
commented
Sep 14, 2026
lukesandberg
force-pushed
the
gc-08-gc-fixes
branch
from
September 14, 2026 06:10
e859bff to
ff1f64f
Compare
Enabling GC on CI surfaced ~14.5k panics from the aggregation graph. Three related fixes: - `followers` is no longer a collectibility pin. A follower is an *outgoing* edge, so it says nothing about whether anything still reaches this task; only `upper` (incoming) does. Treating it as a pin made any task that had grown a follower during aggregation-graph reorganization permanently uncollectible. - Defer rebalance work until the parallel collect phase is quiescent. Running `balance_edge` while other workers were still collecting could add aggregation edges to a task that had just been soft-deleted. The queues GC collects with also refuse optimizations outright: optimizing only raises an aggregation number to shrink fan-out, which is regenerable via `optimization_pending`, unlike `balance_edge`, which restores an invariant. - Guard the aggregation-edge add sites against deleted tasks, so a sibling cascade cannot resurrect edges on a tombstone. Also deepens the GC test fixture: the previous graph was too shallow to build interior aggregation nodes, which is why none of this was caught by existing coverage. The fixture now recurses to a configurable branching factor with a retained top layer, so collection happens under a live root -- the common case. Includes a rename of `GcStats` to `GcPassOutcome` and a revert of incidental formatting churn in the napi bindings. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
lukesandberg
force-pushed
the
gc-08-gc-fixes
branch
from
September 14, 2026 06:33
ff1f64f to
9eae998
Compare
lukesandberg
marked this pull request as ready for review
September 14, 2026 06:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix AggregationGraph updates during GC.
During GC we aremoving a lot of edges so this can trigger a lot of aggregation graph churn. Because of the highly parallel nature of GC this can end up with multiple queues fighting over updates which can exceed various retry limits and lead to things like trying to turn nodes into
followersthat are actively being deleted.Instead we just don't rebalance the aggregation graph during GC, instead we buffer every
rebalancerequest and set theoptimizebudget to zero. Then after GC settles we process all the rebalances at once, taking care to filter out any tasks that have been since deleted.Because GC is only removing edges it can lead to inefficient graphs (too many interior nodes) but not violate graph invariants.
Alternatives considered:
The initial idea was to ensure GC had finished with all 'children' of the node before processing rebalance requests, but this was only a partial solution (and complex!), since it didn't handle the case of an aggregating node having multiple children become collectible in the initial scan, this could still trigger 'optimization contention' and turning dead nodes into followers.
Testing:
The test/benchmark are enhanced to produce non-trivial aggregation graphs which improves test coverage (though the issue of racing deletes was trivially found by CI also)