Skip to content

Make mimalloc a default Cargo feature - #580

Merged
tinder-maxwellelliott merged 1 commit into
Tinder:masterfrom
tamird:codex/bazel-diff-gnu-system-allocator-20261027
Oct 27, 2026
Merged

tinder-maxwellelliott merged 1 commit into
Tinder:masterfrom
tamird:codex/bazel-diff-gnu-system-allocator-20261027

Conversation

@tamird

@tamird tamird commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GNU/Linux builders currently have to edit main.rs to compare glibc with mimalloc on their own workloads. The static musl benchmark leaves that choice open. The earlier public dependency-dense fixture favored mimalloc. Original allocator benchmarks

Make mimalloc an optional Cargo dependency with a default-enabled feature of the same name. Ordinary Cargo and Bazel builds continue to use mimalloc, including the static musl release. Omitting the feature selects Rust’s system allocator on the target platform.

Cargo users can pass --no-default-features --features vendored-protoc to retain the other default feature. The repository’s Bazel binary reads Cargo’s resolved features and accepts --features=-mimalloc to remove just the allocator feature. A consumer with its own rust_binary declaration can omit mimalloc from that target’s crate_features.

The GNU/Linux default binary’s vector growth calls mi_malloc_aligned. The binary built with --features=-mimalloc calls glibc’s malloc and posix_memalign. The static musl default still links mimalloc.

On arm64 macOS, both settings produced identical hash and edge files from the 26,448,878-byte public fixture. The 192 Rust tests, 21 CLI tests and format check passed with each setting. Fixture and reproduction script

Reproduce the GNU/Linux builds
out=$(mktemp -d)
flags=(-c opt --strip=never --@rules_rust//rust/settings:lto=thin
       --platforms=@rules_rs//rs/platforms:x86_64-unknown-linux-gnu)
bazel build "${flags[@]}" //:bazel-diff
cp bazel-bin/src/bazel-diff "$out/default"
bazel build "${flags[@]}" --features=-mimalloc //:bazel-diff
cp bazel-bin/src/bazel-diff "$out/system"

On a GNU/Linux host, run python3 reproduce.py "$out/default" "$out/system" using the published fixture scripts from #577.

Codex for Tamir.

Allow builders to select the system allocator while keeping mimalloc in
ordinary Cargo and Bazel builds. Derive the Bazel binary features from
the root Cargo package so its defaults stay in sync.

Codex for Tamir.
@tamird
tamird force-pushed the codex/bazel-diff-gnu-system-allocator-20261027 branch from 8770517 to 476e09a Compare October 27, 2026 15:22
@tamird tamird changed the title Allow GNU/Linux builds to select the system allocator Make mimalloc a default Cargo feature Oct 27, 2026
@tinder-maxwellelliott
tinder-maxwellelliott merged commit 2fc6db2 into Tinder:master Oct 27, 2026
21 checks passed
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