Skip to content

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Aug 11, 2025

&Freeze parameters are not only readonly within the function, but any captures of the pointer can also only be used for reads. This can now be encoded using the captures(address, read_provenance) attribute.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 11, 2025
@nikic
Copy link
Contributor Author

nikic commented Aug 11, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 11, 2025
Tell LLVM about read-only captures
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 11, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 11, 2025

☀️ Try build successful (CI)
Build commit: 6bc3793 (6bc37934c6eaa84bfd300c54189bec62e15d42ed, parent: 577166503aee7290e09374da21f4045c455acfd5)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6bc3793): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.4%] 5
Regressions ❌
(secondary)
1.0% [0.9%, 1.6%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.8% [-0.8%, -0.7%] 5
All ❌✅ (primary) 0.3% [0.3%, 0.4%] 5

Max RSS (memory usage)

Results (secondary 3.9%)

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

Cycles

Results (secondary -2.1%)

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

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%] 23
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 465.465s -> 464.036s (-0.31%)
Artifact size: 377.33 MiB -> 377.30 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 11, 2025
@nikic nikic force-pushed the read-only-capture branch from 2f266b1 to a68e8be Compare August 19, 2025 10:37
@nikic nikic marked this pull request as ready for review August 19, 2025 10:38
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 19, 2025
@@ -55,6 +55,7 @@ fn main() {
// The `Box` has been deallocated by now, so this is a dangling reference!
let r: &u8 = &*r;
println!("{:p}", r);
println!("{}", i);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These adjustments are necessary so these tests still get miscompiled.

@nikic
Copy link
Contributor Author

nikic commented Aug 19, 2025

r? compiler

@rust-log-analyzer

This comment has been minimized.

@nikic nikic force-pushed the read-only-capture branch from a68e8be to 66fd5d8 Compare August 19, 2025 11:29
Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

Thanks @nikic!

r=me with or without suggestion

nikic added 2 commits August 20, 2025 19:08
`&Freeze` parameters are not only `readonly` within the function,
but any captures of the pointer can also only be used for reads.
This can now be encoded using the `captures(address, read_provenance)`
attribute.
The capture of i in assert_ne!() is now known read-only, which
enables early SROA. Block this by passing i to println, where
we currently cannot recognize this.
@nikic nikic force-pushed the read-only-capture branch from 66fd5d8 to dd151be Compare August 20, 2025 17:08
@nikic
Copy link
Contributor Author

nikic commented Aug 20, 2025

@bors r=wesleywiser

@bors
Copy link
Collaborator

bors commented Aug 20, 2025

📌 Commit dd151be has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 20, 2025
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 20, 2025
@bors
Copy link
Collaborator

bors commented Aug 20, 2025

⌛ Testing commit dd151be with merge 125ff8a...

@bors
Copy link
Collaborator

bors commented Aug 21, 2025

☀️ Test successful - checks-actions
Approved by: wesleywiser
Pushing 125ff8a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 21, 2025
@bors bors merged commit 125ff8a into rust-lang:master Aug 21, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 21, 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 040a98a (parent) -> 125ff8a (this PR)

Test differences

Show 7 test diffs

Stage 1

  • [codegen] tests/codegen-llvm/read-only-capture-opt.rs: [missing] -> ignore (ignored when the LLVM version 19.1.1 is older than 21.0.0) (J0)
  • [codegen] tests/codegen-llvm/read-only-capture-opt.rs: [missing] -> ignore (ignored when the LLVM version 20.1.2 is older than 21.0.0) (J2)

Stage 2

  • [codegen] tests/codegen-llvm/read-only-capture-opt.rs: [missing] -> ignore (ignored when the LLVM version 19.1.1 is older than 21.0.0) (J1)
  • [codegen] tests/codegen-llvm/read-only-capture-opt.rs: [missing] -> pass (J3)
  • [codegen] tests/codegen-llvm/read-only-capture-opt.rs: [missing] -> ignore (ignored when the LLVM version 20.1.2 is older than 21.0.0) (J4)

Additionally, 2 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 125ff8a788c5d6a66917f499abdc00051afe6886 --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. dist-aarch64-linux: 8945.1s -> 5954.9s (-33.4%)
  2. dist-apple-various: 4248.7s -> 5367.6s (26.3%)
  3. dist-x86_64-apple: 6496.1s -> 8134.3s (25.2%)
  4. dist-aarch64-msvc: 5256.9s -> 6130.5s (16.6%)
  5. i686-msvc-2: 9200.7s -> 7840.8s (-14.8%)
  6. pr-check-1: 1583.7s -> 1371.4s (-13.4%)
  7. dist-various-1: 3853.5s -> 4265.6s (10.7%)
  8. aarch64-gnu-llvm-19-2: 2413.3s -> 2230.4s (-7.6%)
  9. dist-x86_64-msvc-alt: 9908.0s -> 9159.0s (-7.6%)
  10. x86_64-msvc-ext2: 6232.4s -> 5763.1s (-7.5%)
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 (125ff8a): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.8% [0.8%, 0.8%] 1
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 7
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
-1.3% [-1.7%, -0.2%] 8
All ❌✅ (primary) 0.3% [-0.2%, 0.8%] 2

Max RSS (memory usage)

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

Cycles

Results (secondary -1.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)
3.7% [3.7%, 3.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-3.3%, -2.6%] 4
All ❌✅ (primary) - - 0

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: 471.047s -> 471.807s (0.16%)
Artifact size: 378.31 MiB -> 378.19 MiB (-0.03%)

@panstromek
Copy link
Contributor

perf triage:

include-blob regressions are noise. serde_derive looks real but it's tiny (adding a println statement). Seems like the biggest query differences are in LLVM, that seems to match the PR area.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants