Skip to content

feat: implement bitmap-managed arena for improved cache locality#21

Draft
ByteMaster2003 wants to merge 1 commit intoboa-dev:mainfrom
ByteMaster2003:bitmap_arena
Draft

feat: implement bitmap-managed arena for improved cache locality#21
ByteMaster2003 wants to merge 1 commit intoboa-dev:mainfrom
ByteMaster2003:bitmap_arena

Conversation

@ByteMaster2003
Copy link

@ByteMaster2003 ByteMaster2003 commented Mar 2, 2026

Closes #22

Summary

This PR introduces arena3, a bitmap-managed memory allocator designed to replace the linked-list approach in arena2. By managing memory as a grid of 64-byte cells and tracking them via a bitmask, we improve allocation speed and significantly reduce metadata overhead.

Key Changes

  • Bitmap-based Tracking: Replaced the next pointer logic with a Vec<u64> bitmap.
  • Consolidated GcBox: Removed ArenaHeapItem. The GcBox<T> is now the top-level structure stored in the arena, saving 8 bytes per object.
  • Optimized Allocation: Implemented bitwise scanning using trailing_zeros() for O(1) allocation on the fast path.
  • Alignment Guarantees: Enforced 64-byte cell alignment to ensure predictable pointer arithmetic (Address=Base+(Index×64)).

Architectural Improvements

  1. Reduced Fragmentation: By using fixed-size cells, we can quickly identify gaps without traversing the entire heap.
  2. Cache Efficiency: During the "Sweep" phase, the collector only needs to scan the bitmap vector (likely residing in L1 cache) before touching the actual object memory.
  3. API Parity: Maintained functional parity with arena2 signatures to allow for a drop-in replacement during the benchmarking phase.

Current Status

  • Basic BitmapArena implementation.
  • Fast-path allocation logic.
  • Consolidated header layout.
  • Sweep logic integration (pending architectural feedback).
  • Arena recycling/swapping strategy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Implementation of Bitmap-managed Arena (arena3) for improved cache locality

1 participant