Skip to content

perf: tune jemalloc RSS decay for faster memory reclamation#2428

Draft
fanyang89 wants to merge 1 commit into
EasyTier:mainfrom
fanyang89:perf/jemalloc-decay
Draft

perf: tune jemalloc RSS decay for faster memory reclamation#2428
fanyang89 wants to merge 1 commit into
EasyTier:mainfrom
fanyang89:perf/jemalloc-decay

Conversation

@fanyang89

Copy link
Copy Markdown
Member

Summary

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.

Changes

  • easytier/src/easytier-core.rs — both jemalloc-prof and non-prof malloc_conf strings 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.

Copilot AI review requested due to automatic review settings July 11, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-prof and non-prof malloc_conf strings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread easytier/src/easytier-core.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

#[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
fanyang89 marked this pull request as draft July 11, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants