From 93aecf25e4c0cc0cf76ed0be3345d7ef7b826fba Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Tue, 23 Jun 2020 16:11:13 +0200 Subject: [PATCH] feat: enable jemalloc as global allocator on musl 64-bit systems references: https://github.com/BurntSushi/ripgrep/blob/master/crates/core/main.rs --- Cargo.lock | 28 ++++++++++++++++++++++++++++ Cargo.toml | 5 ++++- src/main.rs | 4 ++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a74e981..554a696 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,6 +188,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] +name = "fs_extra" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" + +[[package]] name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -332,6 +338,27 @@ dependencies = [ ] [[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 = "language-tags" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -920,6 +947,7 @@ dependencies = [ "iron-cors", "iron-test", "iron_staticfile_middleware", + "jemallocator", "log 0.4.8", "nix", "openssl", diff --git a/Cargo.toml b/Cargo.toml index 44abef3..865e41e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ edition = "2018" include = ["src/**/*", "Cargo.toml", "Cargo.lock"] [dependencies] +jemallocator = "0.3.2" iron = "0.6" log = "0.4" chrono = "0.4" @@ -40,4 +41,6 @@ iron-test = "0.6" tempdir = "0.3" [profile.release] -lto = true +lto = "fat" +codegen-units = 1 +panic = "abort" diff --git a/src/main.rs b/src/main.rs index e4485f0..fcd2e8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ +#[cfg(all(target_env = "musl", target_pointer_width = "64"))] +#[global_allocator] +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; + #[macro_use] extern crate log; -- libgit2 1.7.2