-
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
[PERF Experiment] Only create the self-profile infra if the profiler is actually enabled (only if -Z self-profile
)
#120465
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Here are the results in my independent server (with multithreading): Let's check on the official infrastructure (^..^)ノ @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[PERF Experiment] Only create the self-profile infra if the profiler is actually enabled (only if `-Z self-profile`) Previously, we would use the [`Session::time`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/struct.Session.html#method.time) and this would just call `verbose_generic_activity(...)`, which would create an activity and all that... But all this effort would go unnoticed if the user didn't use the `-Z self-profile` feature. So, this PR checks for the profiler before trying to profile. From my benchmarks on a server, this should be a great performance improvement (Note: I tested this with a 12-thread custom multithreaded rustc-perf clone to mimick a compiler that a user might use, the results may change by using the single-threaded rustc-perf that bors currently uses)
This comment has been minimized.
This comment has been minimized.
I... I forgot tidy @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[PERF Experiment] Only create the self-profile infra if the profiler is actually enabled (only if `-Z self-profile`) Previously, we would use the [`Session::time`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/struct.Session.html#method.time) and this would just call `verbose_generic_activity(...)`, which would create an activity and all that... But all this effort would go unnoticed if the user didn't use the `-Z self-profile` feature. So, this PR checks for the profiler before trying to profile. From my benchmarks on a server, this should be a great performance improvement (Note: I tested this with a 12-thread custom multithreaded rustc-perf clone to mimick a compiler that a user might use, the results may change by using the single-threaded rustc-perf that bors currently uses)
I think that |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (90adef6): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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 sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 660.078s -> 660.948s (0.13%) |
I'm not sure if it's the case here, but note in general that local benchmarks can be quite misleading, since the configuration on the server is quite different from the default
These are instruction count or wall-time results? |
r? @Kobzol |
Those results are instruction counts, I'll re-benchmark with these new configuration options. It seems really weird to me that no changes are perceptible. -6% instead of -9%? That would be reasonable, but a difference no greater than 0.2%? That's very fishy |
It can be a bit tricky to get stable perf. results locally, especially if incremental is enabled. I would be surprised if this change could have such a large effect. You could try running cachegrind locally to see if there's any large difference in instructions. |
I've verified results with those optimizations, still some good results (General: ❌,✅ [ -9.08%, +7.10%] -2.45% 129 (38)) this should work 🤔 I'll try with cachegrind and schedule a benchmark for both Master and this branch on a local Raspberry Pi (ARM architecture, this would eliminate any load that the server I was using may have had, + it will reveal results for the ARM architecture) |
I ran cachegrind locally and there is almost no or only a very small difference in instruction counts. Tbh, I don't think that this help should help much, there's not that many profiling calls in the compiler, and this only saves a few instructions per profiling call (if the profiler is disabled, it basically just does a few no-op operations on Note that this function does more than just record Btw, if you're using a custom version of |
Okis, it's callibrated and the two results in the control benchmarks are the same (except for when I accidentally entered the SSH after a few failed passwords, that made a +0.40% change on a single benchmark), but as you said, it isn't a big change, so we can't expect a big improvement. I'll learn to use cachegrind, and if I don't see any performance improvement, I'll just let this patch go and focus on the next thing. Although maybe the infra server uses |
It should only use |
Previously, we would use the
Session::time
and this would just callverbose_generic_activity(...)
, which would create an activity and all that... But all this effort would go unnoticed if the user didn't use the-Z self-profile
feature.So, this PR checks for the profiler before trying to profile. From my benchmarks on a server, this should be a great performance improvement (Note: I tested this with a 12-thread custom multithreaded rustc-perf clone to mimick a compiler that a user might use, the results may change by using the single-threaded rustc-perf that bors currently uses)