-
Notifications
You must be signed in to change notification settings - Fork 304
Call for Testing: Speeding up compilation with hint-mostly-unused
#1662
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
base: master
Are you sure you want to change the base?
Call for Testing: Speeding up compilation with hint-mostly-unused
#1662
Conversation
cc @rust-lang/cargo |
1bf9f52
to
ee5040b
Compare
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.
Great work! Left two comments.
ee5040b
to
b5846cb
Compare
|
||
## Background | ||
|
||
Some crates provide comprehensive APIs with a very large surface area, yet many |
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.
Perhaps it will help intuition to say this is for APIs that are monomorphic? Not sure how to put that.
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.
I attempted to cover this; let me know how the new version looks.
|
||
Note that this option does not provide a universal performance improvement for | ||
every crate. Using it for crates whose API surface is mostly used, and/or used | ||
in multiple different crates or binaries (e.g. multiple test binaries that each |
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.
I think this explanation really undersells the downside. The problem is that when misused, the flag either completely removes CGU partitioning or causes more items to be compiled in multiple CGUs than before. The way this paragraph is written currently makes it seem like the downsides don't apply if I know have one bin target and no tests.
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.
This paragraph does also explicitly say it's a bad idea for crates whose API surface is mostly used.
I'll try to make this paragraph clearer and more emphatic.
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.
@saethlin I've now expanded this paragraph, and made it much more emphatic about the potential downsides. Let me know if that looks better.
4b90258
to
f76bfcc
Compare
## Background | ||
|
||
When building a Rust library crate, the compiler generates compiled code for as | ||
much of the crate as it can (everything that isn't generic and isn't inlined), |
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.
much of the crate as it can (everything that isn't generic and isn't inlined), | |
much of the crate as it can (everything that isn't generic and doesn't have `#[inline]`), |
We should avoid using the adjective "inlined" for functions that have the inline attribute (same about using the verb inline for adding the attribute), as that adjective is more commonly used for functions that actually have been inlined by the optimizer. Let's avoid this confusion and be very explicit about the attribute.
I'm pleased to announce, and call for testing of, the nightly-only `rustc` | ||
`-Zhint-mostly-unused` option, and the corresponding nightly Cargo features | ||
`profile.hint-mostly-unused` and `hints.mostly-unused`. These options can help | ||
accelerate your Rust compile time in some cases, by avoiding compilation of |
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.
"by avoiding compilation" may be interpreted as saying we will skip type-checking and/or borrow-checking. Which is not true in the current implementation. But maybe we want to leave open the possibility of doing so in the future?
I don't have a particular suggestion or concern here, I just want to make sure you mean the implication I'm reading.
can take a disproportionate amount of the entire compilation time of your | ||
top-level crate. |
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.
can take a disproportionate amount of the entire compilation time of your | |
top-level crate. | |
can take a disproportionate fraction of the entire compilation time for a full build. |
Because adding -Zhint-mostly-unused
will increase the compile time of the top-level crate, while lowering the compile time of the entire multi-crate build.
code generation for those items repeatedly. In particular, avoid using this | ||
hint for crates whose API surface is mostly used, and/or used in multiple |
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.
code generation for those items repeatedly. In particular, avoid using this | |
hint for crates whose API surface is mostly used, and/or used in multiple | |
code generation for those items repeatedly. In particular, this hint will | |
probably regress compile time if applied to crates whose API surface is | |
mostly used, and/or used in multiple |
it applies obvious and substantial wins for your users. Never apply it across | ||
the board to all your dependencies. |
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.
it applies obvious and substantial wins for your users. Never apply it across | |
the board to all your dependencies. | |
it applies obvious and substantial wins for your users. Applying it across | |
the board to all your dependencies will probably go poorly. |
This blog post serves as a call for testing on the
hint-mostly-unused
feature: giving people guidance on how it can help and how to use it, providing
sample performance numbers, asking for specific testing, and pointing people to
a tracking issue for feedback.
Rendered