-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more tracing instrumentation #89048
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
r=me with CI green r? @jackh726 |
@bors r=jackh726 |
📌 Commit 731d7797b90a37da2a02c9e9d58b17904bd272d6 has been approved by |
☔ The latest upstream changes (presumably #88980) made this pull request unmergeable. Please resolve the merge conflicts. |
731d779
to
a1b308d
Compare
@bors r=jackh726 rollup |
📌 Commit a1b308d12a93a19d46579cc7603279da93e26c58 has been approved by |
This comment has been minimized.
This comment has been minimized.
@bors r- |
804c1ac
to
1443de7
Compare
@bors r=jackh726 rollup |
📌 Commit 1443de7 has been approved by |
…h726 Add more tracing instrumentation I changed or added all this while working on a branch and pulled it out so we can merge it on its own.
☔ The latest upstream changes (presumably #89024) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors p=1 This is prone to bitrot. |
@bors rollup=never Same reason |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
1443de7
to
9b5aa06
Compare
@bors r=jackh726 |
📌 Commit 9b5aa06 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (8f8092c): comparison url. Summary: This change led to very large relevant mixed results 🤷 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
Uhhhh... why does instrumentation affect release builds?? I'll go through all attributes in this PR and check them again |
Ok found it. The instrument attribute will still generate a wrapper function, even if the level is statically rejected. LLVM will then not optimize this as well. I will open a PR to tracing. |
…o anything (#1600) ## Motivation Adding `#[instrument(level = "debug")]` attributes to functions in rustc caused a performance regression (in release, where `debug!` is fully optimized out) across all crates: rust-lang/rust#89048 (comment) While trying to debug this, I noticed that spans don't have the same advantage that events have wrt to how LLVM sees them. Spans (or more precisely, the enter-guard), will get dropped at the end of the scope, which throws a spanner into the LLVM optimization pipeline. I am not entirely sure where the problem is, but I am moderately certain that the issue is that even entering a dummy span is too much code for LLVM to reliably (or at all) optimize out. ## Solution My hope is that in trusting the Rust compiler to generate cool code when using drop flags, we can essentially generate a drop flag that depends on something we know (due to events working as expected) to be optimizable. So instead of doing ```rust let _x = span!(); let _y = _x.enter(); // lotsa code drop(_y) ``` we do ```rust let _x; let _y; let must_drop = false; if level_enabled!(DEBUG) { must_drop = true; _x = span!(); _y = _x.enter(); } // lotsa code if must_drop { drop(_y) } ``` I believe this will allow LLVM to properly optimize this again. Testing that right now, but I wanted to open this PR immediately for review.
…o anything (#1600) (#1605) ## Motivation Adding `#[instrument(level = "debug")]` attributes to functions in rustc caused a performance regression (in release, where `debug!` is fully optimized out) across all crates: rust-lang/rust#89048 (comment) While trying to debug this, I noticed that spans don't have the same advantage that events have wrt to how LLVM sees them. Spans (or more precisely, the enter-guard), will get dropped at the end of the scope, which throws a spanner into the LLVM optimization pipeline. I am not entirely sure where the problem is, but I am moderately certain that the issue is that even entering a dummy span is too much code for LLVM to reliably (or at all) optimize out. ## Solution My hope is that in trusting the Rust compiler to generate cool code when using drop flags, we can essentially generate a drop flag that depends on something we know (due to events working as expected) to be optimizable. So instead of doing ```rust let _x = span!(); let _y = _x.enter(); // lotsa code drop(_y) ``` we do ```rust let _x; let _y; let must_drop = false; if level_enabled!(DEBUG) { must_drop = true; _x = span!(); _y = _x.enter(); } // lotsa code if must_drop { drop(_y) } ``` I believe this will allow LLVM to properly optimize this again. Testing that right now, but I wanted to open this PR immediately for review.
…imulacrum Fix performance regression with #[instrument] linked tracing PR: tokio-rs/tracing#1600 regression introduced by rust-lang#89048
I changed or added all this while working on a branch and pulled it out so we can merge it on its own.