From a724270841aeee3c84906e68b3710d4130e2fe61 Mon Sep 17 00:00:00 2001 From: Avril Date: Wed, 17 Feb 2021 01:55:54 +0000 Subject: [PATCH] enabled jemalloc as default allocator for now --- .gitignore | 1 + Cargo.lock | 28 ++++++++++++++++++++++++++++ Cargo.toml | 7 ++++++- src/main.rs | 7 +++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5b36c65..58983bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target *~ *.dump +profiling/ diff --git a/Cargo.lock b/Cargo.lock index 40af383..1f7dd30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,6 +121,7 @@ dependencies = [ "async-compression", "color-eyre", "futures", + "jemallocator", "lazy_static", "libc", "memmap", @@ -148,6 +149,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "fs_extra" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -295,6 +302,27 @@ dependencies = [ "libc", ] +[[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 = "kernel32-sys" version = "0.2.2" diff --git a/Cargo.toml b/Cargo.toml index d5fb129..7453c0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,11 @@ codegen-units = 1 panic = "unwind" [features] -default = ["splash", "inspect", "defer-drop"] +default = ["splash", "inspect", "defer-drop", "jemalloc"] + +# Use jemalloc as global allocator instead of system allocator. +# May potentially cause some speedups and better memory profile on large runs. +jemalloc = ["jemallocator"] # Use `fallocate()` and memory mapping to save output data instead of normal `write()` syscalls prealloc = ["inspect", "libc", "memmap"] @@ -31,6 +35,7 @@ splash = [] async-compression = {version = "0.3", features=["tokio-02", "bzip2"], optional=true} color-eyre = {version = "0.5.10", default-features=false} futures = "0.3.12" +jemallocator = {version = "0.3.2", optional = true} lazy_static = "1.4.0" libc = {version = "0.2.86", optional = true} memmap = {version = "0.7.0", optional = true} diff --git a/src/main.rs b/src/main.rs index c9b59dc..a664c83 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,13 @@ #[cfg(feature="inspect")] use serde::{Serialize, Deserialize}; +#[cfg(feature="jemalloc")] +use jemallocator::Jemalloc; + +#[cfg(feature="jemalloc")] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + use color_eyre::{ eyre::{ self,