Skip to content

Reuse freed GC block IDs without restarting a full-table search for every block #208

Closed

Description

@dimensionscape

BlockDataInfo's constructor in src/hx/gc/Immix.cpp checks gBlockInfoEmptySlots, then searches gBlockInfo from index zero for the first null slot. destroy() nulls a slot and increments the count, but does not record the freed ID. Refilling many holes repeats a growing prefix scan for every block.

After a large heap is compacted and released, regrowing into N empty slots can examine N*(N+1)/2 entries. gBlockInfo retains its historical size, so this affects later allocation bursts even after the managed heap shrinks.

A metadata-only probe at checkout 03a4e8d copied the constructor's first-null-slot search over a cleared hx::QuickVec<void*>. Linux x86_64 through WSL, g++ -O2 -std=c++17:

Slots refilled Time Entries examined
4096 1.583 ms 8390656
16384 24.271 ms 134225920
65536 391.923 ms 2147516416

This isolates the search pattern; it does not instantiate BlockDataInfo or measure an actual application allocation pause. It establishes the repeated scan cost, while a real grow/shrink benchmark is still needed to determine its contribution.

Track freed block IDs directly, or maintain a suitable next-free cursor, so reuse does not restart at zero each time. Preserve existing IDs for live blocks and verify the BlockIdType limits under default and big blocks. Keep native allocation-failure handling and the locking/collection lifecycle intact.

Test holes at the start, middle and end, mixed surviving groups, and repeated release/regrowth with verifier builds. Measure allocation throughput and tail latency after a temporary large heap. Related: #207 covers a separate quadratic metadata operation during release, and #151 covers benchmarking.

Activity

  1. added a commit that references this issue on Oct 20, 2026
    584adf8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions