From 8d200c26d723e6f1e4a96938d13bdf23489f4dab Mon Sep 17 00:00:00 2001 From: fanyang Date: Sat, 19 Sep 2026 23:44:46 +0800 Subject: [PATCH] perf: tune jemalloc RSS decay for faster memory reclamation (#2428) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current malloc_conf only sets retain:false, which prevents jemalloc from retaining virtual memory but does not actively purge dirty/muzzy pages. On long-running EasyTier nodes this can lead to inflated RSS because freed arena pages are not returned to the OS promptly. This tunes the jemalloc decay parameters: background_thread:true — enables background GC threads so purge happens without blocking allocation hot paths. dirty_decay_ms:1000 / muzzy_decay_ms:1000 — return unused pages to the OS within ~1s instead of holding them indefinitely. --- easytier/src/easytier-core.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easytier/src/easytier-core.rs b/easytier/src/easytier-core.rs index 03cf30b4..ca175f61 100644 --- a/easytier/src/easytier-core.rs +++ b/easytier/src/easytier-core.rs @@ -14,12 +14,12 @@ static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; #[cfg(feature = "jemalloc-prof")] #[allow(non_upper_case_globals)] #[unsafe(export_name = "malloc_conf")] -pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:19,retain:false\0"; +pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:19,dirty_decay_ms:1000,muzzy_decay_ms:1000,retain:false\0"; #[cfg(not(feature = "jemalloc-prof"))] #[allow(non_upper_case_globals)] #[unsafe(export_name = "malloc_conf")] -pub static malloc_conf: &[u8] = b"retain:false\0"; +pub static malloc_conf: &[u8] = b"dirty_decay_ms:1000,muzzy_decay_ms:1000,retain:false\0"; rust_i18n::i18n!("locales", fallback = "en");