Skip to content

Apache DataFusion SQL Query Engine

ARROW-11825: [Rust][DataFusion] Add mimalloc as option to benchmarks

Heres, Daniel4e4320eaefab
diff --git a/rust/benchmarks/Cargo.toml b/rust/benchmarks/Cargo.toml
index 9965571001..5cdf0f94ac 100644
--- a/rust/benchmarks/Cargo.toml
+++ b/rust/benchmarks/Cargo.toml
@@ -38,4 +38,5 @@ structopt = { version = "0.3", default-features = false }
tokio = { version = "^1.0", features = ["macros", "rt", "rt-multi-thread"] }
futures = "0.3"
env_logger = "^0.8"
+mimalloc = { version = "0.1", optional = true, default-features = false }
snmalloc-rs = {version = "0.2", optional = true, features= ["cache-friendly"] }
diff --git a/rust/benchmarks/README.md b/rust/benchmarks/README.md
index bb56b75a1b..7460477db4 100644
--- a/rust/benchmarks/README.md
+++ b/rust/benchmarks/README.md
@@ -53,10 +53,10 @@ The benchmark can then be run (assuming the data created from `dbgen` is in `/mn
cargo run --release --bin tpch -- benchmark --iterations 3 --path /mnt/tpch-dbgen --format tbl --query 1 --batch-size 4096
```
-You can enable the features `simd` (to use SIMD instructions) and/or `snmalloc` (to use the snmalloc allocator) as features by passing them in as `--features`:
+You can enable the features `simd` (to use SIMD instructions) and/or `mimalloc` or `snmalloc` (to use either the mimalloc or snmalloc allocator) as features by passing them in as `--features`:
```
-cargo run --release --features "simd snmalloc" --bin tpch -- benchmark --iterations 3 --path /mnt/tpch-dbgen --format tbl --query 1 --batch-size 4096
+cargo run --release --features "simd mimalloc" --bin tpch -- benchmark --iterations 3 --path /mnt/tpch-dbgen --format tbl --query 1 --batch-size 4096
```
The benchmark program also supports CSV and Parquet input file formats and a utility is provided to convert from `tbl`
diff --git a/rust/benchmarks/src/bin/tpch.rs b/rust/benchmarks/src/bin/tpch.rs
index f0f2e7cf57..b0a6cedd17 100644
--- a/rust/benchmarks/src/bin/tpch.rs
+++ b/rust/benchmarks/src/bin/tpch.rs
@@ -40,6 +40,10 @@ use structopt::StructOpt;
#[global_allocator]
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
+#[cfg(feature = "mimalloc")]
+#[global_allocator]
+static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
+
#[derive(Debug, StructOpt)]
struct BenchmarkOpt {
/// Query number