From d01701148b71692164424fe319488be77e52b83a Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sat, 12 Jul 2025 21:22:06 +0200 Subject: [PATCH] fix(rust): remove jemalloc (#9849) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I am no longer able to compile `jemalloc` on my system in a debug build. It fails with the following error: ``` src/malloc_io.c: In function ‘buferror’: src/malloc_io.c:107:16: error: returning ‘char *’ from a function with return type ‘int’ makes integer from pointer without a cast [-Wint-conversion] 107 | return strerror_r(err, buf, buflen); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` This appears to be a problem with modern versions of clang/gcc. I believe this started happening when I recently upgraded my system. The upstream [`jemalloc`](https://github.com/jemalloc/jemalloc) repository is now archived and thus unmaintained. I am not sure if we ever measured a significant benefit in using `jemalloc`. Related: https://github.com/servo/servo/issues/31059 --- rust/Cargo.lock | 22 ---------------------- rust/Cargo.toml | 1 - rust/gateway/Cargo.toml | 1 - rust/gateway/src/main.rs | 4 ---- rust/relay/server/Cargo.toml | 1 - rust/relay/server/src/main.rs | 4 ---- 6 files changed, 33 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 5dd5c062b..3b51c892f 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2381,7 +2381,6 @@ dependencies = [ "futures-bounded", "ip-packet", "ip_network", - "jemallocator", "libc", "moka", "nix 0.30.1", @@ -2550,7 +2549,6 @@ dependencies = [ "futures", "hex", "hex-display", - "jemallocator", "mio", "once_cell", "opentelemetry", @@ -3908,26 +3906,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "jemalloc-sys" -version = "0.5.4+5.3.0-patched" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac6c1946e1cea1788cbfde01c993b52a10e2da07f4bac608228d1bed20bfebf2" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "jemallocator" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0de374a9f8e63150e6f5e8a60cc14c668226d7a347d8aee1a45766e3c4dd3bc" -dependencies = [ - "jemalloc-sys", - "libc", -] - [[package]] name = "jni" version = "0.21.1" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 14d73b61f..53048a097 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -93,7 +93,6 @@ ip-packet = { path = "connlib/ip-packet" } ip_network = { version = "0.4", default-features = false } ip_network_table = { version = "0.2", default-features = false } itertools = "0.14" -jemallocator = "0.5.4" jni = "0.21.1" keyring = "3.6.2" known-folders = "1.2.0" diff --git a/rust/gateway/Cargo.toml b/rust/gateway/Cargo.toml index f2e98ce2a..b0978d344 100644 --- a/rust/gateway/Cargo.toml +++ b/rust/gateway/Cargo.toml @@ -48,7 +48,6 @@ uuid = { workspace = true, features = ["v4"] } [target.'cfg(target_os = "linux")'.dependencies] caps = { workspace = true } dns-lookup = { workspace = true } -jemallocator = { workspace = true } nix = { workspace = true, features = ["user"] } [target.'cfg(target_os = "macos")'.dependencies] diff --git a/rust/gateway/src/main.rs b/rust/gateway/src/main.rs index f20dcf79b..8a4d4b575 100644 --- a/rust/gateway/src/main.rs +++ b/rust/gateway/src/main.rs @@ -1,7 +1,3 @@ -#[cfg(all(target_os = "linux", not(target_arch = "arm")))] -#[global_allocator] -static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; - use crate::eventloop::{Eventloop, PHOENIX_TOPIC}; use anyhow::{Context, Result}; use backoff::ExponentialBackoffBuilder; diff --git a/rust/relay/server/Cargo.toml b/rust/relay/server/Cargo.toml index 914e489cf..d8af1cbef 100644 --- a/rust/relay/server/Cargo.toml +++ b/rust/relay/server/Cargo.toml @@ -53,7 +53,6 @@ uuid = { workspace = true, features = ["v4"] } [target.'cfg(target_os = "linux")'.dependencies] aya = { workspace = true, features = ["tokio"] } aya-log = { workspace = true } -jemallocator = { workspace = true } [target.'cfg(target_os = "linux")'.build-dependencies] anyhow = "1" diff --git a/rust/relay/server/src/main.rs b/rust/relay/server/src/main.rs index 701c64e3f..e3fef4bc0 100644 --- a/rust/relay/server/src/main.rs +++ b/rust/relay/server/src/main.rs @@ -1,9 +1,5 @@ #![cfg_attr(test, allow(clippy::unwrap_used))] -#[cfg(all(target_os = "linux", not(target_arch = "arm")))] -#[global_allocator] -static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; - use anyhow::{Context, Result, bail}; use backoff::ExponentialBackoffBuilder; use clap::Parser;