Skip to content

Commit 18903b1

Browse files
Use mimalloc with purging disabled in each e2e benchmark binary (#10490)
The end-to-end benchmark binaries (SQL via DataFusion and DuckDB, random access, compression, string, Lance) only ran with mimalloc implicitly, through a `#[global_allocator]` declared in the `vortex-bench` library. This makes the choice explicit in each benchmark binary, and stops mimalloc from purging freed memory back to the OS during a run: mimalloc v3 purges 1s after a free, and that work lands in the middle of measured queries. --------- Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 5fc5cb8 commit 18903b1

17 files changed

Lines changed: 69 additions & 3 deletions

File tree

‎Cargo.lock‎

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

‎Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ lending-iterator = "0.1.7"
191191
libfuzzer-sys = "0.4"
192192
libloading = "0.8"
193193
liblzma = "0.4"
194+
libmimalloc-sys = { version = "0.1.49", features = ["extended"] }
194195
log = { version = "0.4.21" }
195196
memchr = "2.8.1"
196197
memmap2 = "0.9.5"

‎benchmarks/compress-bench/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ futures = { workspace = true }
2525
indicatif = { workspace = true }
2626
itertools = { workspace = true }
2727
lance-bench = { path = "../lance-bench", optional = true }
28+
mimalloc = { workspace = true }
2829
parquet = { workspace = true }
2930
regex = { workspace = true }
3031
serde = { workspace = true, features = ["derive"] }

‎benchmarks/compress-bench/src/main.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use compress_bench::vortex::VortexCompressor;
2020
use futures::FutureExt;
2121
use indicatif::ProgressBar;
2222
use itertools::Itertools;
23+
use mimalloc::MiMalloc;
2324
use regex::Regex;
2425
use vortex::utils::aliases::hash_map::HashMap;
2526
use vortex_bench::Engine;
@@ -126,7 +127,11 @@ struct Args {
126127
log_format: LogFormat,
127128
}
128129

130+
#[global_allocator]
131+
static GLOBAL: MiMalloc = MiMalloc;
132+
129133
fn main() -> anyhow::Result<()> {
134+
vortex_bench::configure_allocator();
130135
let args = Args::parse();
131136

132137
setup_logging_and_tracing_with_format(args.verbose, args.tracing, args.log_format)?;

‎benchmarks/datafusion-bench/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ datafusion-common = { workspace = true }
3535
datafusion-physical-plan = { workspace = true }
3636
futures.workspace = true
3737
itertools.workspace = true
38+
mimalloc = { workspace = true }
3839
object_store = { workspace = true, features = ["aws", "gcp"] }
3940
opentelemetry.workspace = true
4041
opentelemetry-otlp.workspace = true

‎benchmarks/datafusion-bench/src/main.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use datafusion_bench::tracer::set_labels;
2424
use datafusion_common::TableReference;
2525
use datafusion_physical_plan::ExecutionPlan;
2626
use datafusion_physical_plan::collect;
27+
use mimalloc::MiMalloc;
2728
use parking_lot::Mutex;
2829
use vortex::file::multi::MultiFileDataSource;
2930
use vortex::io::filesystem::FileSystemRef;
@@ -123,8 +124,12 @@ struct Args {
123124
options: Vec<Opt>,
124125
}
125126

127+
#[global_allocator]
128+
static GLOBAL: MiMalloc = MiMalloc;
129+
126130
#[tokio::main]
127131
async fn main() -> anyhow::Result<()> {
132+
vortex_bench::configure_allocator();
128133
let args = Args::parse();
129134
let opts = Opts::from(args.options);
130135

‎benchmarks/duckdb-bench/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test = false
2323
[dependencies]
2424
anyhow = { workspace = true }
2525
clap = { workspace = true, features = ["derive"] }
26+
mimalloc = { workspace = true }
2627
similar = { workspace = true }
2728
tokio = { workspace = true }
2829
tracing = { workspace = true }

‎benchmarks/duckdb-bench/src/main.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::path::PathBuf;
88
use clap::Parser;
99
use clap::value_parser;
1010
use duckdb_bench::DuckClient;
11+
use mimalloc::MiMalloc;
1112
use tokio::runtime::Runtime;
1213
use vortex::metrics::tracing::set_global_labels;
1314
use vortex_bench::BenchmarkArg;
@@ -103,7 +104,11 @@ struct Args {
103104
reuse: bool,
104105
}
105106

107+
#[global_allocator]
108+
static GLOBAL: MiMalloc = MiMalloc;
109+
106110
fn main() -> anyhow::Result<()> {
111+
vortex_bench::configure_allocator();
107112
let args = Args::parse();
108113
let opts = Opts::from(args.options);
109114

‎benchmarks/lance-bench/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async-trait = { workspace = true }
2424
clap = { workspace = true, features = ["derive"] }
2525
futures = { workspace = true }
2626
glob = { workspace = true }
27+
mimalloc = { workspace = true }
2728
parquet = { version = "58" }
2829
tempfile = { workspace = true }
2930
tokio = { workspace = true, features = ["full"] }

‎benchmarks/lance-bench/src/main.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use lance::deps::datafusion::arrow::util::pretty::pretty_format_batches;
1414
use lance::deps::datafusion::physical_plan::ExecutionPlan;
1515
use lance::deps::datafusion::prelude::SessionContext;
1616
use lance_bench::convert::convert_parquet_to_lance;
17+
use mimalloc::MiMalloc;
1718
use tracing::info;
1819
use vortex_bench::Benchmark;
1920
use vortex_bench::BenchmarkArg;
@@ -84,8 +85,12 @@ struct Args {
8485
options: Vec<Opt>,
8586
}
8687

88+
#[global_allocator]
89+
static GLOBAL: MiMalloc = MiMalloc;
90+
8791
#[tokio::main]
8892
async fn main() -> anyhow::Result<()> {
93+
vortex_bench::configure_allocator();
8994
let args = Args::parse();
9095
let opts = Opts::from(args.options);
9196

0 commit comments

Comments
 (0)