From c8fbb004de402a8df09284696d22486403ccd87d Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 19 May 2026 15:34:40 +0100 Subject: [PATCH] Use jemalloc --- Cargo.lock | 31 +++++++------------------------ rust/Cargo.toml | 6 ++++-- rust/src/lib.rs | 4 ++++ 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92f06acb11..54fa711e1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,12 +80,6 @@ dependencies = [ "shlex", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.1" @@ -295,7 +289,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ - "cfg-if 1.0.1", + "cfg-if", "js-sys", "libc", "wasi 0.11.1+wasi-snapshot-preview1", @@ -308,7 +302,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ - "cfg-if 1.0.1", + "cfg-if", "js-sys", "libc", "r-efi", @@ -1063,7 +1057,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", - "cfg-if 1.0.1", + "cfg-if", "getrandom 0.2.16", "libc", "untrusted", @@ -1243,7 +1237,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "cfg-if 1.0.1", + "cfg-if", "cpufeatures", "digest", ] @@ -1254,7 +1248,7 @@ version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ - "cfg-if 1.0.1", + "cfg-if", "cpufeatures", "digest", ] @@ -1349,7 +1343,6 @@ dependencies = [ "serde_json", "sha2", "tikv-jemallocator", - "tikv-jemallocator-global", "tokio", "ulid", ] @@ -1420,16 +1413,6 @@ dependencies = [ "tikv-jemalloc-sys", ] -[[package]] -name = "tikv-jemallocator-global" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51508a8b70f3a9778a8c2350d66e5fc1803b65893994db4ef633ae012d9f485" -dependencies = [ - "cfg-if 0.1.10", - "tikv-jemallocator", -] - [[package]] name = "tinystr" version = "0.8.1" @@ -1643,7 +1626,7 @@ version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ - "cfg-if 1.0.1", + "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", @@ -1669,7 +1652,7 @@ version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ - "cfg-if 1.0.1", + "cfg-if", "js-sys", "once_cell", "wasm-bindgen", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index ade1717dd5..9608ed0de6 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -63,8 +63,10 @@ futures = "0.3.31" tokio = { version = "1.44.2", features = ["rt", "rt-multi-thread"] } once_cell = "1.18.0" itertools = "0.14.0" -tikv-jemallocator = { version = "0.6.1", features = ["disable_initial_exec_tls", "unprefixed_malloc_on_supported_platforms"] } -tikv-jemallocator-global = "0.6.0" +tikv-jemallocator = { version = "0.6.1", features = [ + "disable_initial_exec_tls", + "unprefixed_malloc_on_supported_platforms", +] } [build-dependencies] blake2 = "0.10.4" diff --git a/rust/src/lib.rs b/rust/src/lib.rs index cc89862e4e..bac2499fe9 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -3,6 +3,7 @@ use std::convert::Infallible; use lazy_static::lazy_static; use pyo3::prelude::*; use pyo3_log::ResetHandle; +use tikv_jemallocator::Jemalloc; pub mod acl; pub mod canonical_json; @@ -19,6 +20,9 @@ pub mod rendezvous; pub mod room_versions; pub mod segmenter; +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + lazy_static! { static ref LOGGING_HANDLE: ResetHandle = pyo3_log::init(); }