Skip to content

Commit

Permalink
Use mimalloc
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
joshuaclayton committed May 25, 2020
1 parent b1495f3 commit a206e55
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ read_ctags = { path = "crates/read_ctags/" }
token_search = { path = "crates/token_search/" }
codebase_files = { path = "crates/codebase_files/" }
cli = { path = "crates/cli/" }
mimalloc = { version = "*", default-features = false }

[[bin]]
name = "read-ctags-rs"
Expand Down
3 changes: 3 additions & 0 deletions src/bin/unused.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

use cli;

fn main() {
Expand Down

0 comments on commit a206e55

Please sign in to comment.