Phase 11.7: fix Rust stats tests missing #[global_allocator] install - #59
Merged
Merged
Conversation
The `frontend_stats`, `full_stats`, `sizeclass_histogram`, and `profile_lifetime_histogram` integration tests rely on the test binary's allocations feeding snmalloc's process-global counters. Without `#[global_allocator] static ALLOC: SnMalloc = SnMalloc;` at the top of each binary, the default cargo test runner routes allocations through the OS allocator and the counters under test stay at zero, causing intermittent panics such as `fast_path_allocs delta (=0) must rise by at least 990`. Mirrors the pattern already used by `snmalloc-rs/benches/stats_bench.rs` (Phase 11.1). No test logic was changed. ClickUp: 86aj0yehx
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.
Summary
SnMallocas the#[global_allocator]at the top of the four affected integration-test binaries (frontend_stats,full_stats,sizeclass_histogram,profile_lifetime_histogram) so the binary's allocations feed snmalloc's process-global counters instead of routing through the OS allocator and leaving the counters at zero.snmalloc-rs/benches/stats_bench.rs(Phase 11.1).ClickUp
Test plan
cargo build --features statssucceedscargo test --features stats-- all previously-failing tests pass (fast_path_alloc_counter_grows,cross_thread_messages_grow,full_stats_bytes_in_use_grows_with_live_allocation,full_stats_backend_frag_invariants,cumulative_alloc_per_class_rises)cargo test(no features) still passescargo test --features profiling --test profile_lifetime_histogramstill passesNotes
Coordinates with Phase 11.6 (tiered stats). If 11.6 changes the gating of
SnMalloc::full_stats()fromstatstostats-basic, the three#![cfg(feature = "stats")]test files (and their#[global_allocator]blocks, which sit under the same gate) will need a parallel update to#[cfg(any(feature = "stats", feature = "stats-basic"))].