-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustdoc: Compute some fields of clean::Crate
on-demand to reduce size
#90391
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
Conversation
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit a92c191ad66c182bee3f619ececce20fc216c51b with merge a95fcc6c76fa042939aae01abaf13368297003c2... |
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 is great, thanks! Just a couple nits.
@@ -115,8 +115,7 @@ impl From<DefId> for ItemId { | |||
|
|||
#[derive(Clone, Debug)] | |||
crate struct Crate { | |||
crate name: Symbol, | |||
crate src: FileName, | |||
crate num: CrateNum, | |||
crate module: Item, | |||
crate externs: Vec<ExternalCrate>, |
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.
Note to self: remove this field as well.
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.
Update: In order to remove this field, Cache::populate
will need to take a DocContext, which I think is possible but will require some changes. I'm also working on that as part of #90365, so I'll save removing this field for a future PR.
☀️ Try build successful - checks-actions |
Queued a95fcc6c76fa042939aae01abaf13368297003c2 with parent df76418, future comparison URL. |
Finished benchmarking commit (a95fcc6c76fa042939aae01abaf13368297003c2): comparison url. Summary: This benchmark run did not return any relevant changes. 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 led to changes in compiler perf. @bors rollup=never |
That is really weird. Let's try rerunning perf to see if that was spurious. @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit a92c191ad66c182bee3f619ececce20fc216c51b with merge 73c6d8ebffee3c722b0c6f21fb78c137711a3f3f... |
☀️ Try build successful - checks-actions |
Queued 73c6d8ebffee3c722b0c6f21fb78c137711a3f3f with parent 9ed5b94, future comparison URL. |
Finished benchmarking commit (73c6d8ebffee3c722b0c6f21fb78c137711a3f3f): comparison url. Summary: This benchmark run did not return any relevant changes. 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 led to changes in compiler perf. @bors rollup=never |
... apparently that made the RSS regression go away? how strange ... |
In my experience, |
@camelid I would rather not add back |
Ok, sounds good. I'll try removing some of the other fields too. |
(Currently squashing.) |
Ok, should be good for a new review! |
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.
r=me with those nits fixed :)
It is only used in one place; `src` was about a third of `Crate`'s total size; `Crate` is frequently moved by-value; and `src` can be easily computed on-demand.
It is not as large as `Crate.src` was, but it's still 8 bytes, and `clean::Crate` is moved by-value a lot.
Now that rust-lang#73423 is fixed, sorting should no longer be necessary. See also this discussion [1]. [1]: rust-lang#86889 (comment)
@bors r=jyn514 rollup=never |
📌 Commit a58e214 has been approved by |
@@ -125,6 +124,20 @@ crate struct Crate { | |||
crate collapsed: bool, | |||
} | |||
|
|||
// `Crate` is frequently moved by-value. Make sure it doesn't unintentionally get bigger. | |||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] | |||
rustc_data_structures::static_assert_size!(Crate, 104); |
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.
Nice idea to add this check! 👍
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.
Thanks :)
☀️ Test successful - checks-actions |
Finished benchmarking commit (38b01d9): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
clean::Crate
is frequently moved by-value -- for example, inDocFolder
implementations -- so reducing its size should improve performance.
This PR reduces the size of
clean::Crate
from 168 bytes to 104 bytes.r? @jyn514