-
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
Lazify SourceFile::lines
.
#97575
Lazify SourceFile::lines
.
#97575
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit ffd9172b548b8b831bcee64a05127b7fbadd7c17 with merge 0ca780e66ec23e02858753c0c8f112e63e3718ef... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
Queued 0ca780e66ec23e02858753c0c8f112e63e3718ef with parent 47365c0, future comparison URL. |
Finished benchmarking commit (0ca780e66ec23e02858753c0c8f112e63e3718ef): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking 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 Footnotes |
I was able to run |
The CI also checks |
ffd9172
to
54a8a87
Compare
I have addressed the review comments and changed the |
54a8a87
to
5175a71
Compare
`SourceFile::lines` is a big part of metadata. It's stored in a compressed form (a difference list) to save disk space. Decoding it is a big fraction of compile time for very small crates/programs. This commit introduces a new type `SourceFileLines` which has a `Lines` form and a `Diffs` form. The latter is used when the metadata is first read, and it is only decoded into the `Lines` form when line data is actually needed. This avoids the decoding cost for many files, especially in `std`. It's a performance win of up to 15% for tiny crates/programs where metadata decoding is a high part of compilation costs. A `Lock` is needed because the methods that access lines data (which can trigger decoding) take `&self` rather than `&mut self`. To allow for this, `SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather than returning the lines slice.
5175a71
to
0b81d7c
Compare
I have addressed the latest review comments. |
@bors r+ |
📌 Commit 72de7c4 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (e714405): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
…r=Mark-Simulacrum Lazify `SourceFile::lines`. `SourceFile::lines` is a big part of metadata. It's stored in a compressed form (a difference list) to save disk space. Decoding it is a big fraction of compile time for very small crates/programs. This commit introduces a new type `SourceFileLines` which has a `Lines` form and a `Diffs` form. The latter is used when the metadata is first read, and it is only decoded into the `Lines` form when line data is actually needed. This avoids the decoding cost for many files, especially in `std`. It's a performance win of up to 15% for tiny crates/programs where metadata decoding is a high part of compilation costs. A `RefCell` is needed because the methods that access lines data (which can trigger decoding) take `&self` rather than `&mut self`. To allow for this, `SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather than returning the lines slice. r? `@Mark-Simulacrum`
SourceFile::lines
is a big part of metadata. It's stored in a compressed form(a difference list) to save disk space. Decoding it is a big fraction of
compile time for very small crates/programs.
This commit introduces a new type
SourceFileLines
which has aLines
form and a
Diffs
form. The latter is used when the metadata is firstread, and it is only decoded into the
Lines
form when line data isactually needed. This avoids the decoding cost for many files,
especially in
std
. It's a performance win of up to 15% for tinycrates/programs where metadata decoding is a high part of compilation
costs.
A
RefCell
is needed because the methods that access lines data (which cantrigger decoding) take
&self
rather than&mut self
. To allow for this,SourceFile::lines
now takes aFnMut
that operates on the lines slice ratherthan returning the lines slice.
r? @Mark-Simulacrum