Disable GC zeal allocation counter when retrying after GC#13278
Merged
Conversation
With a GC zeal allocation counter of `1`, we would otherwise indefinitely fail to allocate, even after we did the GC that the counter triggered, when we tried to allocate again the GC zeal counter would force-return another OOM. Instead, we temporarily disable the GC zeal allocation counter in `retry_after_gc_async` on the retry path. This resets the counter after we have done our second-attempt allocation, giving the desired sequence of events for `gc_zeal_alloc_counter=1` where we GC once on every `retry_after_gc_async` call: * Attempt to allocate * Fails with GC OOM due to `gc_zeal_alloc_counter` going from `1` to `0` * `gc_zeal_alloc_counter` reset to `1` * Disable `gc_zeal_alloc_counter` * Do GC-or-growth * Retry allocation * Succeeds or fails without interference from the `gc_zeal_alloc_counter` * Re-enable `gc_zeal_alloc_counter=1` so everything repeats on the next `retry_after_gc_async` call Fixes bytecodealliance#13263
alexcrichton
approved these changes
May 5, 2026
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.
With a GC zeal allocation counter of
1, we would otherwise indefinitely fail to allocate, even after we did the GC that the counter triggered, when we tried to allocate again the GC zeal counter would force-return another OOM.Instead, we temporarily disable the GC zeal allocation counter in
retry_after_gc_asyncon the retry path. This resets the counter after we have done our second-attempt allocation, giving the desired sequence of events forgc_zeal_alloc_counter=1where we GC once on everyretry_after_gc_asynccall:gc_zeal_alloc_countergoing from1to0gc_zeal_alloc_counterreset to1gc_zeal_alloc_countergc_zeal_alloc_countergc_zeal_alloc_counter=1so everything repeats on the nextretry_after_gc_asynccallFixes #13263