-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
lookup exported symbols only when needed. #48219
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
half the time was only for an empty file due to I measured wrong (had --crate-type lib for a file with only an main function ) but hay big win for #43300 :) for other files the translation time go down 10ms so 3-4% |
Could you make the Otherwise I feel pretty good about this! |
@Mark-Simulacrum shall I split it up in two optional variables then one for local create and other? or shall I only have one if with lto or not? And what shall I do in lto.rs when there is none in the variable? is it possible to move this to the use in lto.rs my feeling was that it was not wanted/possible. will try to fix this after work today |
One field for the whole list is fine. In |
src/librustc_trans/back/write.rs
Outdated
for &cnum in tcx.crates().iter() { | ||
exported_symbols.insert(cnum, tcx.exported_symbols(cnum)); | ||
} | ||
} | ||
} |
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.
Could you turn this whole block into a match tcx.sess.lto() { ... }
instead of two nested if
s? It's a bit more verbose but it makes it easier to read.
Great find, btw! |
I'm not sure this PR was a good idea. also I'm to bad at rust to understand how to update the code in lto.rs if I change to a Arc<Option> when I try to get the value with the Option::expect() I get a compile error and I do not understand how to solve it. |
This should have no effect on linking time, though perhaps that incorporates parts of Rust code too. I'm not sure. I don't see why this would be a net loss. With regards to the option, you probably want something like |
have already tried with as_ref and get the same error :( |
got it to compile now have no idea why :) |
43cc330
to
e15edf9
Compare
Ah, the |
It'd actually be nice to flip the |
reduces the time to emit dep-info and metadata.
e15edf9
to
7041ef3
Compare
started with that order of Arc and the Option but when I did not get it to compile I changed thanks for the comments. |
Linking needs the list of exported symbols too, so it will be computed there instead of earlier. However, the overall time should be the same in that case, while can skip computing the list in cases without linking. It would be great if you could verify this though (that the overall build time is roughly the same for builds that do linking). |
the time-passes listed abow is what differs between the runs so when linking I see a 40ms longer compile time with this PR. |
the function that takes longer time is this rust/src/librustc_trans/back/link.rs Line 800 in 58a8e0c
but I do not see how this PR change any thing in that function very strange. |
That's weird. Let's test it perf.rust-lang.org to see if the difference is visible there too. @bors try |
lookup exported symbols only when needed. reduces the time to compile small file with no optimization by half.
☀️ Test successful - status-travis |
@Mark-Simulacrum, could you do a perf run please? |
Must've forgot to leave a comment that I queued it. http://perf.rust-lang.org/compare.html?start=27a046e9338fb0455c33b13e8fe28da78212dedc&end=682bc88006582c2e549d0c5b26a1f41a682f2a18&stat=instructions%3Au (done). Looks fairly good overall. |
have tested om my other computer and can not see any degradation of the compile time when linking. |
@andjo403 "style-servo-opt clean incremental" is flaky so you can ignore it (check out the front page http://perf.rust-lang.org/). So, nice wins all around :) |
📌 Commit 7041ef3 has been approved by |
…erister lookup exported symbols only when needed. reduces the time to compile small file with no optimization by half.
reduces the time to compile small file with no optimization by half.