From 7e0c0bf698e0b1af82d26693895ecd15cc2db582 Mon Sep 17 00:00:00 2001 From: Elijah Mirecki Date: Sun, 19 Dec 2021 11:53:02 -0500 Subject: [PATCH] Switch to jemalloc (for 33% better performance) --- Cargo.lock | 42 ++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 ++- src/main.rs | 4 ++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f638ccd..14526e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,3 +5,45 @@ version = 3 [[package]] name = "b64" version = "0.1.0" +dependencies = [ + "jemallocator", +] + +[[package]] +name = "cc" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" + +[[package]] +name = "fs_extra" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" + +[[package]] +name = "jemalloc-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45" +dependencies = [ + "cc", + "fs_extra", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69" +dependencies = [ + "jemalloc-sys", + "libc", +] + +[[package]] +name = "libc" +version = "0.2.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" diff --git a/Cargo.toml b/Cargo.toml index 1c6a3af..d770370 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,5 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[dependencies] \ No newline at end of file +[dependencies] +jemallocator = "0.3.2" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 9e067d4..26043e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,10 @@ struct Opts { inputs: Vec, } +// jemalloc performs a lot better in multithreaded applications +#[global_allocator] +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; + fn main() { let opts = parse_opts();