Skip to content

Conversation

cjgillot
Copy link
Contributor

Small effort to reduce invalidating CFG caches.

@rustbot
Copy link
Collaborator

rustbot commented Sep 18, 2025

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 18, 2025

r? @lcnr

rustbot has assigned @lcnr.
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 changed the title Avoid invalidating from MirPatch::apply. Avoid invalidating CFG caches from MirPatch::apply. Sep 18, 2025
@lcnr
Copy link
Contributor

lcnr commented Sep 19, 2025

r=me after perf

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Sep 19, 2025
Avoid invalidating CFG caches from MirPatch::apply.
@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 Sep 19, 2025
@rust-bors
Copy link

rust-bors bot commented Sep 19, 2025

☀️ Try build successful (CI)
Build commit: 37ed41a (37ed41a84266b30ffc58df946ea5338241662949, parent: 2f4dfc753fd86c672aa4145940db075a8a149f17)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (37ed41a): comparison URL.

Overall result: ❌✅ regressions and improvements - 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)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -3.2%)

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)
-3.9% [-4.5%, -2.5%] 9
All ❌✅ (primary) - - 0

Cycles

Results (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)
3.4% [2.7%, 4.4%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
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: 470.95s -> 471.912s (0.20%)
Artifact size: 389.99 MiB -> 387.95 MiB (-0.52%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 19, 2025
body.basic_blocks.len()
);
let bbs = if self.term_patch_map.is_empty() && self.new_blocks.is_empty() {
let bbs = if self.term_patch_map.iter().all(Option::is_none) && self.new_blocks.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

so this small perf regression might be real because we're now iterating over all basic blocks here even if all are None 🤔

🤷 would still be fine with landing this, but we may also consider alternatives, e.g. I would kinda assume that the patch map will be mostly None all the time, so maybe something that's better with sparse entries would perform better here.

anyways, haven't looked much at the relevant code yet

@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 Sep 20, 2025
Avoid invalidating CFG caches from MirPatch::apply.
@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 Sep 20, 2025
@rust-bors
Copy link

rust-bors bot commented Sep 20, 2025

☀️ Try build successful (CI)
Build commit: 5b81809 (5b8180916cd08f43db7975b4bf3491d8735ebdf8, parent: 9f2ef0f14d6028c5108643cafa6e2c617834594b)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5b81809): comparison URL.

Overall result: ✅ improvements - 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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.1%] 7
Improvements ✅
(secondary)
-0.2% [-0.4%, -0.1%] 12
All ❌✅ (primary) -0.2% [-0.2%, -0.1%] 7

Max RSS (memory usage)

Results (primary 0.3%, secondary -0.8%)

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

mean range count
Regressions ❌
(primary)
1.7% [1.0%, 2.1%] 3
Regressions ❌
(secondary)
0.9% [0.9%, 0.9%] 1
Improvements ✅
(primary)
-1.8% [-2.8%, -0.8%] 2
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) 0.3% [-2.8%, 2.1%] 5

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.8%, -2.0%] 2
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 471.07s -> 470.492s (-0.12%)
Artifact size: 389.99 MiB -> 389.88 MiB (-0.03%)

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

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

hm, we might be able to get another 0.1-0.2% here by doing some counts based profiling looking at how many entries end up in the term_patch_map and then e.g. use some SsoHashMap with an inline len of 1 or sth istead of a HashMap. I expect that slotting in the current SsoHashMap would actually slow things down as TerminatorKind is too large.

r=me after adding the comment

View changes since this review

Co-authored-by: lcnr <rust@lcnr.de>
@cjgillot
Copy link
Contributor Author

@bors r=lcnr

I'll try SsoHashMap in a follow up PR.

@bors
Copy link
Collaborator

bors commented Sep 24, 2025

📌 Commit ce677c7 has been approved by lcnr

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 24, 2025
@Zalathar
Copy link
Contributor

Scheduling: interleave rollup=never PRs with rollups.

@bors p=5

bors added a commit that referenced this pull request Sep 25, 2025
Avoid invalidating CFG caches from MirPatch::apply.

Small effort to reduce invalidating CFG caches.
@bors
Copy link
Collaborator

bors commented Sep 25, 2025

⌛ Testing commit ce677c7 with merge ef5b084...

@bors
Copy link
Collaborator

bors commented Sep 25, 2025

💔 Test failed - checks-actions

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

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Image input checksum 4ef84ab3b8a59556ac09337f9862a9844bfdfe25dfeff8792afdf568f1697d3819e6cfc0ed7069216c6f4229b9812f4c5544fa54c7a6e6d57bef45de3f3e3a8f
##[group]Building docker image for dist-sparcv9-solaris
Docker version 28.0.4, build b8034c0
Error response from daemon: Get "https://ghcr.io/v2/": Get "https://ghcr.io/token?account=rust-lang&client_id=docker&offline_token=true&service=ghcr.io": context deadline exceeded (Client.Timeout exceeded while awaiting headers) (Client.Timeout exceeded while awaiting headers)
##[error]Process completed with exit code 1.
Post job cleanup.

@Zalathar
Copy link
Contributor

@bors retry (flaky)

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

bors commented Sep 25, 2025

⌛ Testing commit ce677c7 with merge eabf390...

@bors
Copy link
Collaborator

bors commented Sep 25, 2025

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing eabf390 to master...

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

Test differences

Show 2 test diffs

2 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 eabf390b4ceeb34db9f37e97f435134abbcdea92 --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-x86_64-apple: 8055.4s -> 6766.5s (-16.0%)
  2. aarch64-gnu: 7150.7s -> 6102.5s (-14.7%)
  3. pr-check-1: 1562.6s -> 1334.6s (-14.6%)
  4. aarch64-apple: 7594.2s -> 6536.8s (-13.9%)
  5. i686-gnu-nopt-1: 8244.0s -> 7321.3s (-11.2%)
  6. dist-aarch64-msvc: 6666.6s -> 5941.2s (-10.9%)
  7. i686-gnu-2: 6131.0s -> 5492.0s (-10.4%)
  8. x86_64-gnu-stable: 7524.4s -> 6790.8s (-9.8%)
  9. aarch64-gnu-llvm-20-1: 3689.8s -> 3330.6s (-9.7%)
  10. x86_64-gnu-debug: 7384.8s -> 6695.6s (-9.3%)
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 (eabf390): 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)
-0.2% [-0.2%, -0.1%] 3
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.1%] 10
All ❌✅ (primary) -0.2% [-0.2%, -0.1%] 3

Max RSS (memory usage)

Results (primary 1.0%, secondary 0.8%)

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

mean range count
Regressions ❌
(primary)
1.0% [1.0%, 1.0%] 1
Regressions ❌
(secondary)
1.6% [0.7%, 2.0%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) 1.0% [1.0%, 1.0%] 1

Cycles

Results (primary -2.6%)

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

Binary size

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

Bootstrap: 471.619s -> 470.601s (-0.22%)
Artifact size: 388.14 MiB -> 388.11 MiB (-0.01%)

@cjgillot cjgillot deleted the invalidate-patch branch September 25, 2025 23:49
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-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