Skip to content

Avoid a few more allocations in write_shared.rs #142667

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yotamofek
Copy link
Contributor

@yotamofek yotamofek commented Jun 18, 2025

Inspired by #141421 , avoids a few Vec, PathBuf and String allocations in write_shared.rs. I don't think these will show up on benchmarks, but are still worthwhile IMHO.
Also includes a few small cleanups.
r? nnethercote - if you'd like :)

@rustbot
Copy link
Collaborator

rustbot commented Jun 18, 2025

nnethercote is not on the review rotation at the moment.
They may take a while to respond.

@rustbot rustbot added 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. labels Jun 18, 2025
@yotamofek
Copy link
Contributor Author

Oh, maybe r? @GuillaumeGomez then?

@GuillaumeGomez
Copy link
Member

Looks promising, thanks! Let's check perf impact.

@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 Jun 18, 2025
bors added a commit that referenced this pull request Jun 18, 2025
…r=<try>

Avoid a few more allocations in `write_shared.rs`

Inspired by #141421 , avoids a few `Vec`, `PathBuf` and `String` allocations in `write_shared.rs`. I don't think these will show up on benchmarks, but are still worthwhile IMHO.
Also includes a few small cleanups.
r? nnethercote - if you'd like :)
@bors
Copy link
Collaborator

bors commented Jun 18, 2025

⌛ Trying commit 56fe2f6 with merge 91cf0c3...

@bors
Copy link
Collaborator

bors commented Jun 18, 2025

☀️ Try build successful - checks-actions
Build commit: 91cf0c3 (91cf0c3afad8861a1760cf5bae082ee32c4375b5)

@rust-timer

This comment has been minimized.

@nnethercote
Copy link
Contributor

I like the cleanups in commits 1, 3, 4, and 5.

I'm ambivalent about the introduction of Cow in commits 2 and 6. Optimized code is often more complex that non-optimized code, and if the optimizations don't have measurable effects then they aren't worth it. I.e. I disagree with "I don't think these will show up on benchmarks, but are still worthwhile IMHO." I did #141421 by looking at memory profiles (from DHAT) and avoiding the hot allocation paths.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (91cf0c3): 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 2.7%)

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)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary -2.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)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 692.01s -> 691.962s (-0.01%)
Artifact size: 372.13 MiB -> 372.12 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 19, 2025
@nnethercote
Copy link
Contributor

The perf CI run is neutral. r=me for commits 1, 3, 4, and 5.

@yotamofek yotamofek force-pushed the pr/rustdoc/more-write-shared-perf branch from 56fe2f6 to 2bf66e3 Compare June 19, 2025 10:26
@yotamofek
Copy link
Contributor Author

@nnethercote thanks for reviewing! Rebased without those two commits.
Just wanted to say that I didn't mean that it's worthwhile to make these changes even if they don't improve perf (because like you said - they just add complexity), what I meant was that the benchmark suite doesn't necessarily cover all workloads, and that some improvements might be too minute to register, but will have a real-life impact when added up. i.e., benchmarks are never perfect. :)

@nnethercote
Copy link
Contributor

Thanks!

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 19, 2025

📌 Commit 2bf66e3 has been approved by nnethercote

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants