From 5a154866e36fdba1473cede0f9d9a4fcff45a60c Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sun, 15 Sep 2019 17:47:36 +0200 Subject: [PATCH] Use jemalloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Benchmark #1: ./fd-sys-alloc '[0-9]\.jpg$' /home/shark Time (mean ± σ): 246.8 ms ± 3.4 ms [User: 960.1 ms, System: 810.0 ms] Range (min … max): 244.1 ms … 257.1 ms 12 runs Benchmark #2: ./fd-jemalloc '[0-9]\.jpg$' /home/shark Time (mean ± σ): 201.0 ms ± 3.0 ms [User: 833.9 ms, System: 666.9 ms] Range (min … max): 196.1 ms … 206.9 ms 14 runs Summary './fd-jemalloc '[0-9]\.jpg$' /home/shark' ran 1.23 ± 0.03 times faster than './fd-sys-alloc '[0-9]\.jpg$' /home/shark' --- Cargo.toml | 1 + src/main.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index dd84f93..4dd0cc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ ctrlc = "3.1" humantime = "1.1.1" lscolors = "0.6" globset = "0.4" +jemallocator = "0.3.0" [dependencies.clap] version = "2.31.2" diff --git a/src/main.rs b/src/main.rs index c4af1ef..96964fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,10 @@ use crate::internal::{ pattern_has_uppercase_char, transform_args_with_exec, FileTypes, }; +// We use jemalloc for performance reasons, see https://github.com/sharkdp/fd/pull/480 +#[global_allocator] +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; + fn main() { let checked_args = transform_args_with_exec(env::args_os()); let matches = app::build_app().get_matches_from(checked_args);