Skip to content

Commit 2c7670b

Browse files
committed
perf: use mimalloc as the runner's global allocator
The release binary targets musl, whose allocator is slow on many small allocations and serializes threads. Post-processing a memory run decodes the whole memtrack artifact with one or more allocations per event, which on a 62M-event artifact took 8-19 minutes in CI with the musl build against 1-2 minutes with glibc for the same code. Use mimalloc, as memtrack already does, so the runner no longer depends on the libc allocator.
1 parent 5ff86d7 commit 2c7670b

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ linux-perf-data = { git = "https://github.com/mstange/linux-perf-data.git", rev
6060
] } # unreleased main as of 2026-03-19
6161
debugid = "0.8.0"
6262
memmap2 = "0.9.10"
63+
mimalloc = { workspace = true }
6364
nix = { version = "0.31.3", features = ["fs", "time", "user"] }
6465
futures = "0.3.32"
6566
runner-shared = { path = "crates/runner-shared" }
@@ -113,6 +114,7 @@ libc = "0.2"
113114
log = "0.4.28"
114115
serde_json = "1.0"
115116
serde = { version = "1.0.228", features = ["derive"] }
117+
mimalloc = "0.1"
116118
ipc-channel = "0.20"
117119
itertools = "0.14.0"
118120
rayon = "1.12"

‎crates/memtrack/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ byteorder = "1.5"
4040
rayon = "1.12"
4141
parking_lot = "0.12"
4242
typed-builder = "0.23.2"
43-
mimalloc = { version = "0.1", optional = true }
43+
mimalloc = { workspace = true, optional = true }
4444

4545
[build-dependencies]
4646
libbpf-cargo = { version = "0.26", optional = true }

‎src/main.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// musl's allocator is slow on the many small allocations made when decoding memtrack artifacts.
2+
#[global_allocator]
3+
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
4+
15
use codspeed_runner::{clean_logger, cli};
26
use console::style;
37
use log::log_enabled;

0 commit comments

Comments
 (0)