Unverified Commit 45a8a82d authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: Aggregation update improvements (#90139)

## Summary

- Remove negative count handling in aggregation updates since unsigned ints can't be negative
- Add `aggregation_update_no_batch` feature flag for debugging (falls back to non-batched single-item processing)
- Fix concurrency bug in inner/follower classification: add retry loop to `inner_of_upper_has_new_follower` and its batched variants to correctly handle concurrent aggregation number changes
- Add proper `ctx.should_track_activeness()` guards to avoid unnecessary activeness checks
- Move per-iteration state inside the loop in `inner_of_upper_has_new_followers` to prevent stale values across iterations
- Remove unnecessary `BalanceEdge` for inner nodes (now handled by the retry loop)
- Fix optimize check to use `added_uppers` instead of `persistent_uppers`

## Details

The main fix addresses a concurrency issue where the follower's aggregation number was read without holding a lock, and the inner-vs-follower decision could be incorrect if it changed concurrently. The new loop re-verifies the classification under the correct lock, ensuring only one task is locked at a time while still making the correct decision.

All three variants (`inner_of_upper_has_new_follower`, `inner_of_uppers_has_new_follower`, `inner_of_upper_has_new_followers`) now follow the same STEP-numbered algorithm for consistency.

## Test plan

- [x] Existing aggregation tests pass
- [x] Verify with `aggregation_update_no_batch` feature flag that batched and non-batched paths produce equivalent results
parent 797eb7fe
......@@ -16,6 +16,7 @@ workspace = true
default = []
print_cache_item_size = ["dep:lzzzz"]
no_fast_stale = []
aggregation_update_no_batch = []
verify_serialization = []
verify_aggregation_graph = []
verify_immutable = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment