Repository navigation
Merged
Conversation
added 3 commits
November 8, 2026 12:56
…when freed; a large block grows in place within its mapping A large allocation (payload over 4 KiB) was its own mapping, mapped and unmapped per List buffer and recorded and forgotten in the sorted range table with a shift each: a fifth of `check src/main.w` by sampling (rt_range_store, rt_record_large_range, rt_forget_large_range, mmap, munmap), fed by the per-scope snapshots and per-call lookups that make and drop a buffer over 4 KiB each time. A large block up to 2 MiB is now mapped at the power of two that holds it and, when freed, kept on a per-class list (32 blocks a class, 96 MiB in all) for the next allocation of its class: still mapped, still recorded, its size word 0 so it is not an owned payload (the ownership test's large branch reads the word), its payload zeroed when reused. WITH_ALLOC_NO_REUSE bypasses the cache as it does the small freelists. A large block that grows within its mapping grows in place, header updated and new bytes zeroed, instead of allocate-copy-free.
…sed large buffers come back zeroed
…elds to the memory limit Power-of-two mappings doubled the committed bytes of a payload just over a power of two, and the retained cache counted against WITH_MEMORY_LIMIT_BYTES: behav_1944_comptime_snapshot_memory (a 32 MiB limit over 64 KiB receivers) failed in the battery. Mappings up to 256 KiB are now a multiple of the 16 KiB page (one class per multiple; the kernel commits no less), powers of two above that; and a reservation that would cross the limit first gives every cached block back, so the cache is never what the limit measures.
ehartford
marked this pull request as ready for review
November 8, 2026 21:41
Contributor
Author
|
Battery GREEN on f9db712: |
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.
Fixes #3103.
A large allocation (payload over 4 KiB) was its own mapping, mapped and unmapped per List buffer and recorded and forgotten in the sorted range table with a shift each: about a fifth of
check src/main.wby sampling (rt_range_store,rt_record_large_range,rt_forget_large_range,mmap,munmap), fed by per-scope snapshots and per-call lookups that make and drop a buffer over 4 KiB each time.A large block is now mapped at a class size (a multiple of the 16 KiB page up to 256 KiB, a power of two up to 2 MiB above) and, when freed, kept on its class's list (32 blocks a class, 96 MiB in all) for the next allocation of its class: still mapped, still recorded, its size word 0 so it is not an owned payload (the ownership test's large branch reads the word), its payload zeroed when reused.
WITH_ALLOC_NO_REUSEbypasses the cache as it does the small freelists; a reservation that would crossWITH_MEMORY_LIMIT_BYTESfirst gives every cached block back, so the cache is never what the limit measures (the first battery's red,behav_1944_comptime_snapshot_memory, was that). A large block that grows within its mapping grows in place.Measured back to back on
check src/main.w: installed compiler (main, no cache) 97 s, this tree's stage2 85 s; the earlier power-of-two version measured 102 s → 86 s and 93 s → 83 s under battery load.Fixtures:
test/debug_alloc/da_3103_large_block_double_free_reported.w(a cached block's second free still reaches the ledger) andtest/behavior/behav_3103_large_blocks_reused.w(reused buffers come back zeroed and whole). Gate green on the first version; battery running on this one.