Skip to content

Commit a206e55

Browse files
committed
Use mimalloc
What? ===== Rather than using Rust's built-in allocator, this changes to using mimalloc. In looking to squeeze out further performance, benchmarks across three private Rails repositories (of varying sizes) as well as Discourse cover Rust's built-in allocator, jemalloc, and mimalloc. In starting with jemallic, the benchmarks looked quite promising: | | Rust | jemalloc | speedup vs Rust | | Codebase 1 | 1389 | 906 | 53% | | Codebase 2 | 2172 | 1541 | 41% | | Codebase 3 | 59005 | 57340 | 3% | | discourse | 2092 | 1490 | 40% | All times are measured in milliseconds and benchmarks are run with [bench](https://hackage.haskell.org/package/bench) on release mode. mimalloc resulted in even further performance gains: | | Rust | mimalloc | speedup vs Rust | speedup vs jemalloc | | Codebase 1 | 1389 | 828 | 67% | 9% | | Codebase 2 | 2172 | 1264 | 72% | 22% | | Codebase 3 | 59005 | 40176 | 47% | 43% | | discourse | 2092 | 1403 | 49% | 6% | Across the board, mimalloc presented a ~45% to 70% speedup over the Rust allocator. In each of these samples, mimalloc also outperformed jemalloc, especially with larger codebases (either number of tokens or number of files).
1 parent b1495f3 commit a206e55

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

Cargo.lock

Lines changed: 34 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
@@ -12,6 +12,7 @@ read_ctags = { path = "crates/read_ctags/" }
1212
token_search = { path = "crates/token_search/" }
1313
codebase_files = { path = "crates/codebase_files/" }
1414
cli = { path = "crates/cli/" }
15+
mimalloc = { version = "*", default-features = false }
1516

1617
[[bin]]
1718
name = "read-ctags-rs"

src/bin/unused.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#[global_allocator]
2+
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
3+
14
use cli;
25

36
fn main() {

0 commit comments

Comments
 (0)