Repository navigation
Conversation
reuse() only returned blocks released in the current collect() to the bump pointer. A block that went to a free list in an earlier round stayed there even after the blocks above it were freed, so the heap could not shrink back past it. That matches the behavior before #583, but it is cheap to fix now that collect() runs periodically. Each reuse() now merges the free lists with the newly released blocks, rolls the bump pointer down while a candidate ends exactly at it, and rebuilds the free lists from what is left. Both inputs are identical on every rank, so the result stays symmetric. Cost is O(F log F) per collect() for F free blocks, small next to its gc.collect() and device sync. The free lists are rebuilt highest offset first, so pop() hands out the lowest block and keeps blocks near the top free for later rollbacks. The churn test now frees everything at the end and checks that the heap rolls back to where it started, which fails without this change when buffers are kept every 16 iterations. Two new tests cover a block freed in an earlier round rolling back, and the lowest-first order. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ariscript
requested review from
BKP,
artulab,
drprajap,
efric,
mawad-amd,
neoblizz and
nirvedhmeshram
as code owners
October 15, 2026 20:57
nirvedhmeshram
approved these changes
Oct 15, 2026
nirvedhmeshram
left a comment
Collaborator
There was a problem hiding this comment.
LGTM % small docs nit
ariscript
enabled auto-merge (squash)
October 15, 2026 21:55
This branch has not been deployed
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.
reuse()only returned blocks released in the currentcollect()to the bump pointer. A block that went to a free list in an earlier round stayed there even after the blocks above it were freed, so the heap could not shrink back past it. That matches the behavior before #583, but it is cheap to fix now thatcollect()runs periodically.Each
reuse()now merges the free lists with the newly released blocks, rolls the bump pointer down while a candidate ends exactly at it, and rebuilds the free lists from what is left. Both inputs are identical on every rank, so the result stays symmetric. Cost is O(F log F) percollect()for F free blocks, small next to itsgc.collect()and device sync.The free lists are rebuilt highest offset first, so
pop()hands out the lowest block and keeps blocks near the top free for later rollbacks.The churn test now frees everything at the end and checks that the heap rolls back to where it started, which fails without this change when buffers are kept every 16 iterations. Two new tests cover a block freed in an earlier round rolling back, and the lowest-first order.
This is the requested follow-up from the review comment on #583.