Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow for re-using monomorphizations in upstream crates. #48779
Conversation
rust-highfive
assigned
estebank
Mar 6, 2018
This comment has been minimized.
This comment has been minimized.
|
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
label
Mar 6, 2018
michaelwoerister
unassigned
estebank
Mar 6, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 6, 2018
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@Mark-Simulacrum, could you do a perf run for this too, please? |
This comment has been minimized.
This comment has been minimized.
|
Perf queued. Probably about 40-45 minutes until it starts. |
This comment has been minimized.
This comment has been minimized.
|
Thanks, @Mark-Simulacrum! Here's the link: |
This comment has been minimized.
This comment has been minimized.
|
@Mark-Simulacrum, the results don't seem to be available yet. Is it still in the queue or has something gone wrong? |
michaelwoerister
force-pushed the
michaelwoerister:share-generics4
branch
from
9a1af56
to
710e4d6
Mar 7, 2018
This comment has been minimized.
This comment has been minimized.
|
Hm, it does look like something went wrong -- I've restarted the build. |
This comment has been minimized.
This comment has been minimized.
|
Will the link be the same? |
This comment has been minimized.
This comment has been minimized.
|
Hm, it failed again -- I'm going to try and keep an eye on it and hopefully diagnose why, it also turns out we weren't properly logging the failures for try builds previously so I've now corrected that as well. |
This comment has been minimized.
This comment has been minimized.
|
URL works now! |
This comment has been minimized.
This comment has been minimized.
|
Thanks, Mark! |
This comment has been minimized.
This comment has been minimized.
|
OK, so those numbers look good. I had hoped that they would be even better though. It looks like it's mostly small functions that get re-used. But yeah, -15.9% for tokio-web-push, I'll take it |
This comment has been minimized.
This comment has been minimized.
|
@rust-lang/compiler & @alexcrichton, do you have any objections to pursuing this further? There's a description at the top and performance numbers are here: http://perf.rust-lang.org/compare.html?start=6f2100b92cb14fbea2102701af6a3ac5814bd06c&end=55221f5e2d6d5c71f6b89674eb29f2a213f415ef&stat=instructions%3Au |
michaelwoerister
referenced this pull request
Mar 8, 2018
Open
Compiler Performance Tracking Issue #48547
This comment has been minimized.
This comment has been minimized.
|
Awesome work here @michaelwoerister! It's pretty neat how it's not to difficult to play around with various schemes like this these days :) One concern I might have here is the size of binaries but given that this only affects debug mode rather than optimized then I guess it doesn't matter too much? We rely on In general though seems like a great idea to me to keep pursuing, any bugs or surprises along the way we can probably smooth over! For the diamond problem you gisted above, is this what all that "link once ODR" stuff is for in LLVM? I feel like that's all basically intended for optimized binaries linking only one copy rather than for debug mode, so it may not benefit us much if we don't turn this on in optimized mode. Speaking of optimized mode though, we may actually be able to get some nice wins here with |
This comment has been minimized.
This comment has been minimized.
The monomorphizations are still assigned We could look into |
This comment has been minimized.
This comment has been minimized.
|
Also, thanks for the feedback, @alexcrichton! |
This comment has been minimized.
This comment has been minimized.
|
Oh right that's true, I'd sort of doubt that I think that for executables we don't currently pass linker scripts/symbol whitelists, but AFAIK that's because we just never have before. We could likely start now! |
This comment has been minimized.
This comment has been minimized.
OK, I'll make sure we do as part of the PR. |
This comment has been minimized.
This comment has been minimized.
|
We discussed this in the @rust-lang/compiler meeting today. Everybody felt pretty good about it. It'd be nice to land this and possibly do further experimentation to see if we can enable in optimized builds without hurting perf. |
michaelwoerister
force-pushed the
michaelwoerister:share-generics4
branch
2 times, most recently
from
be1e8f6
to
d4264dc
Mar 13, 2018
michaelwoerister
changed the title
WIP: Allow for re-using monomorphizations in upstream crates.
Allow for re-using monomorphizations in upstream crates.
Mar 13, 2018
kennytm
added
S-waiting-on-author
and removed
S-waiting-on-review
labels
Apr 5, 2018
michaelwoerister
added some commits
Mar 1, 2018
michaelwoerister
force-pushed the
michaelwoerister:share-generics4
branch
from
679ba55
to
61991a5
Apr 6, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r=alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Apr 6, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 6, 2018
This comment has been minimized.
This comment has been minimized.
|
|
michaelwoerister commentedMar 6, 2018
•
edited
Followup to #48611. This implementation is pretty much finished modulo failing tests if there are any. Not quite ready for review yet though.
DESCRIPTION
This PR introduces a
share-genericsmode for RLIBs and Rust dylibs. When a crate is compiled in this mode, two things will happen:This results in less code being translated and LLVMed. However, there are also downsides:
Consequently, this PR only enables the
shared-genericsmode for opt-levelsNo,Less,Size, andMinSize, and for when incremental compilation is activated.-O2and-O3will still generate generic functions per-crate.Another thing to note is that this has a somewhat similar effect as MIR-only RLIBs, in that monomorphizations are shared, but it is less effective because it cannot share monomorphizations between sibling crates:
With
share-generics, bothBandChave to instantiatefoo<u32>and onlyDcan re-use it (from eitherBorC). With MIR-only RLIBs,BandCwould not instantiate anything, and inDwe would then only instantiatefoo<u32>once.On the other hand, when there are many leaf crates in the graph (e.g. when compiling many individual test binaries) then the
share-genericsapproach will often be more effective.TODO