-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix performance regression in debuginfo file_metadata. #70803
Conversation
Finding the `SourceFile` associated with a `FileName` called `get_source_file` on the `SourceMap`, which does a linear search through all files in the `SourceMap`. This resolves the issue by passing the SourceFile in from the caller (which already had it available).
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @eddyb Should we do a perf run to see if this fully resolves the regression? It seemed to resolve it in a few benchmarks I ran locally. |
|
||
let source_file = cx.sess().source_map().get_source_file(file_name); |
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.
Ahh, I missed this during review! This is indeed unnecessarily slow.
file_name: &FileName, | ||
source_file: &SourceFile, |
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.
Heh, I think I did this (plus removing defining_crate
and relying on the more accurate source_file.is_imported()
) in one of my PRs that has been sitting around.
Let's land it and see the results there, to reduce the time @bors r+ rollup=never p=10 |
📌 Commit 4cdceda has been approved by |
☀️ Test successful - checks-azure |
@arlosi: This change fixes most of the regressions, thanks. But I notice that the "clap-rs-debug patched incremental: println" benchmark regression is only partly fixed. Any ideas what happened there? |
@nnethercote this PR has fixed the regression: https://perf.rust-lang.org/compare.html?start=9e55101bb681010c82c3c827305e2665fc8f2aa0&end=607b8582362be8e26df7acc12fa242359d7edf95&stat=instructions:u |
@mati865: is that the right perf link? Those perf results look like not much changed. |
@nnethercote it's difference starting right before original PR and after this fix proving there is no big preformance hit. |
I see now that this caused a large regression in memory usage @arlosi: was that expected? Any thoughts on how it could be improved? |
@nnethercote It appears that the change that caused the CPU regression, also caused an rss improvement. And that fixing the CPU regression removed the rss improvement. The original change that contained the CPU regression went in on 2020-04-03, and the fix went in on 2020-04-05. Looking at the graph for cargo-debug max-rss over that time period shows an improvement in memory usage, then a matching regression: Here's the run that introduced the CPU regression (and rss improvement): The key difference that caused the CPU regression was adding this line: |
Fixes performance regression caused by #69718.
Finding the
SourceFile
associated with aFileName
calledget_source_file
on theSourceMap
, which does a linear search through all files in theSourceMap
.This resolves the issue by passing the
SourceFile
in from the caller (which already had it available) instead of theFileName
Fixes #70785.