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

Merged
merged 4 commits into from
Jun 22, 2025

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
@bors
Copy link
Collaborator

bors commented Jun 21, 2025

⌛ Testing commit 2bf66e3 with merge fa2f355...

@bors
Copy link
Collaborator

bors commented Jun 22, 2025

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing fa2f355 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 22, 2025
@bors bors merged commit fa2f355 into rust-lang:master Jun 22, 2025
11 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 22, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing d4e1159 (parent) -> fa2f355 (this PR)

Test differences

No test diffs found

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard fa2f3552dae918294c8572b2a07fed2746722dd3 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-apple-2: 4878.1s -> 3715.6s (-23.8%)
  2. x86_64-apple-1: 6230.9s -> 7013.4s (12.6%)
  3. x86_64-msvc-1: 8401.0s -> 9110.6s (8.4%)
  4. dist-apple-various: 6204.2s -> 5756.3s (-7.2%)
  5. dist-x86_64-musl: 7106.4s -> 7557.0s (6.3%)
  6. dist-aarch64-apple: 5706.0s -> 5391.6s (-5.5%)
  7. x86_64-msvc-2: 6651.0s -> 7016.5s (5.5%)
  8. dist-x86_64-apple: 7078.8s -> 7399.7s (4.5%)
  9. aarch64-gnu: 6389.9s -> 6128.6s (-4.1%)
  10. x86_64-gnu-aux: 6101.3s -> 5853.9s (-4.1%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fa2f355): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary -1.7%, secondary -3.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)
- - 0
Improvements ✅
(primary)
-1.7% [-2.2%, -1.2%] 2
Improvements ✅
(secondary)
-3.4% [-5.6%, -1.0%] 6
All ❌✅ (primary) -1.7% [-2.2%, -1.2%] 2

Cycles

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

Binary size

Results (secondary 0.0%)

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

Bootstrap: 691.957s -> 689.982s (-0.29%)
Artifact size: 371.85 MiB -> 371.93 MiB (0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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