Skip to content

Mimalloc in every bench - #32

Merged
enthropy7 merged 1 commit into
enthropy7:mainfrom
Human9000-bit:bench-allocator-unify
Aug 19, 2026
Merged

Mimalloc in every bench#32
enthropy7 merged 1 commit into
enthropy7:mainfrom
Human9000-bit:bench-allocator-unify

Conversation

@Human9000-bit

Copy link
Copy Markdown
Collaborator

Let's make mimalloc a default allocator in all benches for consistency.

@enthropy7 ig we'll have to re-measure some stuff now

`#[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.
@enthropy7
enthropy7 merged commit 29ebc42 into enthropy7:main Aug 19, 2026
6 checks passed
enthropy7 added a commit that referenced this pull request Aug 20, 2026
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.

2 participants