Skip to content

Conversation

@GuillaumeGomez
Copy link
Member

Let's see if it has an impact on performance.

r? ghost

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 29, 2025
@GuillaumeGomez
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 29, 2025
@bors
Copy link
Collaborator

bors commented Apr 29, 2025

⌛ Trying commit b7de7a0 with merge 1b81120...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 29, 2025
…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
@bors
Copy link
Collaborator

bors commented Apr 29, 2025

☀️ Try build successful - checks-actions
Build commit: 1b81120 (1b81120a15b63f5d48a4ace1d5be8416031db67c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1b81120): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking 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 @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This 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.

mean range count
Regressions ❌
(primary)
1.6% [0.2%, 3.0%] 2
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.6% [0.2%, 3.0%] 2

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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-0.8%, -0.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.7% [-0.8%, -0.5%] 2

Cycles

Results (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.

mean range count
Regressions ❌
(primary)
1.7% [0.5%, 2.8%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-0.5%, -0.5%] 1
Improvements ✅
(secondary)
-5.4% [-14.6%, -1.6%] 20
All ❌✅ (primary) 1.0% [-0.5%, 2.8%] 3

Binary size

Results (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.

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [1.1%, 1.1%] 1

Bootstrap: 763.658s -> 763.537s (-0.02%)
Artifact size: 365.42 MiB -> 365.22 MiB (-0.06%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 29, 2025
@GuillaumeGomez
Copy link
Member Author

Small regression. Gonna try to make it better.

@GuillaumeGomez GuillaumeGomez force-pushed the iterator-instead-of-vec branch from b7de7a0 to 9d14b47 Compare May 2, 2025 14:17
@GuillaumeGomez
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 2, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2025
…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
@bors
Copy link
Collaborator

bors commented May 2, 2025

⌛ Trying commit 9d14b47 with merge 9efc522...

@bors
Copy link
Collaborator

bors commented May 2, 2025

☀️ Try build successful - checks-actions
Build commit: 9efc522 (9efc522381d82f77519ec169a2f081e2d99e95fc)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9efc522): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This 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.

mean range count
Regressions ❌
(primary)
0.7% [0.4%, 1.7%] 7
Regressions ❌
(secondary)
3.5% [3.5%, 3.5%] 1
Improvements ✅
(primary)
-1.5% [-5.7%, -0.4%] 7
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-5.7%, 1.7%] 14

Cycles

Results (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.

mean range count
Regressions ❌
(primary)
0.6% [0.4%, 1.6%] 16
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-1.4%, -0.4%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [-1.4%, 1.6%] 22

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 766.288s -> 768.378s (0.27%)
Artifact size: 365.55 MiB -> 365.45 MiB (-0.03%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels May 2, 2025
@GuillaumeGomez
Copy link
Member Author

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.

Comment on lines 901 to 906
if self.done {
return None;
}
let ret = self.item.adt_item_extra_attrs(self.tcx, self.document_private);
self.done = true;
ret
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lees intermediate variables.

Suggested change
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)
}

Comment on lines 862 to 867
Some(
rustc_hir_pretty::attribute_to_string(&tcx, attr)
.replace("\\\n", "")
.replace('\n', "")
.replace(" ", " "),
)
Copy link
Contributor

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?

Suggested change
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<_>>();
Copy link
Contributor

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.

Suggested change
let attrs = item.attributes(self.tcx, self.cache(), true).collect::<Vec<_>>();
let attrs = item.attributes(self.tcx, self.cache(), true).collect::<ThinVec<_>>();

Copy link
Member Author

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.

@GuillaumeGomez GuillaumeGomez force-pushed the iterator-instead-of-vec branch from 9d14b47 to 8e07721 Compare May 5, 2025 12:45
@GuillaumeGomez
Copy link
Member Author

Let's see if there is an improvement!

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 5, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 5, 2025
…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
@bors
Copy link
Collaborator

bors commented May 5, 2025

⌛ Trying commit 8e07721 with merge d5f9630...

@bors
Copy link
Collaborator

bors commented May 5, 2025

☀️ Try build successful - checks-actions
Build commit: d5f9630 (d5f963095693d154e91c26822a3fcc6f6de58ee9)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d5f9630): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.5% [-1.5%, -1.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.5% [-1.5%, -1.5%] 1

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.

mean range count
Regressions ❌
(primary)
0.8% [0.4%, 2.1%] 12
Regressions ❌
(secondary)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
-0.6% [-0.6%, -0.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [-0.6%, 2.1%] 14

Cycles

Results (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.

mean range count
Regressions ❌
(primary)
0.6% [0.4%, 1.1%] 25
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-1.3%, -0.5%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [-1.3%, 1.1%] 31

Binary size

Results (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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 1

Bootstrap: 768.8s -> 771.846s (0.40%)
Artifact size: 365.42 MiB -> 365.37 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 5, 2025
@GuillaumeGomez
Copy link
Member Author

Still no significant impact. I'll let it up to you notriddle whether or not you think this improvement is still worth keeping. 😉

@notriddle
Copy link
Contributor

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.

@notriddle notriddle closed this May 5, 2025
@GuillaumeGomez GuillaumeGomez deleted the iterator-instead-of-vec branch May 6, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants