fix(build): production flamegraphs are useless#6764
Merged
Conversation
Contributor
Author
|
Requesting review from @abhigets and @bayandin mostly to raise awareness. @jcsp might be generally interested in this, and @koivunej and @conradludgate are probably the best to judge whether my solution follows best practices with Cargo. |
e880432 to
aca8877
Compare
Contributor
|
I have no thoughts or concerns about the flags here |
2436 tests run: 2318 passed, 0 failed, 118 skipped (full report)Code coverage (full report)
The comment gets automatically updated with the latest test results
aca8877 at 2024-02-14T18:13:22.591Z :recycle: |
bayandin
reviewed
Feb 14, 2024
koivunej
approved these changes
Feb 15, 2024
Contributor
koivunej
left a comment
There was a problem hiding this comment.
If android is using this, it should be safe for us as well. This is what I've been using locally, never tried to produce flamegraphs with production binaries.
bayandin
approved these changes
Feb 16, 2024
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.
Problem
Running a flamegraph on a pageserver build today yields a flamegraph with sort-of flattened stacks:
Analysis
We use
moldto link the production binaries.It seems that, similar to when using
lld, it's necessary to set--no-rosegment, as is also recommended by theflamegraph-rstools.Setting it fixes the issue on my workstation.
I don't use
mold -runthere, but instead usemoldby setting defaultrustflagsin my~/.cargo/config.toml:Solution For Production Binaries
Our production binaries are the ones built inside docker, see
./Dockerfile.It would be nice if we could just make the setting once, somewhere inside
$checkout/Cargo.tomlor$checkout/.cargo/config.toml.That way, all developers, _and the artifact builds, would automatically get the correct flags.
Sadly, the various ways to configure the rust compiler flags in cargo don't compose well.
I.e., there's a strict priority order and one replaces the other.
So, this PR sets the right rust compiler flags through the
RUSTFLAGSenv var, which is otherwise unset in the Dockerfile, so, we don't have to worry about losing any flag overrides.This PR also augments the README with a hint on how to get proper flamegraphs on developer builds.