-
Notifications
You must be signed in to change notification settings - Fork 13.4k
rustdoc_json: reduce allocations #142335
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
rustdoc_json: reduce allocations #142335
Conversation
- It doesn't need to be cloneable. - Some of the `Rc`s and `RefCell`s aren't doing anything. - `after_krate` can consume `self`.
It can be very big. This reduces peak memory usage for some `--output-format=json` runs by up to 8%.
By making `JsonRenderer::item` take `&clean::Item` instead of a `clean::Item`. This required also changing `FromClean` and `IntoJson` methods to take references, which required a lot of follow-on sigil wrangling that is mostly tedious.
We can avoid it by using the `entry` API, which lets us do the `assert_eq` comparison before `new_item` is consumed.
rustc-perf doesn't measure rustdoc_json so a perf run won't tell us anything. But I modified rustc-perf locally to use wall-time reductions: max-rss (peak memory) reductions: (You can ignore the red entries. There's enough noise in these metrics that even on clear improvements there will usually be one or two benchmarks that look like a regression, but they're not.) Other metrics like instruction counts, cycles, cache-misses, page faults, and allocation counts were all improved as well. |
cc @obi1kenobi |
Amazing work! Also, thanks so much for splitting into different commits, it make it a breeze to review. @bors r+ rollup=never (Is that needed here? This is perf sensitive 🤷♀️) |
It's nice if it's rollup=never, since we can then check at least manually what was the effect on the CI built artifacts, since it's now possible in rustc-perf. |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 49a8ba0 (parent) -> 38c41d0 (this PR) Test differencesNo test diffs found Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 38c41d0f926d77985fc17087c21eeb7896dfe61e --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (38c41d0): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (secondary 3.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -1.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 758.463s -> 757.13s (-0.18%) |
These commits reduce the number of allocations done for rustdoc_json, mostly by avoiding unnecessary clones.
Best reviewed one commit at a time.
r? @aDotInTheVoid