fix: bound hierarchical scan scratch ranges - #16
Merged
Conversation
SamJSui
marked this pull request as ready for review
August 8, 2026 22:41
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.
Summary
Root cause
Deeper hierarchy levels place
dataandauxiliaryat different offsets in one scratch buffer. Both bindings previously usedsize: None, so the data view extended through the next auxiliary level. Rounded-up WGSL threads used that largerarrayLength(&data)and could overwrite the next level, producing a scheduling-sensitive writable-storage race.The fix bounds
datatonum_items * 4bytes andauxiliarytoceil(num_items / items_per_block) * 4bytes. It changes views only; it does not add allocation or copies.Validation
cargo fmt --all --checkcargo test --lib --testscargo clippy --all-targets --all-features -- -D warningscargo doc --no-depscargo package --allow-dirtygit diff --checkPerformance finding
Correctness is closed, but valid 100M data confirms the next optimization target. Massively is 1.95x faster for scan and 1.49x for compaction on RTX, and 2.03x/1.71x faster on the 4-TPC Jetson.