Repository navigation
[ISSUE #12657]✨Build the release Broker with profile-guided optimization - #12658
Merged
Merged
Conversation
Collaborator
|
🔊@mxsm 🚀Thanks for your contribution🎉! |
This was referenced Nov 15, 2026
Closed
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.
Which Issue(s) This PR Fixes(Closes)
Brief Description
The release service images now ship a Broker built with profile-guided optimization (PGO).
docker/Dockerfile.basebuilder-baseinstalls the rustupllvm-toolscomponent, which providesllvm-profdatafor the pinned toolchain.service-buildergets a build argumentROCKETMQ_BROKER_PGO(defaulttrue). Withtrue, the Broker is built three times over: an instrumented build with the release features, a training run on loopback, and the release build with the merged profile. Both Broker builds use their own target directory because theirRUSTFLAGSdiffer.falsekeeps the previous plain build for faster local images. NameServer, Controller and Proxy are unchanged.scripts/pgo-train-broker.shstarts a NameServer and the instrumented Broker on loopback and drives theclient-production-benchmarkexample: 20,000 synchronous sends, 200,000 asynchronous sends with 256 in flight, 200,000 LitePull messages, 100,000 asynchronous sends with 16 in flight, and four concurrent sessions of 50,000 sends. It stops the Broker with SIGTERM so the profile is written, fails the build when a step fails or no profile appears, and keeps client and server output in log files that it prints on failure. Training takes about 25 seconds. The profile is generated in the build, never committed, so it always matches the code.Cargo.lock:cc1.4.6 to 1.11.2 (andfind-msvc-tools0.1.12 to 0.1.15).cc1.4.6 forwards-Cprofile-generateand-Cprofile-useto clang, so the builder image's clang 14 instrumented the C dependencies against an older profiling runtime than rustc's, and the instrumented Broker crashed at startup (even--helpexited with SIGSEGV; the same build with gcc did not).cc1.10 and later no longer forward these flags (cc-rs issue 1986).scripts/README.mddescribe the build argument and the training script.Measured gain (Linux Docker, 16 CPUs, Rust benchmark client, 1 KiB messages, Broker built with the release features
otlp-metrics,otlp-traces,otlp-logs,tls,allocator-mimalloc, PGO against the same features without PGO, interleaved pairs, pairs with either side below 85% of the batch median throughput dropped, 0 failures):The Broker copied out of the
brokerimage built from thisDockerfile.base(clang for the C dependencies), against the same plain build (built with gcc in the benchmark container), 3 interleaved pairs each, 0 failures: async with 16 workers -26.1% cycles (3 of 3 lower), -21.9% instructions, +19.7% throughput; sync -29.6% cycles (3 of 3), -18.0% instructions, +16.4% throughput.Build cost: in the
service-builderstage on that machine, the instrumented Broker took 7 min 52 s, the benchmark client 3 min 22 s, training 24 s and the PGO Broker 11 min 55 s; the whole stage took 40 min. The image publish workflow allows 240 minutes.How Did You Test This Change?
docker buildx build --file docker/Dockerfile.base --target service-builderand--target brokeratHEAD: built, trained (one raw profile, merged without warnings) and installed the PGO Broker. Before theccupgrade the same build failed at the training step with the SIGSEGV described above.bash -n scripts/pgo-train-broker.sh; the training script was also run on its own against an instrumented Broker.cargo check -p rocketmq-broker --features allocator-mimallocwith the upgradedcc.npm run buildinrocketmq-website: both locales generated.🤖 Generated with Claude Code