-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Return an iterator instead of a Vec in rustdoc Item::attributes
#140441
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
Return an iterator instead of a Vec in rustdoc Item::attributes
#140441
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…ec, r=<try> Return an iterator instead of a `Vec` in rustdoc `Item::attributes` Let's see if it has an impact on performance. r? ghost
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (1b81120): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking 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 may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -0.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 1.0%, secondary -5.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary 1.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 763.658s -> 763.537s (-0.02%) |
|
Small regression. Gonna try to make it better. |
b7de7a0 to
9d14b47
Compare
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…ec, r=<try> Return an iterator instead of a `Vec` in rustdoc `Item::attributes` Let's see if it has an impact on performance. r? ghost
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (9efc522): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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 may lead to 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 (primary -0.4%, secondary 3.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 0.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 766.288s -> 768.378s (0.27%) |
|
I'm surprised the impact is so small for both memory and CPU... r? @notriddle If you don't think it's worth keeping, I'll just close the PR. |
src/librustdoc/clean/types.rs
Outdated
| if self.done { | ||
| return None; | ||
| } | ||
| let ret = self.item.adt_item_extra_attrs(self.tcx, self.document_private); | ||
| self.done = true; | ||
| ret |
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.
Lees intermediate variables.
| if self.done { | |
| return None; | |
| } | |
| let ret = self.item.adt_item_extra_attrs(self.tcx, self.document_private); | |
| self.done = true; | |
| ret | |
| if self.done { | |
| None | |
| } else { | |
| self.done = true; | |
| self.item.adt_item_extra_attrs(self.tcx, self.document_private) | |
| } |
src/librustdoc/clean/types.rs
Outdated
| Some( | ||
| rustc_hir_pretty::attribute_to_string(&tcx, attr) | ||
| .replace("\\\n", "") | ||
| .replace('\n', "") | ||
| .replace(" ", " "), | ||
| ) |
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.
I wonder if this makes a measurable improvement?
| Some( | |
| rustc_hir_pretty::attribute_to_string(&tcx, attr) | |
| .replace("\\\n", "") | |
| .replace('\n', "") | |
| .replace(" ", " "), | |
| ) | |
| let attr = rustc_hir_pretty::attribute_to_string(&tcx, attr); | |
| Some( | |
| if attr.contains(['\n', '\\']) || attr.contains(" ") { | |
| attr | |
| .replace("\\\n", "") | |
| .replace('\n', "") | |
| .replace(" ", " ") | |
| } else { | |
| attr | |
| } | |
| ) |
| .collect(); | ||
| let docs = item.opt_doc_value(); | ||
| let attrs = item.attributes(self.tcx, self.cache(), true); | ||
| let attrs = item.attributes(self.tcx, self.cache(), true).collect::<Vec<_>>(); |
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.
Another potential memory-use improvement.
| let attrs = item.attributes(self.tcx, self.cache(), true).collect::<Vec<_>>(); | |
| let attrs = item.attributes(self.tcx, self.cache(), true).collect::<ThinVec<_>>(); |
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 requires changing rustdoc-json-types so maybe in a follow-up. Let's see if the rest of your suggestions will work.
9d14b47 to
8e07721
Compare
|
Let's see if there is an improvement! @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…ec, r=<try> Return an iterator instead of a `Vec` in rustdoc `Item::attributes` Let's see if it has an impact on performance. r? ghost
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (d5f9630): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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 may lead to changes in compiler perf. @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 0.6%, secondary 1.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 0.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary -0.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 768.8s -> 771.846s (0.40%) |
|
Still no significant impact. I'll let it up to you notriddle whether or not you think this improvement is still worth keeping. 😉 |
|
No, I don't think it is. If it were written as a straight-line generator, maybe it would work, but as long as it requires a manual iterator adapter, it's not worth it. |
Let's see if it has an impact on performance.
r? ghost