Skip to content

Comments

feat: enable jemalloc for Mooncake Store master by default#1436

Open
acelyc111 wants to merge 2 commits intokvcache-ai:mainfrom
acelyc111:default_je
Open

feat: enable jemalloc for Mooncake Store master by default#1436
acelyc111 wants to merge 2 commits intokvcache-ai:mainfrom
acelyc111:default_je

Conversation

@acelyc111
Copy link
Contributor

@acelyc111 acelyc111 commented Jan 25, 2026

Description

Jemalloc is very important in high load senarios, it would encounter OOM frequently when insert in and remove keys from master unorderedmap.

We can provide Jemalloc version by default to prevent users encounter this issue.

before:
image

after:
image

Type of Change

  • Types
    • Bug fix
    • New feature
      • Transfer Engine
      • Mooncake Store
      • Mooncake EP
      • Integration
      • P2P Store
      • Python Wheel
    • Breaking change
    • CI/CD
    • Documentation update
    • Other

How Has This Been Tested?

Checklist

  • I have performed a self-review of my own code.
  • I have formatted my own code using ./scripts/code_format.sh before submitting.
  • I have updated the documentation.
  • I have added tests to prove my changes are effective.

Copilot AI review requested due to automatic review settings January 25, 2026 14:54
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @acelyc111, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to enhance the stability and performance of the Mooncake Store master by enabling the jemalloc memory allocator by default. This change is crucial for high-load scenarios where frequent object insertions and removals from unordered maps can lead to out-of-memory errors. By making jemalloc the default, the system benefits from more efficient memory allocation, reduced fragmentation, and improved memory return to the operating system, thereby proactively preventing common memory-related issues for users.

Highlights

  • Jemalloc Enabled by Default: The STORE_USE_JEMALLOC CMake option for Mooncake Store master is now set to ON by default, enabling jemalloc for improved memory management.
  • Documentation Updates: The build documentation (English and Chinese versions) has been updated to reflect the new default for STORE_USE_JEMALLOC and to explain its purpose.
  • Code Comments for Clarity: New comments have been added to mooncake-store/src/CMakeLists.txt to explain the benefits of using jemalloc, such as reduced OOM issues, better multi-threaded performance, and less fragmentation with std::unordered_map.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enables jemalloc by default for the Mooncake Store master to improve memory management, especially in high-load scenarios. The changes correctly update the CMake build options and add documentation for the new default setting.

My main feedback is to also update the dependency lists in the build documentation. Since jemalloc is now a default dependency, users following the manual build instructions will need to install it to avoid build failures. I've added comments to the documentation files with this suggestion.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enables jemalloc as the default memory allocator for the Mooncake Store master component to address out-of-memory (OOM) issues in high-load scenarios where frequent insertions and removals occur in the master's unordered_map data structures.

Changes:

  • Changed the default value of STORE_USE_JEMALLOC CMake option from OFF to ON
  • Added comprehensive documentation comments explaining jemalloc's benefits (memory return to OS, multi-threaded performance, fragmentation reduction)
  • Updated build documentation to reflect the new default setting

Reviewed changes

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

File Description
CMakeLists.txt Changed STORE_USE_JEMALLOC default from OFF to ON and added status message
mooncake-store/src/CMakeLists.txt Added detailed comments explaining jemalloc benefits for mooncake_master
docs/source/getting_started/build.md Updated documentation to indicate default is ON
docs/source/zh_archive/build.md Updated Chinese documentation to indicate default is ON

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

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

pybind11-dev \
libcurl4-openssl-dev \
libhiredis-dev \
libjemalloc-dev \
Copy link
Collaborator

Choose a reason for hiding this comment

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

For building the whole project, I think libjemalloc-dev should be an optional dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can install the dependencies when prepare the build environment, whether to enable the option depends on the user. Pre-install the dependency could mute the complains like 'why it needs another dependency when I enable the compile option'?

@stmatengss
Copy link
Collaborator

LGTM

@stmatengss
Copy link
Collaborator

@ykwd What's your opinion?

@acelyc111
Copy link
Contributor Author

@ykwd PTAL, thanks!

@stmatengss
Copy link
Collaborator

Only one concern: Jemalloc should be a general package available across Linux distributions. It's currently unavailable through package managers like Suse's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants