Mimalloc in every bench - #32
Merged
Merged
Conversation
`#[global_allocator]` lived in exactly two places — `apps/bench/src/main.rs` and `benchmarks/onnx-models/src/main.rs`. Bench, example, and every `src/bin/*.rs` target is its own crate root, so a declaration in a package's `main.rs` never reaches its siblings. `benchmarks/onnx-models` was therefore split three ways against itself: the bin ran mimalloc while `benches/onnx_models.rs` and `examples/bench_yolo.rs` ran the system allocator, the latter being exactly what `scripts/bench-all-competitors.sh` measures for the published "yscv CPU" number. All 17 criterion benches behind the CI regression gates were on system malloc, as were the `apps/llm-bench` harnesses — `compute_gap` and `bench_tracker` — that produced the single-op and Siamese tracker tables in `docs/performance-benchmarks.md`, whose methodology section nonetheless claimed a mimalloc global allocator. The gate that decides whether a hot-path change regressed and the harness whose numbers go in the commit message did not agree on the allocator. `benchmarks/rust-competitors` had no declaration either, so `run-suite.sh` compared yscv-on-mimalloc against tract-on-system-malloc. Hoist mimalloc into `[workspace.dependencies]` so the version is stated once, and declare it in all 39 measurement entry points: the 17 criterion benches, `fpv-latency`, the 7 llm-bench bins, `bench_yolo`, the 9 `bench_*` examples, and the tract harness. The library crates keep no declaration on purpose — a `#[global_allocator]` is a whole-program singleton, so a library that sets one forces it on every consumer and hard-fails the link against any binary that sets its own; it would also put libmimalloc-sys's C toolchain in the dependency path of the published crates and of the RISC-V/WASM fallback targets. README and `docs/architecture.md` relabel the `Allocator` row in the SIMD matrix to `Bench-harness allocator`, since sitting among per-platform kernel rows it read as a framework-wide property. The existing tables in `docs/performance-benchmarks.md` predate this change and are flagged in-place as needing a re-run before they can be compared against post-unification measurements. Validation: `scripts/check-ci-local.sh` default path clean; `cargo clippy --workspace --all-targets --all-features -- -D warnings` clean; `cargo test --workspace` 53 targets, 0 failures. Criterion gates re-run for yscv-tensor, yscv-imgproc and yscv-kernels: 43/43 PASS against the existing absolute `max_upper_us` ceilings, which the allocator switch cannot silently invalidate since they are bounds rather than deltas. `nm` confirms 3 mimalloc symbols in the freshly built bench binaries against 0 in the pre-change hashes. `cargo +nightly miri test -p yscv-recognize` still builds and runs, since the allocator sits in the bench crate root and not the lib test target.
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.
Let's make mimalloc a default allocator in all benches for consistency.
@enthropy7 ig we'll have to re-measure some stuff now