Use jemalloc as global allocator on unix#2252
Open
briangmilnes wants to merge 1 commit into
Open
Conversation
On Linux, switching from glibc malloc to jemalloc saves avg 12%, peak 14% RSS and avg 9%, peak 14% wall time across 6 open-source Verus projects, with zero code changes. macOS is not yet benchmarked. jemalloc is not available on Windows. The `unprefixed_malloc_on_supported_platforms` feature is required so that jemalloc replaces C-level malloc/free globally, not just Rust's allocator. Without it, librustc_driver.so (which uses C malloc via LLVM) fights with jemalloc over the heap, causing corruption during vstd build. Benchmarks and analysis: https://github.com/briangmilnes/verus-heaptrack Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Double checked the build and the benchmarks looking for any crashes, and it's clean. |
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
and avg 9%, peak 14% wall time across 6 open-source Verus projects, with zero
code changes
cfg(unix)gated — no effect on Windows buildsunprefixed_malloc_on_supported_platformsfeature ensures jemalloc replacesC-level malloc/free globally, not just Rust's allocator (required because
librustc_driver.so uses C malloc via LLVM)
Benchmark results
macOS is not yet benchmarked. jemalloc is not available on Windows.
Full analysis: https://github.com/briangmilnes/verus-heaptrack
Test plan
vargo build --releasesucceeds, vstd rebuilds clean (1490 verified)vargo test --package rust_verify_test— 3928 passed, 0 failed