-
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
Rustdoc takes 8.5 GB of memory to document stm32h7 #79103
Comments
This is causing docs.rs to have to periodically bump the sandbox limits when documenting stm32 crates: rust-lang/docs.rs#1179. |
P-medium: it's annoying that it takes so much memory, but it's not like you can't document it. And it's being worked on. |
I ran Rustdoc under DHAT and found that a good tenth of the allocations come from rust/src/librustdoc/clean/blanket_impl.rs Line 130 in 2225ee1
|
Another 7% just storing the structs themselves:
|
[rustdoc] Calculate span information on demand instead of storing it ahead of time This brings `size_of<clean::types::Span>()` down from over 100 bytes (!!) to only 12, the same as rustc. It brings `Item` down even more, from `784` to `680`. ~~TODO: I need to figure out how to do this for the JSON backend too. That uses `From` impls everywhere, which don't allow passing in the `Session` as an argument. `@P1n3appl3,` `@tmandry,` maybe one of you have ideas?~~ Figured it out, fortunately only two functions needed to be changed. I like the `convert_x()` format better than `From` everywhere but I'm open to feedback. Helps with rust-lang#79103
[rustdoc] Switch to Symbol for item.name This decreases the size of `Item` from 680 to 616 bytes. It also does a lot less work since it no longer has to copy as much. Helps with rust-lang#79103. r? `@GuillaumeGomez`
The strange thing that most of the time is not spent on |
Almost all the time in
|
|
Get rid of `clean::Deprecation` This brings the size of `item.deprecation` from 56 to 16 bytes. Helps with rust-lang#79103 and rust-lang#76382, in the same vein as rust-lang#79957. r? `@GuillaumeGomez`
Add more timing info to rustdoc This helped me confirm in rust-lang#79103 (comment) that get_blanket_impls is indeed what's taking all the time on stm32. r? `@Mark-Simulacrum`
…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.
[rustdoc] Box ItemKind to reduce the size of `Item` This brings the size of `Item` from ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 536 ``` to ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 136 ``` This is an alternative to rust-lang#79967; I don't think it makes sense to make both changes. Helps with rust-lang#79103.
This also impacts |
I profiled this recently, and it's down to 1.6 GB - still high, but a lot better than before. I'm going to close this until I find something more specific to track. |
Similar to but not the same as #78761: rustdoc uses an inordinate amount of memory to document large crates.
heaptrack_gui
shows almost a third of the memory being allocated inget_blanket_impls
:However, the peak usage is actually in
check_mod_item_types
, which rustdoc can't do much about:Rustdoc should work improving on both the total memory usage and peak memory usage.
This is meant as a tracking issue, since there are issues other than
get_blanket_impls
causing high memory use, such as #76382. There is a Zulip stream for technical discussion.cc @adamgreig
The text was updated successfully, but these errors were encountered: