-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[rustdoc] Box ItemKind to reduce the size of Item
#80014
Conversation
Some changes occurred in intra-doc-links. cc @jyn514 |
r? @ollie27 (rust-highfive has picked a reviewer for you, use r? to override) |
d231734
to
1b6bb0c
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit 1b6bb0c79853f4d96b91679f5a01cd6c79291ba8 with merge 5060bdc312fd830ad807a5d08d2f884ef1303a1c... |
☀️ Try build successful - checks-actions |
Queued 5060bdc312fd830ad807a5d08d2f884ef1303a1c with parent 057937b, future comparison URL. |
Finished benchmarking try commit (5060bdc312fd830ad807a5d08d2f884ef1303a1c): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
Up to -1.7% on instructions, up to -3.1% on max-rss. The RSS numbers for rustdoc seem to be less variable than for rustc for some reason. |
r? @nnethercote maybe? |
Is there a way you could measure how much it helps reduce the peak memory usage there? |
Can you add a static assertion on the size to prevent future regressions? Something like this, which is a pattern used in various places in the compiler:
r=me with that done. Also, 280 bytes is still large. Most of the AST types in the compiler itself are less than 100 bytes. Which fields are big? |
@nnethercote you should have seen when I started, it was 784 bytes 😆 #79957 (comment) This is all changing rather rapidly so I'm a little hesitant to put an assert since it will make rebasing harder. After rebasing over master the new change is from 616 to 216.
So most of the size is coming from Attributes, Visibility, and (Stability, Deprecation, ConstStability). The last three are from rustc directly. A way I thought of to reduce that size is to calculate them on demand with something like enum ItemId {
Real(DefId),
Fake(usize),
}
impl Item {
fn stability() -> Option<Stability> { ... }
} and then always return I do not currently have ideas for reducing the size of Visibility or Attributes. |
1b6bb0c
to
487fc16
Compare
Measuring this (imprecisely, with FYI, all of these measurements are done with |
This comment has been minimized.
This comment has been minimized.
487fc16
to
9a4c311
Compare
Pass a `TyCtxt` through to `FormatRender` This is the next step after rust-lang#79957 for rust-lang#76382. Eventually I plan to use this to remove `stability`, `const_stability`, and `deprecation` from `Item`, but that needs more extensive changes (in particular, rust-lang#75355 or something like it). This has no actual changes to behavior, it's just moving types around. ccc rust-lang#80014 (comment)
This comment has been minimized.
This comment has been minimized.
9a4c311
to
311512b
Compare
…meGomez [rustdoc] Calculate stability, const_stability, and deprecation on-demand Previously, they would always be calculated ahead of time, which bloated the size of `clean::Item`. Builds on rust-lang#80090 and should not be merged before. Helps with rust-lang#79103 and rust-lang#76382. cc rust-lang#80014 (comment) This brings `Item` down to 568 bytes, down from 616.
…umeGomez Remove `DefPath` from `Visibility` and calculate it on demand Depends on rust-lang#80090 and should not be merged before. Helps with rust-lang#79103 and rust-lang#76382. cc rust-lang#80014 (comment) - `@nnethercote` I figured it out! It was simpler than I expected :) This brings the size of `clean::Visibility` down from 40 bytes to 8. Note that this does *not* remove `clean::Visibility`, even though it's now basically the same as `ty::Visibility`, because the `Invsible` variant means something different from `Inherited` and I thought it would be be confusing to merge the two. See the new comments on `impl Clean for ty::Visibility` for details.
This comment has been minimized.
This comment has been minimized.
This brings the size of `Item` from ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 680 ``` to ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 280 ```
311512b
to
4a44263
Compare
This now brings the size from 536 to 136 bytes. |
This comment has been minimized.
This comment has been minimized.
775d55e
to
5fce0dd
Compare
I added the static assertion. @bors r=nnethercote |
📌 Commit 5fce0dd has been approved by |
@bors rollup=never |
☀️ Test successful - checks-actions |
This brings the size of
Item
fromto
This is an alternative to #79967; I don't think it makes sense to make both changes.
Helps with #79103.