Skip to content

Commit f53acf7

Browse files
claudeconnortsui20
authored andcommitted
Use mimalloc as the global allocator in every benchmark binary
Twenty-two benchmark binaries already used mimalloc, on the advice of the benchmarking guide; the other 81 used the system allocator, whose cost depends on state that differs between runner images and between runs. Several simulation benchmarks that allocate inside the timed region flipped between two values on pull requests that could not have affected them, among them split_collection's cold_misaligned, fsst_compress's compress_fsst, and take_chunked's repeated-index case. Give every benchmark binary the same allocator, add the workspace mimalloc dev-dependency to the 16 crates that lacked it, and make the guide's recommendation a rule. The CUDA and DuckDB benchmarks are left alone: they run on different legs and link C++ code. Signed-off-by: Claude <[email protected]>
1 parent e482701 commit f53acf7

99 files changed

Lines changed: 368 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

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

‎docs/developer-guide/benchmarking.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,23 @@ trace — including cache and memory access costs. This has several implications
182182
[walltime instrument](https://codspeed.io/docs/instruments/walltime) or be gated with
183183
`#[cfg(not(codspeed))]`.
184184

185-
### Prefer `mimalloc` for throughput benchmarks
185+
### Use `mimalloc` as the global allocator
186186

187-
Throughput benchmarks should use `mimalloc` as the global allocator to reduce system allocator
188-
noise:
187+
Every benchmark binary uses `mimalloc` as its global allocator:
189188

190189
```rust
191190
use mimalloc::MiMalloc;
192191
#[global_allocator]
193192
static GLOBAL: MiMalloc = MiMalloc;
194193
```
195194

195+
The system allocator's cost depends on its state, which differs between runner images and between
196+
runs, so allocation inside a timed region made several simulation benchmarks flip between two
197+
values on pull requests that could not have affected them. `mimalloc` does the same work every
198+
time, and one allocator for every binary means no benchmark measures a different allocator from
199+
its neighbours. Add the two lines to every new benchmark file; each crate with benchmarks already
200+
has the `mimalloc` dev-dependency.
201+
196202
## SQL Benchmarks
197203

198204
SQL benchmarks measure end-to-end query performance across different engines and file formats.

‎encodings/alp/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ vortex-session = { workspace = true }
3030

3131
[dev-dependencies]
3232
divan = { workspace = true }
33+
mimalloc = { workspace = true }
3334
rand = { workspace = true }
3435
rstest = { workspace = true }
3536
vortex-array = { workspace = true, features = ["_test-harness"] }

‎encodings/alp/benches/alp_compress.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use std::sync::LazyLock;
77

88
use divan::Bencher;
9+
use mimalloc::MiMalloc;
910
use rand::RngExt;
1011
use rand::SeedableRng as _;
1112
use rand::rngs::StdRng;
@@ -25,6 +26,9 @@ use vortex_buffer::Buffer;
2526
use vortex_buffer::buffer;
2627
use vortex_session::VortexSession;
2728

29+
#[global_allocator]
30+
static GLOBAL: MiMalloc = MiMalloc;
31+
2832
fn main() {
2933
divan::main();
3034
}

‎encodings/datetime-parts/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ vortex-session = { workspace = true }
2727

2828
[dev-dependencies]
2929
divan = { workspace = true }
30+
mimalloc = { workspace = true }
3031
rand = { workspace = true }
3132
rstest = { workspace = true }
3233
vortex-array = { workspace = true, features = ["_test-harness"] }

‎encodings/datetime-parts/benches/split_temporal.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use std::sync::LazyLock;
77

88
use divan::Bencher;
9+
use mimalloc::MiMalloc;
910
use rand::RngExt;
1011
use rand::SeedableRng as _;
1112
use rand::rngs::StdRng;
@@ -19,6 +20,9 @@ use vortex_buffer::Buffer;
1920
use vortex_datetime_parts::split_temporal;
2021
use vortex_session::VortexSession;
2122

23+
#[global_allocator]
24+
static GLOBAL: MiMalloc = MiMalloc;
25+
2226
fn main() {
2327
divan::main();
2428
}

‎encodings/decimal-byte-parts/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ vortex-session = { workspace = true }
2828
[dev-dependencies]
2929
divan = { workspace = true }
3030
hegeltest = { workspace = true }
31+
mimalloc = { workspace = true }
3132
rand = { workspace = true }
3233
rstest = { workspace = true }
3334
vortex-array = { path = "../../vortex-array", features = ["_test-harness"] }

‎encodings/decimal-byte-parts/benches/dbp_assemble.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod common;
88

99
use divan::Bencher;
1010
use divan::black_box;
11+
use mimalloc::MiMalloc;
1112
use vortex_array::dtype::DecimalType;
1213
use vortex_array::dtype::i256;
1314
use vortex_buffer::buffer;
@@ -22,6 +23,9 @@ use crate::common::cases;
2223
use crate::common::i128_values;
2324
use crate::common::i256_values;
2425

26+
#[global_allocator]
27+
static GLOBAL: MiMalloc = MiMalloc;
28+
2529
fn main() {
2630
divan::main();
2731
}

‎encodings/decimal-byte-parts/benches/dbp_split.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod common;
88

99
use divan::Bencher;
1010
use divan::black_box;
11+
use mimalloc::MiMalloc;
1112
use rand::RngExt;
1213
use rand::SeedableRng;
1314
use rand::rngs::StdRng;
@@ -22,6 +23,9 @@ use crate::common::cases;
2223
use crate::common::i128_values;
2324
use crate::common::i256_values;
2425

26+
#[global_allocator]
27+
static GLOBAL: MiMalloc = MiMalloc;
28+
2529
fn main() {
2630
divan::main();
2731
}

‎encodings/fastlanes/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ vortex-session = { workspace = true }
3535
[dev-dependencies]
3636
divan = { workspace = true }
3737
itertools = { workspace = true }
38+
mimalloc = { workspace = true }
3839
rand = { workspace = true }
3940
rstest = { workspace = true }
4041
vortex-alp = { path = "../alp" }

0 commit comments

Comments
 (0)