Skip to content

Implement stable raw byte Arena - #440

Draft
helly25 wants to merge 5 commits into
perf/benchmark-artifactsfrom
feature/arena
Draft

helly25 wants to merge 5 commits into
perf/benchmark-artifactsfrom
feature/arena

Conversation

@helly25

@helly25 helly25 commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Implements the raw byte Arena and block-source layer required by SegmentedSequence and StringInterner. The implementation makes address stability, transactional failure, block growth, ownership transfer, and exception-disabled behavior explicit, while establishing a reproducible benchmark matrix rather than selecting performance-sensitive defaults by intuition.

This pull request is intentionally draft. It must not merge until the layout experiments are complete and validated JSON measurements exist for both Apple M5 Pro and AMD Zen 5.

AG;DR

  • Adds MemoryBlock and the BlockSource concept.
  • Adds new/delete, fixed external, inline, standard allocator, and PMR block sources.
  • Encodes whether a source can genuinely recover allocation failure. Standard allocator and PMR-backed arenas expose TryAllocate only in exception-enabled builds because those standard APIs report exhaustion through std::bad_alloc.
  • Adds Arena<Source, ArenaOptions> with aligned stable byte allocation, transactional failure, geometric normal blocks, dedicated oversized blocks, O(1) block append, retained-block Reset, full Release, conditional address-preserving move/swap, and O(1) counters.
  • Keeps raw Arena free of object-destruction registration; a future ObjectArena remains separate.
  • Adds tests for alignment, fixed exhaustion, reset/release, move assignment, swap, source adapters, every public request-validation mode, recoverable allocator/PMR exhaustion, strict source-contract validation, and oversized growth behavior.
  • Adds a dedicated memory coverage category and baseline. The integrity checker now permits additive categories while continuing to reject changes to every existing category, top-level scope, and source exclusion. The Arena tests satisfy the enforced high boundaries without exclusions.
  • Adds Google Benchmark comparisons against PMR monotonic allocation and direct new/delete, including allocator/PMR-backed Arena variants, fresh versus retained lifecycle costs, mixed string-like sizes, memory counters, and alignments through 256 bytes.
  • Adds detailed methodology and an immutable JSON evidence location under mbo/memory/measurements.

Validation at head 64123479c:

  • bazel test //mbo/memory:arena_test //mbo/memory:block_source_test
  • focused Clang coverage: memory 97.07% lines, 100.00% functions, 92.86% branches
  • coverage-policy evaluation using the PR coverage artifact with the updated memory records: every category passes
  • coverage-integrity comparison against the base branch: passes with no lowered baseline and no source exclusions
  • focused pre-commit hooks for all changed files
  • GCC-compatible control flow in the invalid-response source test, with the focused Arena test passing locally

Still required before review/merge:

  • complete the growth/layout and string-record proof branches;
  • expand failure, lifecycle, mixed-size, fragmentation, and source benchmarks;
  • run the clean nine-repetition protocol on Apple M5 Pro and AMD Zen 5;
  • commit and validate both raw JSON artifacts;
  • document the measured selection and known limitations.

Portability: the API and implementation target C++20. Later-standard naming and semantics are followed where expressible in C++20. The raw-storage representation does not claim constexpr allocation in C++20.

@helly25
helly25 force-pushed the feature/arena branch 2 times, most recently from a4a5f67 to 3a59f0b Compare September 10, 2026 18:43
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.

1 participant