Conversation
|
Not expecting any big wins there, but let's check: @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Optimize dependency file search
This comment has been minimized.
This comment has been minimized.
|
Unfortunately I am unable to test because of #153077, I am unable to get rustc to build. |
|
Finished benchmarking commit (71d4456): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 480.132s -> 480.258s (0.03%) |
|
OK, got some data: With this PR: Without: The tests are super noisy, though (I get significantly different results between runs). But it seems like a pretty good win. |
I tried to look into the slowdown reported in rust-lang/cargo#16665.
I created a Rust hello world program, and used this Python script to create a directory containing 200k files:
Then I tried to do various small microoptimalizations and simplifications to the code that iterates the search directories. Each individual commit improved performance, with the third one having the biggest effect.
Here are the results on
mainvs the last commit with the stage1 compiler on Linux, usinghyperfine "rustc +stage1 src/main.rs -L deps" -r 30(there's IO involved, so it's good to let it run for a while):Would be cool if someone could try this on macOS (maybe @ehuss - not sure if you have macOS or you only commented about its behavior on the Cargo issue :) ).
I also tried to prefilter the paths (not in this PR); right now we load everything and then we filter files with given prefixes, that's wasteful. Filtering just files starting with
libwould get us down to ~150ms here. (The baseline without-Lis ~80ms on my PC). The rest of the 70ms is essentially allocations from iterating the directory entries and sorting. That would be very hard to change - iterating the directory entries (de)allocates a lot of intermediate paths :( We'd have to implement the iteration by hand with either arena allocation, or at least some better management of memory.r? @nnethercote