Skip to content

rustdoc: use with_capacity and reserve to reduce reallocation#152503

Open
lolbinarycat wants to merge 1 commit intorust-lang:mainfrom
lolbinarycat:rustdoc-with_capacity
Open

rustdoc: use with_capacity and reserve to reduce reallocation#152503
lolbinarycat wants to merge 1 commit intorust-lang:mainfrom
lolbinarycat:rustdoc-with_capacity

Conversation

@lolbinarycat
Copy link
Contributor

No description provided.

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Feb 11, 2026
@lolbinarycat
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 11, 2026
rust-bors bot pushed a commit that referenced this pull request Feb 11, 2026
rustdoc: use with_capacity and reserve to reduce reallocation
@lolbinarycat
Copy link
Contributor Author

Oops, forgot we can do more focused perf runs now, hopefully this overwrites the perf run and doesn't start a second one.

@rust-timer queue profiles=doc

@rust-timer

This comment has been minimized.

@lolbinarycat
Copy link
Contributor Author

@bors try cancel

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 11, 2026

Try build cancelled. Cancelled workflows:

@lolbinarycat
Copy link
Contributor Author

@bors try

rust-bors bot pushed a commit that referenced this pull request Feb 11, 2026
rustdoc: use with_capacity and reserve to reduce reallocation
@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 12, 2026

☀️ Try build successful (CI)
Build commit: 08f322c (08f322c258c616d236bf389f7abf02202a524729, parent: 7057231bd78d6c7893f905ea1832365d4c5efe17)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (08f322c): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking 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
@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 (secondary -4.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.5% [-4.9%, -4.0%] 2
All ❌✅ (primary) - - 0

Cycles

Results (secondary -2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.0% [3.0%, 3.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.2% [-5.5%, -2.8%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 476.438s -> 474.386s (-0.43%)
Artifact size: 397.88 MiB -> 397.89 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 12, 2026
@lolbinarycat
Copy link
Contributor Author

Like many other micro-optimizations, it doesn't have enough of an impact to actually clear the significance threshold, but it does seem like it helps a bit, and it makes logical sense that it would...

@lolbinarycat lolbinarycat marked this pull request as ready for review February 13, 2026 20:47
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 13, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 13, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 13, 2026

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 9 candidates
  • Random selection from GuillaumeGomez, camelid, fmease, notriddle

@lolbinarycat
Copy link
Contributor Author

r? @GuillaumeGomez

What do you think? Are the small (hard to measure) improvements worth it?

@GuillaumeGomez
Copy link
Member

I'd tend to say that if code isn't much better and perf doesn't change expected improvement, it's not worth it. In particular, we now add lot more pre-computed lengths that might be hard to keep up to date.

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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants