-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Rustdoc performance improvements #151368
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 performance improvements #151368
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Rustdoc performance improvements
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (aa5a68b): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (secondary -0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 1.9%, secondary -2.6%)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: 474.261s -> 473.66s (-0.13%) |
f660783 to
09235ca
Compare
|
But it makes sense to allocate directly what you need and there is still one less string comparison. Well, whatever you prefer @yotamofek. Applied your suggestion as well. |
This comment has been minimized.
This comment has been minimized.
09235ca to
22f7c1a
Compare
|
Reverted the suggestion. |
| @@ -488,7 +490,15 @@ impl Hierarchy { | |||
| let files = self.elems.borrow(); | |||
| let name = OrderedJson::serialize(self.elem.to_str().expect("invalid osstring conversion")) | |||
| .unwrap(); | |||
| let mut out = Vec::from([name]); | |||
| let needed_capacity = if !files.is_empty() { | |||
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 change seems very verbose, considering it doesn't show on perf. Other two changes are IMHO improvements, regardless of perf.
Maybe discard just this one?
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.
ok!
22f7c1a to
290bb6c
Compare
|
Removed the pre-computed vec size. |
| if let Some(parent) = h.parent.upgrade() { | ||
| h = parent; | ||
|
|
||
| while let Some(component) = components.next() { |
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.
just noticed there's a very small change in behavior here.
previous version would panic if path.components() doesn't yield any items.
not sure if it's worth preserving? (you could add a assert!(components.peek().is_some()) before the loop)
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.
Good catch. Yeah let's go with an assert.
| h.elems.borrow_mut().insert(s.to_owned()); | ||
| break; | ||
| } | ||
| let next_h = { |
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.
nit: you could just do h = { ... }, instead of creating the new binding. up to you.
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.
One less variable and line, sounds good to me. :)
| Component::ParentDir => { | ||
| if let Some(parent) = h.parent.upgrade() { | ||
| h = parent; | ||
| } | ||
| } |
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.
nit, up to you:
| Component::ParentDir => { | |
| if let Some(parent) = h.parent.upgrade() { | |
| h = parent; | |
| } | |
| } | |
| Component::ParentDir if let Some(parent) = h.parent.upgrade() => { | |
| h = parent; | |
| } |
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.
Shorter, I like it.
290bb6c to
bd45311
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Applied improved code suggestions. :) |
|
r=me once CI passes, sorry for the long response time with this one :D |
|
@bors r=yotamofek rollup |
…uwer Rollup of 7 pull requests Successful merges: - #151290 (Recover from struct literals with placeholder or empty path) - #148187 (Remove uses of `&mut CmResolver`) - #151368 (Rustdoc performance improvements) - #151374 (some more rustc_borrowck cleanups) - #151536 (Fix sanitizer target builds on CI) - #151626 (Remove `Deref<Target = TyCtxt>` from `QueryCtxt`) - #151661 (Suggest changing `iter`/`into_iter` when the other was meant)
…uwer Rollup of 7 pull requests Successful merges: - #151290 (Recover from struct literals with placeholder or empty path) - #148187 (Remove uses of `&mut CmResolver`) - #151368 (Rustdoc performance improvements) - #151374 (some more rustc_borrowck cleanups) - #151536 (Fix sanitizer target builds on CI) - #151626 (Remove `Deref<Target = TyCtxt>` from `QueryCtxt`) - #151661 (Suggest changing `iter`/`into_iter` when the other was meant)
…uwer Rollup of 7 pull requests Successful merges: - #151290 (Recover from struct literals with placeholder or empty path) - #148187 (Remove uses of `&mut CmResolver`) - #151368 (Rustdoc performance improvements) - #151374 (some more rustc_borrowck cleanups) - #151536 (Fix sanitizer target builds on CI) - #151626 (Remove `Deref<Target = TyCtxt>` from `QueryCtxt`) - #151661 (Suggest changing `iter`/`into_iter` when the other was meant)
…uwer Rollup of 7 pull requests Successful merges: - #151290 (Recover from struct literals with placeholder or empty path) - #148187 (Remove uses of `&mut CmResolver`) - #151368 (Rustdoc performance improvements) - #151374 (some more rustc_borrowck cleanups) - #151536 (Fix sanitizer target builds on CI) - #151626 (Remove `Deref<Target = TyCtxt>` from `QueryCtxt`) - #151661 (Suggest changing `iter`/`into_iter` when the other was meant)
Rollup merge of #151368 - GuillaumeGomez:librustdoc-perf, r=yotamofek Rustdoc performance improvements A few things I had sitting around for a while. Let's check what perf says about them r? @yotamofek
A few things I had sitting around for a while. Let's check what perf says about them
r? @yotamofek