From e5dc8f0d4132fda2c3e194aa7071204e2717f95b Mon Sep 17 00:00:00 2001 From: nullchinchilla Date: Mon, 1 Apr 2024 14:37:05 -0400 Subject: [PATCH] Add tikv-jemallocator as non-MSVC dependency and configure as global allocator in geph5-exit --- Cargo.lock | 21 +++++++++++++++++++++ binaries/geph5-exit/Cargo.toml | 3 +++ binaries/geph5-exit/src/main.rs | 7 +++++++ 3 files changed, 31 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index c89afb7..fa88b9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1741,6 +1741,7 @@ dependencies = [ "tachyonix", "tap", "thiserror", + "tikv-jemallocator", "tracing", "tracing-subscriber", "x25519-dalek", @@ -4251,6 +4252,26 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.34" diff --git a/binaries/geph5-exit/Cargo.toml b/binaries/geph5-exit/Cargo.toml index 75a30c7..2dad139 100644 --- a/binaries/geph5-exit/Cargo.toml +++ b/binaries/geph5-exit/Cargo.toml @@ -42,3 +42,6 @@ tachyonix = "0.2.1" mizaru2={path="../../libraries/mizaru2"} governor = "0.6.3" quanta = "0.12.2" + +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = "0.5" diff --git a/binaries/geph5-exit/src/main.rs b/binaries/geph5-exit/src/main.rs index b73b80a..3165d3f 100644 --- a/binaries/geph5-exit/src/main.rs +++ b/binaries/geph5-exit/src/main.rs @@ -13,6 +13,13 @@ mod listen; mod proxy; mod ratelimit; +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + /// The global config file. static CONFIG_FILE: OnceCell = OnceCell::new();