diff --git a/Cargo.lock b/Cargo.lock index 2bced061..746cf32d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,6 +171,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 = "futures-channel" version = "0.3.19" @@ -365,6 +371,27 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +[[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 = "js-sys" version = "0.3.58" @@ -547,6 +574,7 @@ dependencies = [ "exitcode", "hmac", "hyper", + "jemallocator", "log", "md-5", "num_cpus", diff --git a/Cargo.toml b/Cargo.toml index 48ba966d..8284d2df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,3 +34,6 @@ rustls-pemfile = "1" hyper = { version = "0.14", features = ["full"] } phf = { version = "0.11.1", features = ["macros"] } exitcode = "1.1.2" + +[target.'cfg(not(target_env = "msvc"))'.dependencies] +jemallocator = "0.3.2" diff --git a/src/main.rs b/src/main.rs index 467527c9..75aab69b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,6 +37,13 @@ extern crate tokio; extern crate tokio_rustls; extern crate toml; +#[cfg(not(target_env = "msvc"))] +use jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + use log::{error, info, warn}; use parking_lot::Mutex; use pgcat::format_duration;