From e17ec20bcd89150581027394111b36ce247ab4c4 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 19 May 2026 17:01:10 +0100 Subject: [PATCH] Fixup --- Cargo.lock | 5 +++-- rust/Cargo.toml | 1 + rust/src/lib.rs | 22 ++++++++++++---------- synapse/metrics/jemalloc.py | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d56fc1ec3..a0a6cd4bde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -689,9 +689,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.174" +version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libm" @@ -1330,6 +1330,7 @@ dependencies = [ "icu_segmenter", "itertools", "lazy_static", + "libc", "log", "mime", "once_cell", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 5d1609e677..608f7a688f 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -69,6 +69,7 @@ tikv-jemallocator = { version = "0.6.1", features = [ tikv-jemalloc-sys = { version = "0.6.1", features = [ "disable_initial_exec_tls", ] } +libc = "0.2.186" [build-dependencies] blake2 = "0.10.4" diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 1fe4496317..f5c562bcf4 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -20,6 +20,8 @@ pub mod rendezvous; pub mod room_versions; pub mod segmenter; +use libc::{c_char, c_int, c_void, size_t}; + #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; @@ -92,32 +94,32 @@ impl UnwrapInfallible for Result { } #[no_mangle] -pub unsafe extern "C" fn malloc(size: usize) -> *mut std::ffi::c_void { +pub unsafe extern "C" fn malloc(size: size_t) -> *mut c_void { tikv_jemalloc_sys::malloc(size) } #[no_mangle] -pub unsafe extern "C" fn calloc(number: usize, size: usize) -> *mut std::ffi::c_void { +pub unsafe extern "C" fn calloc(number: size_t, size: size_t) -> *mut c_void { tikv_jemalloc_sys::calloc(number, size) } #[no_mangle] -pub unsafe extern "C" fn realloc(ptr: *mut std::ffi::c_void, size: usize) -> *mut std::ffi::c_void { +pub unsafe extern "C" fn realloc(ptr: *mut c_void, size: size_t) -> *mut c_void { tikv_jemalloc_sys::realloc(ptr, size) } #[no_mangle] -pub unsafe extern "C" fn free(ptr: *mut std::ffi::c_void) { +pub unsafe extern "C" fn free(ptr: *mut c_void) { tikv_jemalloc_sys::free(ptr) } #[no_mangle] pub unsafe extern "C" fn mallctl( - name: *const std::ffi::c_char, - oldp: *mut std::ffi::c_void, - oldlenp: *mut usize, - newp: *mut std::ffi::c_void, - newlen: usize, -) -> i32 { + name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, +) -> c_int { tikv_jemalloc_sys::mallctl(name, oldp, oldlenp, newp, newlen) } diff --git a/synapse/metrics/jemalloc.py b/synapse/metrics/jemalloc.py index 03cecec3ca..ef0b4905a8 100644 --- a/synapse/metrics/jemalloc.py +++ b/synapse/metrics/jemalloc.py @@ -161,7 +161,7 @@ def _setup_jemalloc_stats() -> None: # We're looking for a path at the end of the line that includes # "libjemalloc". - regex = re.compile(r"/\S+/libjemalloc.*$") + regex = re.compile(r"/\S+/synapse_rust\.abi3\.so$") jemalloc_path = None with open("/proc/self/maps") as f: