-
Notifications
You must be signed in to change notification settings - Fork 13k
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
We don't need NonNull::as_ptr
debuginfo
#133899
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[EXPERIMENT] We don't need `NonNull::as_ptr` debuginfo Stop pessimizing the use of local variables in core by skipping debug info for MIR temporaries in tiny (single-BB) functions. For functions as simple as this -- `Pin::new`, etc -- nobody every actually wants debuginfo for them in the first place. They're more like intrinsics than real functions, and stepping over them is good. r? ghost
sync @bors r- |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (fe36381): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -2.3%, secondary -3.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -1.3%, secondary -1.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary -1.4%, secondary -0.8%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 768.023s -> 767.749s (-0.04%) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Oh, I'm quite happy with those perf results :) 560,934 bytes off hyper-debug. r? mir |
NonNull::as_ptr
debuginfoNonNull::as_ptr
debuginfo
The (especially binary size) wins look awesome! Just thinking out loud, I wonder if there's a way to evaluate the debugging impact of these changes though? I noticed that in recent Rust versions debugging stepping regressed for me, with stepping over (a line without |
My saying "strip" here might have made it sound like it's doing more than it is. The following are unchanged, and should continue to work exactly as before:
What doesn't work:
For a specific example, my argument is that while it's true that there's a local in rust/library/core/src/ptr/non_null.rs Lines 111 to 117 in c94848c
I don't think anyone's ever cared about that in the debuginfo, since it's a trivial straight-line function (even though we do have six inlined function call scopes in it today). |
I see, thanks for clarifying! That makes sense, I agree that this kind of local variable debuginfo is not very useful. In fact, I think that it would be nice if we had a way to skip generating such information for all libraries that a crate depends on, to improve compile times and reduce binary size of debug builds, as these are relatively rarely needed for actual stepping (as opposed to the user's own code). But that's a separate discussion. |
@@ -16,7 +16,6 @@ | |||
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:20:5: 20:8}>::new) { | |||
+ debug pointer => _3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this one also be gone? Pin::new (after inlining the function call in its body and stripping debug info) is just the same as Pin::new_unchecked, but its debug info seems to stay around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointer
is the parameter to Pin::new
, so it's not removed
Line 1191 in cdeddae
pub const fn new(pointer: Ptr) -> Pin<Ptr> { |
(Rather than if it were a local in the function)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't the same true for the pointer
arg of new_unchecked
?
Ah, if the currently-being-optimized function were in libcore, the arg of new
would also be gone...
Makes sense, but subtle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, definitely subtle. We could be less subtle by just removing all the debuginfo from trivial functions, but I thought it would be worth allowing at least that outer bit so that if you're unsure what you're calling into core with, that first step in having those arguments visible seemed potentially useful.
Basically I'm trying to make as small a change as I can while still avoiding the bad incentive of local variables in core making the compiler slower.
@bors r+ |
Ok, failure was spurious, so back into the queue. |
FWIW i use a debugger on rust binaries somewhat frequently and almost always i’m doing so because one of my dependencies does something i don’t understand or expect. so removing that debuginfo would make my life harder. if you intend this to be the default for |
i think you could solve the problem you’re talking about more directly if gdb/lldb had a command for “never step into functions defined in this crate”. maybe that already exists today, i’m not sure. |
I meant it as the opposite, i.e. by default build all debuginfo, but have an opt-in mechanism to skip debuginfo of dependencies. |
you can already do this today, no?
|
yeah here we go: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Skipping-Over-Functions-and-Files.html |
Ah, I forgot about this, good point!
Yeah, that's useful, I think I used this in the IJ Rust plugin when implementing an option to skip stepping through stdlib sources. Hard to say which functions to mark as being auto skippable though. |
We don't need `NonNull::as_ptr` debuginfo In order to stop pessimizing the use of local variables in core, skip debug info for MIR temporaries in tiny (single-BB) functions. For functions as simple as this -- `Pin::new`, etc -- nobody every actually wants debuginfo for them in the first place. They're more like intrinsics than real functions, and stepping over them is good.
💔 Test failed - checks-actions |
That job just passed in test-with-try above #133899 (comment) so sounds spurious again :/ @bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (dd436ae): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -2.3%, secondary -4.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -1.2%, secondary -2.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary -1.3%, secondary -0.9%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 769.59s -> 770.497s (0.12%) |
More improvements than regressions, and in particular very nice binary size wins. @rustbot label: +perf-regression-triaged |
In order to stop pessimizing the use of local variables in core, skip debug info for MIR temporaries in tiny (single-BB) functions.
For functions as simple as this --
Pin::new
, etc -- nobody every actually wants debuginfo for them in the first place. They're more like intrinsics than real functions, and stepping over them is good.