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

Only compute vtable information during codegen #126505

Merged
merged 1 commit into from
Jun 16, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jun 15, 2024

This PR removes vtable information from the Object and TraitUpcasting candidate sources in the trait solvers, and defers the computation of relevant information to Instance::resolve. This is because vtables really aren't a thing in the trait world -- they're an implementation detail in codegen.

Previously it was just easiest to tangle this information together since we were already doing the work of looking at all the supertraits in the trait solver, and specifically because we use traits to represent when it's possible to call a method via a vtable (Object candidate) and do upcasting (Unsize candidate). but I am somewhat suspicious we're doing a lot of extra work, especially in polymorphic contexts, so let's see what perf says.

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 15, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 15, 2024

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@compiler-errors

This comment was marked as outdated.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 15, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 15, 2024
Only compute vtable information during codegen

r? `@ghost`
@bors

This comment was marked as outdated.

@rust-log-analyzer

This comment was marked as outdated.

@rust-log-analyzer

This comment was marked as outdated.

@bors

This comment was marked as outdated.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2024
@compiler-errors
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 15, 2024

⌛ Trying commit 343e079 with merge 19ca3c6...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 15, 2024
Only compute vtable information during codegen

This PR removes vtable information from the `Object` and `TraitUpcasting` candidate sources in the trait solvers, and defers the computation of relevant information to `Instance::resolve`. This is because vtables really aren't a thing in the trait world -- they're an implementation detail in codegen.

Previously it was just easiest to tangle this information together since we were already doing the work of looking at all the supertraits in the trait solver, and specifically because we use traits to represent when it's possible to call a method via a vtable (`Object` candidate) and do upcasting (`Unsize` candidate). but I am somewhat suspicious we're doing a *lot* of extra work, especially in polymorphic contexts, so let's see what perf says.

Also, walking the vtable in the trait solver calls `impossible_predicates`, which itself does trait solving. This probably can lead to stack overflows the compiler.

r? `@ghost`
@compiler-errors compiler-errors 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 Jun 15, 2024
@bors
Copy link
Contributor

bors commented Jun 15, 2024

☀️ Try build successful - checks-actions
Build commit: 19ca3c6 (19ca3c6af7d6d1786b7aea51899fed72fcf48b6a)

@rust-timer

This comment has been minimized.

@rust-timer

This comment has been minimized.

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 15, 2024
@compiler-errors
Copy link
Member Author

@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 15, 2024
@bors
Copy link
Contributor

bors commented Jun 15, 2024

⌛ Trying commit 3b9adbe with merge ad3edf4...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 15, 2024
Only compute vtable information during codegen

This PR removes vtable information from the `Object` and `TraitUpcasting` candidate sources in the trait solvers, and defers the computation of relevant information to `Instance::resolve`. This is because vtables really aren't a thing in the trait world -- they're an implementation detail in codegen.

Previously it was just easiest to tangle this information together since we were already doing the work of looking at all the supertraits in the trait solver, and specifically because we use traits to represent when it's possible to call a method via a vtable (`Object` candidate) and do upcasting (`Unsize` candidate). but I am somewhat suspicious we're doing a *lot* of extra work, especially in polymorphic contexts, so let's see what perf says.

Also, walking the vtable in the trait solver calls `impossible_predicates`, which itself does trait solving. This probably can lead to stack overflows the compiler.

r? `@ghost`
@bors
Copy link
Contributor

bors commented Jun 15, 2024

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ad3edf4): comparison URL.

Overall result: no relevant changes - 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-perf -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary 3.4%)

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.

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

Cycles

Results (secondary 3.8%)

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.

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

Binary size

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

Bootstrap: 671.602s -> 672.019s (0.06%)
Artifact size: 320.43 MiB -> 319.77 MiB (-0.21%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Jun 15, 2024
@compiler-errors
Copy link
Member Author

Ok perfect. Even if this isn't a major perf improvement, I'd still like to do this since it removes a dependency on vtable information from the new trait solver.

r? compiler

@lcnr
Copy link
Contributor

lcnr commented Jun 15, 2024

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Jun 15, 2024

📌 Commit 3b9adbe 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 Jun 15, 2024
@bors
Copy link
Contributor

bors commented Jun 16, 2024

⌛ Testing commit 3b9adbe with merge 5639c21...

@bors
Copy link
Contributor

bors commented Jun 16, 2024

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 16, 2024
@bors bors merged commit 5639c21 into rust-lang:master Jun 16, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 16, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5639c21): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.3%, 0.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
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.

Binary size

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

Bootstrap: 671.288s -> 671.71s (0.06%)
Artifact size: 320.38 MiB -> 320.54 MiB (0.05%)

bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Jun 30, 2024
Only compute vtable information during codegen

This PR removes vtable information from the `Object` and `TraitUpcasting` candidate sources in the trait solvers, and defers the computation of relevant information to `Instance::resolve`. This is because vtables really aren't a thing in the trait world -- they're an implementation detail in codegen.

Previously it was just easiest to tangle this information together since we were already doing the work of looking at all the supertraits in the trait solver, and specifically because we use traits to represent when it's possible to call a method via a vtable (`Object` candidate) and do upcasting (`Unsize` candidate). but I am somewhat suspicious we're doing a *lot* of extra work, especially in polymorphic contexts, so let's see what perf says.
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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants