Skip to content
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

Fix perf regression from TypeVisitor changes #101893

Merged
merged 3 commits into from
Sep 29, 2022
Merged

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Sep 16, 2022

Regression occurred in #101858 (comment)

Instead of just reverting, we only fixed part of the regression. The main regression was due to actually correctly visiting a type that contains types and consts and should therefor be visited. This is not actually observable (yet?), but we should still do it correctly instead of risking major bugs in the future.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 16, 2022
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 16, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 16, 2022
@bors
Copy link
Contributor

bors commented Sep 16, 2022

⌛ Trying commit cf6366b with merge f68409c5eea19c71665bc0c07038879c68413d11...

@bors
Copy link
Contributor

bors commented Sep 16, 2022

☀️ Try build successful - checks-actions
Build commit: f68409c5eea19c71665bc0c07038879c68413d11 (f68409c5eea19c71665bc0c07038879c68413d11)

@rust-timer
Copy link
Collaborator

Queued f68409c5eea19c71665bc0c07038879c68413d11 with parent 22f6aec, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f68409c5eea19c71665bc0c07038879c68413d11): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.5% [-2.0%, -0.3%] 7
Improvements ✅
(secondary)
-1.0% [-2.0%, -0.5%] 8
All ❌✅ (primary) -1.5% [-2.0%, -0.3%] 7

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.8% [1.6%, 2.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
3.5% [2.4%, 4.7%] 2
Regressions ❌
(secondary)
2.9% [2.0%, 4.8%] 4
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) 1.5% [-2.6%, 4.7%] 3

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 16, 2022
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 17, 2022

r? @lcnr turns out generalizing the &List impls for TypeVisitor is a perf problem. I can investigate further, but maybe let's just revert for now

@lcnr
Copy link
Contributor

lcnr commented Sep 19, 2022

is it only the CanonicalVarInfo folder which is causing the regression? We have CanonicalVarInfo in the mir for user types, so I expect that to be a large part of the regression 🤔 not traversing them seems like a bug (even if probably not exploitable as the only possible types in them are const param types which are mostly trivial) however so I would actually accept the perf regression (maybe we can instead cache the type flags for either user types or the whole mir to alleviate some of it.

@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 19, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 19, 2022
@bors
Copy link
Contributor

bors commented Sep 19, 2022

⌛ Trying commit 18ab705 with merge cf14103f0c80a2a2abd96c44f71d6c855b27fa23...

@bors
Copy link
Contributor

bors commented Sep 19, 2022

☀️ Try build successful - checks-actions
Build commit: cf14103f0c80a2a2abd96c44f71d6c855b27fa23 (cf14103f0c80a2a2abd96c44f71d6c855b27fa23)

@rust-timer
Copy link
Collaborator

Queued cf14103f0c80a2a2abd96c44f71d6c855b27fa23 with parent 503e19d, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cf14103f0c80a2a2abd96c44f71d6c855b27fa23): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.5% [3.9%, 5.4%] 3
Improvements ✅
(primary)
-1.3% [-1.7%, -0.4%] 7
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.3% [-1.7%, -0.4%] 7

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.9% [-3.9%, -3.9%] 1
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
2.2% [2.2%, 2.2%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.5%, -2.3%] 2
All ❌✅ (primary) 2.2% [2.2%, 2.2%] 1

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 19, 2022
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 19, 2022

The deeply nested benchmark regresses even further with this change. But the diesel benchmark is unaffected. So we can get both the perf regression fixed in the regular case and get checking of CanonicalVarInfo

@lcnr
Copy link
Contributor

lcnr commented Sep 20, 2022

so now all of the 5 functions are exactly the same so its really weird how that can have worse perf than just using 1 generic function, is the difference because of inlining decisions? 🤔

regressions to incr-unchanged feel acceptable, so either r=me as is or you try to merge the impls again, maybe slapping some inline attribute on it or whatever 🤷

@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 20, 2022

is the difference because of inlining decisions? 🤔

Making it generic gives us access to the MIR, so inlining can now happen across crates, where it wasn't possible before. But just for completeness I'll do some more experiments.

@bors try @rust-timer queue include=diesel,deeply-nested-multi

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 21, 2022

@rust-timer build 7eecd77bc8dd1ade7b4d10cdb244db88238a7c78 include=diesel,deeply-nested-multi

@rust-timer
Copy link
Collaborator

Queued 7eecd77bc8dd1ade7b4d10cdb244db88238a7c78 with parent acb8934, future comparison URL.

@Mark-Simulacrum
Copy link
Member

The try build didn't succeed, so this queue won't work (and actually stalls the collector today, though we should fix that0. @bors try

 error: unused import: `ControlFlow`
  --> compiler/rustc_middle/src/infer/canonical.rs:32:16
   |
32 | use std::ops::{ControlFlow, Index};
   |                ^^^^^^^^^^^
   |
   = note: `-D unused-imports` implied by `-D warnings`

[RUSTC-TIMING] rustc_attr test:false 3.499

@bors
Copy link
Contributor

bors commented Sep 21, 2022

⌛ Trying commit f841f1b with merge 549a91bb3ca412725a8d26f84b033d74be3bca68...

@bors
Copy link
Contributor

bors commented Sep 21, 2022

☀️ Try build successful - checks-actions
Build commit: 549a91bb3ca412725a8d26f84b033d74be3bca68 (549a91bb3ca412725a8d26f84b033d74be3bca68)

@Mark-Simulacrum
Copy link
Member

@rust-timer build 549a91bb3ca412725a8d26f84b033d74be3bca68 include=diesel,deeply-nested-multi

@rust-timer
Copy link
Collaborator

Queued 549a91bb3ca412725a8d26f84b033d74be3bca68 with parent 1de00d1, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (549a91bb3ca412725a8d26f84b033d74be3bca68): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.2% [-2.8%, -0.4%] 8
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

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

Footnotes

  1. the arithmetic mean of the percent change

  2. number of relevant changes

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Sep 21, 2022
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 28, 2022

Only the original PR gives us both diesel and deeply-nested perf improvements.

@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 28, 2022

But considering this is a bugfix that simply has to do more work

@rustbot ready

@oli-obk oli-obk removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 28, 2022
@lcnr
Copy link
Contributor

lcnr commented Sep 29, 2022

r=me with updated pr title 😁

@oli-obk oli-obk changed the title Revert TypeVisitor changes Fix perf regression from TypeVisitor changes Sep 29, 2022
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 29, 2022

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Sep 29, 2022

📌 Commit f841f1b 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 29, 2022
@bors
Copy link
Contributor

bors commented Sep 29, 2022

⌛ Testing commit f841f1b with merge 9f1a21a...

@bors
Copy link
Contributor

bors commented Sep 29, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 29, 2022
@bors bors merged commit 9f1a21a into rust-lang:master Sep 29, 2022
@rustbot rustbot added this to the 1.66.0 milestone Sep 29, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9f1a21a): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.4% [1.2%, 1.6%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.3% [-2.9%, -0.5%] 9
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 2
All ❌✅ (primary) - - 0

Cycles

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

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@rustbot rustbot added the perf-regression Performance regression. label Sep 29, 2022
@Kobzol
Copy link
Contributor

Kobzol commented Sep 29, 2022

keccak has been noisy lately.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Sep 29, 2022
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. 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.

8 participants