Skip to content

Commit

Permalink
use mimalloc instead of system allocator
Browse files Browse the repository at this point in the history
Benchmarks:

```
group                          base                                   jemalloc                               mimalloc                               mimalloc-insecure
-----                          ----                                   --------                               --------                               -----------------
ripgrep::node_modules          1.00    140.7±1.24ms        ? ?/sec    1.91    267.8±6.46ms        ? ?/sec    1.00    140.1±1.48ms        ? ?/sec    1.00    140.5±1.73ms        ? ?/sec
ripgrep::package-lock.json     1.16  1690.3±43.28µs        ? ?/sec    1.09  1587.6±29.90µs        ? ?/sec    1.05  1526.9±23.70µs        ? ?/sec    1.00  1455.6±36.80µs        ? ?/sec
ripgrep::testdata              1.18  1279.0±56.35µs        ? ?/sec    1.37  1481.4±42.61µs        ? ?/sec    1.00  1079.3±56.64µs        ? ?/sec    1.09  1179.5±72.64µs        ? ?/sec
syntect::package-lock.json     1.27   704.2±35.54ms        ? ?/sec    1.05   580.7±37.35ms        ? ?/sec    1.04   579.8±31.08ms        ? ?/sec    1.00   554.9±30.07ms        ? ?/sec
syntect::ripgrep-background    1.25    109.2±1.83ms        ? ?/sec    1.04     90.9±0.93ms        ? ?/sec    1.03     90.1±1.79ms        ? ?/sec    1.00     87.2±1.06ms        ? ?/sec
syntect::ripgrep-large         1.09    422.4±3.94ms        ? ?/sec    1.31   507.9±10.91ms        ? ?/sec    1.01    392.8±4.37ms        ? ?/sec    1.00    387.1±4.92ms        ? ?/sec
syntect::ripgrep-no-wrap       1.25    109.2±1.49ms        ? ?/sec    1.04     90.9±1.07ms        ? ?/sec    1.03     89.8±1.11ms        ? ?/sec    1.00     87.3±1.26ms        ? ?/sec
syntect::ripgrep-small         1.25    109.1±1.59ms        ? ?/sec    1.04     91.1±1.55ms        ? ?/sec    1.02     89.8±1.28ms        ? ?/sec    1.00     87.6±2.02ms        ? ?/sec
syntect::ripgrep-tiny          1.55     48.4±0.48ms        ? ?/sec    1.13     35.3±1.75ms        ? ?/sec    1.07     33.3±0.44ms        ? ?/sec    1.00     31.2±0.53ms        ? ?/sec
```

mimalloc without secure mode is fastest in most benchmarks
  • Loading branch information
rhysd committed Oct 31, 2021
1 parent b03b62c commit 2587e82
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
20 changes: 20 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
Expand Up @@ -92,6 +92,7 @@ bincode = { version = "1.3", optional = true }
flate2 = { version = "1", optional = true }
rgb2ansi256 = { version = "0.1", optional = true }
dirs-next = { version = "2.0", optional = true }
mimalloc = { version = "0.1", default-features = false }

[target."cfg(windows)".dependencies]
ansi_term = "0.12"
Expand Down
1 change: 1 addition & 0 deletions hgrep-bench/Cargo.toml
Expand Up @@ -10,6 +10,7 @@ bench = false

[dependencies]
hgrep = { path = ".." }
mimalloc = { version = "0.1", default-features = false }

[dev-dependencies]
criterion = "0.3"
Expand Down
3 changes: 3 additions & 0 deletions hgrep-bench/src/lib.rs
@@ -1,6 +1,9 @@
use std::fs;
use std::path::Path;

#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

pub fn package_lock_json_path() -> &'static Path {
let path = Path::new("package-lock.json");
assert!(
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Expand Up @@ -7,6 +7,9 @@ use std::env;
use std::io;
use std::process;

#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[cfg(feature = "ripgrep")]
use hgrep::ripgrep;

Expand Down

0 comments on commit 2587e82

Please sign in to comment.