Feature-gated allocation counter + alloc-budget test#79
Merged
joaquinbejar merged 1 commit intomainfrom Apr 25, 2026
Merged
Conversation
Wraps any inner GlobalAlloc and tracks four AtomicU64 counters
(allocs / deallocs / bytes_allocated / bytes_deallocated). Bench /
test binaries opt in via:
use orderbook_rs::CountingAllocator;
use std::alloc::System;
#[global_allocator]
static A: CountingAllocator<System> = CountingAllocator::new(System);
The library rlib does not install a global allocator. The wrapper
exists so bench / budget-test binaries can measure hot-path
allocation without forcing a global choice.
New bench at benches/order_book/alloc_count.rs reports allocs_per_op
+ bytes_alloc/op for the mixed 70/20/10 workload (200k warmup +
1M measured) and writes a markdown summary to
target/alloc-counters/. New integration test at
tests/alloc_budget.rs (its own [[test]] binary, gated on
alloc-counters) asserts allocs/op < 10 over 10 000 mixed ops as a
CI regression guard.
mod utils is now pub mod utils so the new types are reachable via
the canonical orderbook_rs::utils path. counting_allocator carries a
documented #[allow(unsafe_code)] exception confined to the
GlobalAlloc trait boundary.
BENCH.md gains an Allocation profile section. CHANGELOG and lib.rs
updated.
Closes #58.
8 tasks
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.
Closes #58. Adds CountingAllocator + AllocSnapshot behind alloc-counters feature, alloc_count bench reporting allocs_per_op + bytes_alloc/op, and tests/alloc_budget.rs asserting allocs/op < 10 over 10k mixed ops. Library rlib does not install a global allocator. mod utils is now pub. BENCH.md gains Allocation profile section.