Skip to content

[ISSUE #12220]✨Build release binaries with whole-program LTO and offer mimalloc for server images - #12221

Merged
mxsm merged 1 commit into
mainfrom
perf-12220
Nov 5, 2026
Merged

mxsm merged 1 commit into
mainfrom
perf-12220

Conversation

@mxsm

@mxsm mxsm commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Which Issue(s) This PR Fixes(Closes)

Brief Description

Two build-level changes for the server binaries:

  • Root Cargo.toml gains [profile.release] with lto = "fat" and codegen-units = 1, so per-message code that crosses the protocol, transport, broker, and store crates can be inlined across crates. CI does not run release builds; only local release builds and image builds take longer.
  • rocketmq-broker, rocketmq-namesrv, rocketmq-controller, and rocketmq-proxy get an optional allocator-mimalloc feature backed by a new workspace dependency mimalloc = "0.1.52". With the feature on, each binary entrypoint declares mimalloc::MiMalloc as its #[global_allocator]. The feature is not a default, so default builds and library users keep the system allocator.
  • distribution/config/production-feature-profile.json and the four matching docker/Dockerfile.base build commands enable allocator-mimalloc, so production images use it; resolved_features stays sorted as the release-state guard requires.
  • Cargo.lock adds mimalloc and libmimalloc-sys. Adding the dependency made Cargo re-resolve, which moved six Windows-only windows-sys edges to the 0.61.2 already in the lockfile; no other package was added or removed. Standalone lockfiles do not change because the feature is not enabled there.

Release-build microbenchmark of the protocol hot paths on an 8-core x86_64 host (single thread, rocketmq-protocol and rocketmq-model):

Path Default Fat LTO + 1 codegen unit mimalloc Both
SendMessage header encode, map path 2106 ns 1819 ns 1849 ns 1799 ns
SendMessage response with region/trace fields 1210 ns 1060 ns 1042 ns 940 ns
Parse 8 message properties 883 ns 833 ns 605 ns 547 ns
Encode 8 message properties 154 ns 158 ns 73 ns 68 ns
Decode one 1 KiB message in a 32-message batch 1422 ns 1370 ns 1161 ns 1125 ns

How Did You Test This Change?

  • cargo check -p <package> --bins --features allocator-mimalloc for rocketmq-broker, rocketmq-namesrv, rocketmq-controller, and rocketmq-proxy: passed.
  • cargo build --release -p rocketmq-broker --features allocator-mimalloc --bin rocketmq-broker-rust with the new profile: succeeded in 9 min 29 s on 16 threads, and the binary starts (--help).
  • python -B -m unittest scripts/tests/test_p3_production_release_state.py: 6 of 7 passed, including test_production_features_are_explicit_and_resolve_exactly. test_validate_only_accepts_complete_state_and_rejects_secret_material fails identically on main on this Windows host (subprocess output decoding), so it is unrelated.
  • cargo fmt check for the four packages: passed.
  • Tests ran on Windows. The Linux CI run and an image build were not waited for.

🤖 Generated with Claude Code

@mxsm
mxsm merged commit 2ecca35 into main Nov 5, 2026
24 checks passed
@rocketmq-rust-bot

Copy link
Copy Markdown
Collaborator

🔊@mxsm 🚀Thanks for your contribution🎉!

@rocketmq-rust-bot rocketmq-rust-bot added auto merge ready to review waiting-review waiting review this PR approved PR has approved and removed ready to review waiting-review waiting review this PR labels Nov 5, 2026
@mxsm
mxsm deleted the perf-12220 branch November 7, 2026 12:44
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.

[Enhancement✨] Build release binaries with whole-program LTO and offer mimalloc for server images

3 participants