Repository navigation
Conversation
|
@panagosg7 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D128303865. |
Open
Summary: Release binaries are built with Cargo, which uses the system allocator: glibc malloc on Linux. glibc keeps most of the memory a recheck frees instead of returning it to the OS, so a long-running server's resident memory ratchets up with every large recheck. On a large codebase it settled at about twice what the same code uses with jemalloc, and `malloc_trim(0)` gave the difference back, so the growth is retained free memory, not live data. Install jemalloc as the global allocator in Cargo builds on Linux, with background threads so that memory freed by a recheck goes back to the OS while the server is idle. Buck builds pick their allocator themselves and are unchanged. jemalloc fixes its page size when it is built, so the arm64 release build uses 64 KiB pages, which also work on kernels with 4 or 16 KiB pages. macOS keeps the system allocator, which already returns memory after a recheck. With jemalloc (which has no background threads on macOS) the server settled about 1 GiB higher and peaked about 4 GiB lower, which is not a clear win. Changelog: [fix] Linux release builds use jemalloc, which keeps the memory of long-running servers from growing after large rechecks. Differential Revision: D128303865
meta-codesync
Bot
force-pushed
the
export-D128303865
branch
from
October 30, 2026 01:09
c09aff7 to
ffd95fd
Compare
This branch has not been deployed
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:
Release binaries are built with Cargo, which uses the system allocator: glibc malloc on Linux. glibc keeps most of the memory a recheck frees instead of returning it to the OS, so a long-running server's resident memory ratchets up with every large recheck. On a large codebase it settled at about twice what the same code uses with jemalloc, and
malloc_trim(0)gave the difference back, so the growth is retained free memory, not live data.Install jemalloc as the global allocator in Cargo builds on Linux, with background threads so that memory freed by a recheck goes back to the OS while the server is idle. Buck builds pick their allocator themselves and are unchanged. jemalloc fixes its page size when it is built, so the arm64 release build uses 64 KiB pages, which also work on kernels with 4 or 16 KiB pages.
macOS keeps the system allocator, which already returns memory after a recheck. With jemalloc (which has no background threads on macOS) the server settled about 1 GiB higher and peaked about 4 GiB lower, which is not a clear win.
Changelog: [fix] Linux release builds use jemalloc, which keeps the memory of long-running servers from growing after large rechecks.
Differential Revision: D128303865