Skip to content

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Aug 22, 2025

GVN generates values that are not meant to be unified with any other. For instance Opaque (aka we don't know anything), non-deterministic constants and borrows.

The current algorithm generates a unique index, so the generated Value will be different from all the existing. This is wasteful, as we should not hash that Value at all.

This PR proposes to do this. This involves partially reimplementing a FxIndexSet, but yields a small but consistent perf improvement (#145737 (comment)).

@rustbot rustbot added 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 22, 2025
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 22, 2025
GVN: stop hashing opaque values
@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 Aug 22, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 22, 2025

☀️ Try build successful (CI)
Build commit: b1206a5 (b1206a5638d835852d82f15f0f0f66e4f33420a5, parent: 6ba0ce40941eee1ca02e9ba49c791ada5158747a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b1206a5): 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 (primary -0.9%, secondary -0.9%)

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

mean range count
Regressions ❌
(primary)
4.2% [4.2%, 4.2%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-6.1% [-6.1%, -6.1%] 1
Improvements ✅
(secondary)
-0.9% [-0.9%, -0.9%] 1
All ❌✅ (primary) -0.9% [-6.1%, 4.2%] 2

Cycles

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

Binary size

Results (primary -0.0%, secondary 0.2%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.1%] 2
Regressions ❌
(secondary)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
-0.1% [-0.2%, -0.1%] 3
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 3
All ❌✅ (primary) -0.0% [-0.2%, 0.1%] 5

Bootstrap: 471.281s -> 472.689s (0.30%)
Artifact size: 378.27 MiB -> 378.24 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 22, 2025
@cjgillot
Copy link
Contributor Author

@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 23, 2025
GVN: stop hashing opaque values
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 23, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 24, 2025

☀️ Try build successful (CI)
Build commit: 08b7b9c (08b7b9c5ab0fbe6eb9e66c5f59e9c8d90709f453, parent: c5a6a7bdd89f099544fa0d3fad4d833d238377ad)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (08b7b9c): comparison URL.

Overall result: ❌ regressions - 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

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

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

Max RSS (memory usage)

Results (primary -1.4%, secondary -1.5%)

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

mean range count
Regressions ❌
(primary)
2.5% [2.5%, 2.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.7% [-3.8%, -1.9%] 3
Improvements ✅
(secondary)
-1.5% [-1.9%, -1.1%] 2
All ❌✅ (primary) -1.4% [-3.8%, 2.5%] 4

Cycles

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

Binary size

Results (primary 0.0%, secondary 0.5%)

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

mean range count
Regressions ❌
(primary)
0.3% [0.1%, 0.4%] 4
Regressions ❌
(secondary)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
-0.3% [-0.7%, -0.1%] 3
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) 0.0% [-0.7%, 0.4%] 7

Bootstrap: 467.196s -> 468.333s (0.24%)
Artifact size: 378.17 MiB -> 378.18 MiB (0.00%)

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

bors commented Aug 27, 2025

☔ The latest upstream changes (presumably #145923) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Collaborator

bors commented Sep 7, 2025

☔ The latest upstream changes (presumably #146292) made this pull request unmergeable. Please resolve the merge conflicts.

@cjgillot
Copy link
Contributor Author

cjgillot commented Sep 9, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Sep 9, 2025
GVN: stop hashing opaque values
@rust-bors

This comment has been minimized.

@cjgillot cjgillot marked this pull request as ready for review September 14, 2025 13:50
@rustbot
Copy link
Collaborator

rustbot commented Sep 14, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Sep 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 14, 2025

r? @saethlin

rustbot has assigned @saethlin.
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

@cjgillot cjgillot added A-mir-opt Area: MIR optimizations A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) labels Sep 14, 2025
@saethlin
Copy link
Member

Did you check if these debug assertions were actually too expensive to be enabled in all builds? Users make the compiler do really weird stuff, so I'm always wary of having assertions that are off in distributed builds.

That being said, if you do want to do that perf experiment, it'll be easier to do after this is merged.

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 18, 2025

📌 Commit df04be8 has been approved by saethlin

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 Sep 18, 2025
@bors
Copy link
Collaborator

bors commented Sep 19, 2025

⌛ Testing commit df04be8 with merge e10aa88...

@bors
Copy link
Collaborator

bors commented Sep 19, 2025

☀️ Test successful - checks-actions
Approved by: saethlin
Pushing e10aa88 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 19, 2025
@bors bors merged commit e10aa88 into rust-lang:master Sep 19, 2025
11 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 19, 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 2f4dfc7 (parent) -> e10aa88 (this PR)

Test differences

Show 4 test diffs

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

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard e10aa8891182378de002bd71bf4d04181fb8231d --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-gnu-llvm-20: 2347.2s -> 2855.0s (21.6%)
  2. pr-check-1: 1408.6s -> 1678.9s (19.2%)
  3. aarch64-gnu-llvm-20-2: 2205.9s -> 2572.2s (16.6%)
  4. dist-aarch64-apple: 9204.9s -> 7720.1s (-16.1%)
  5. aarch64-apple: 5583.1s -> 6477.4s (16.0%)
  6. dist-x86_64-apple: 6881.1s -> 5881.2s (-14.5%)
  7. aarch64-gnu: 6260.8s -> 7163.4s (14.4%)
  8. x86_64-rust-for-linux: 2557.2s -> 2891.0s (13.0%)
  9. aarch64-msvc-2: 4733.1s -> 5350.0s (13.0%)
  10. i686-gnu-nopt-1: 7134.1s -> 8048.3s (12.8%)
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 (e10aa88): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.7% [-1.9%, -1.5%] 2
Improvements ✅
(secondary)
-1.4% [-1.4%, -1.4%] 1
All ❌✅ (primary) -1.7% [-1.9%, -1.5%] 2

Max RSS (memory usage)

Results (primary -2.9%)

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

mean range count
Regressions ❌
(primary)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.7% [-9.8%, -1.9%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.9% [-9.8%, 2.7%] 4

Cycles

Results (primary 6.0%, secondary 2.2%)

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

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

Binary size

Results (primary -0.2%, 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.2% [0.1%, 0.2%] 3
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 3
Improvements ✅
(primary)
-0.4% [-0.9%, -0.1%] 5
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) -0.2% [-0.9%, 0.2%] 8

Bootstrap: 470.95s -> 471.12s (0.04%)
Artifact size: 389.99 MiB -> 389.97 MiB (-0.01%)

@rustbot rustbot removed the perf-regression Performance regression. label Sep 19, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 20, 2025
GVN: stop hashing opaque values

GVN generates values that are not meant to be unified with any other. For instance `Opaque` (aka we don't know anything), non-deterministic constants and borrows.

The current algorithm generates a unique index, so the generated `Value` will be different from all the existing. This is wasteful, as we should not hash that `Value` at all.

This PR proposes to do this. This involves partially reimplementing a `FxIndexSet`, but yields a small but consistent perf improvement (rust-lang/rust#145737 (comment)).
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 22, 2025
GVN: stop hashing opaque values

GVN generates values that are not meant to be unified with any other. For instance `Opaque` (aka we don't know anything), non-deterministic constants and borrows.

The current algorithm generates a unique index, so the generated `Value` will be different from all the existing. This is wasteful, as we should not hash that `Value` at all.

This PR proposes to do this. This involves partially reimplementing a `FxIndexSet`, but yields a small but consistent perf improvement (rust-lang/rust#145737 (comment)).
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Sep 24, 2025
GVN: stop hashing opaque values

GVN generates values that are not meant to be unified with any other. For instance `Opaque` (aka we don't know anything), non-deterministic constants and borrows.

The current algorithm generates a unique index, so the generated `Value` will be different from all the existing. This is wasteful, as we should not hash that `Value` at all.

This PR proposes to do this. This involves partially reimplementing a `FxIndexSet`, but yields a small but consistent perf improvement (rust-lang#145737 (comment)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) 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-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.

5 participants