You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Large allocations (>4 KiB) are mmapped one by one and tracked in a shifting sorted array: ~20% of check src/main.w by sampling #3103
So about a fifth of the check is the allocator's large-block path: every allocation over RT_LARGE_THRESHOLD (4096) is its own mmap, freed with munmap, and recorded in a sorted array by shift-insert (rt_record_large_range) and shift-remove (rt_forget_large_range), O(n) each, with n the number of live large blocks. The callers that allocate large blocks most in the sample: Sema.pop_scope (350), check_concrete_trait_method_call → find_dyn_trait_method_info → lookup_trait_named (322–348), check_if_expr (~180 each at three sites) — List buffers over 4 KiB made and freed per scope or per method-call check (save_scope_states and the poison snapshots copy lists per scope).
Two fixes, both in rt/rt_core.w and both measurable with the same sample:
A cache of freed large blocks by rounded size (pages, power of two up to some ceiling), so a scope's snapshot list reuses the block the previous scope freed instead of munmap + mmap; WITH_ALLOC_NO_REUSE keeps the debug behavior.
Ownership by page hash, not a sorted array: slabs already map page → start through rt_owned_put; large blocks can use the same table (one entry per page of the block, or per first page with the size in the header), making record/forget O(pages) with no shifting, and rt_payload_start_is_owned's large branch a hash probe instead of a binary search.
Then the Sema side (#3100): why pop_scope and a trait-method lookup allocate over 4 KiB per call; a snapshot that copies a whole list per scope wants a stack mark or an epoch.
Activity
#3103: the large-block cache maps page multiples up to 256 KiB and yi…
#3103: large blocks are mapped at a power of two and cached by class …