perf: tune jemalloc RSS decay for faster memory reclamation#2428
Draft
fanyang89 wants to merge 1 commit into
Draft
perf: tune jemalloc RSS decay for faster memory reclamation#2428fanyang89 wants to merge 1 commit into
fanyang89 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tunes jemalloc runtime configuration to reclaim unused memory pages more aggressively, aiming to reduce long-running node RSS when EasyTier is built with jemalloc.
Changes:
- Enable jemalloc background threads (
background_thread:true) to purge without blocking allocation hot paths. - Set decay windows (
dirty_decay_ms:1000,muzzy_decay_ms:1000) to return freed pages to the OS within ~1s. - Apply the above to both
jemalloc-profand non-profmalloc_confstrings.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fanyang89
force-pushed
the
perf/jemalloc-decay
branch
from
July 11, 2026 13:38
f9fcb73 to
c493821
Compare
| #[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"; |
Comment on lines
+22
to
+23
| pub static malloc_conf: &[u8] = | ||
| b"dirty_decay_ms:1000,muzzy_decay_ms:1000,retain:false\0"; |
Comment on lines
19
to
+23
| #[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"; |
fanyang89
marked this pull request as draft
July 11, 2026 13:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The current
malloc_confonly setsretain: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.Changes
easytier/src/easytier-core.rs— bothjemalloc-profand non-profmalloc_confstrings updated (3 lines).Impact
No code logic changes. Only affects builds using jemalloc (Linux default). Reduces steady-state RSS with a minimal trade-off: pages freed less than 1s ago may need to be re-faulted if reused after purge.