-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Folding revamp #97447
Folding revamp #97447
Conversation
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 4c0dfc4f24819a7a6e29696851b8e9a937df5a17 with merge 0de273a0aaed9784c55f9056accf83bf2b496c6b... |
☀️ Try build successful - checks-actions |
Queued 0de273a0aaed9784c55f9056accf83bf2b496c6b with parent f558990, future comparison URL. |
Finished benchmarking commit (0de273a0aaed9784c55f9056accf83bf2b496c6b): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 @bors rollup=never Footnotes |
I haven't read through this in deep detail, but just curious on well this aligns with (or differs from) Chalk's Fold/Visit model: https://github.com/rust-lang/chalk/blob/master/chalk-ir/src/fold.rs |
Yes, this PR is much like the Chalk model. What Chalk calls |
6383df7
to
bdfa336
Compare
r? @jackh726 Best reviewed one commit at a time. |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit bdfa33663f5f27d6102261e2c98aa597f28415e0 with merge 0018697d93c34b5db080c6274e26c0c202d75864... |
☀️ Try build successful - checks-actions |
Queued 0018697d93c34b5db080c6274e26c0c202d75864 with parent e838059, future comparison URL. |
Finished benchmarking commit (0018697d93c34b5db080c6274e26c0c202d75864): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 @bors rollup=never Footnotes |
For most types the default impls of these methods are good enough, and `EarlyBinder` is one such type.
Because `TypeFoldable::try_fold_mir_const` exists, and even though `visit_mir_const` isn't needed right now, the consistency makes the code easier to understand.
We already have `visit_unevaluated`, so this improves consistency. Also, define `TypeFoldable for Unevaluated<'tcx, ()>` in terms of `TypeFoldable for Unevaluated<'tcx>`, which is neater.
This commit makes type folding more like the way chalk does it. Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods. - `fold_with` is the standard entry point, and defaults to calling `super_fold_with`. - `super_fold_with` does the actual work of traversing a type. - For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead calls into a `TypeFolder`, which can then call back into `super_fold_with`. With the new approach, `TypeFoldable` has `fold_with` and `TypeSuperFoldable` has `super_fold_with`. - `fold_with` is still the standard entry point, *and* it does the actual work of traversing a type, for all types except types of interest. - `super_fold_with` is only implemented for the types of interest. Benefits of the new model. - I find it easier to understand. The distinction between types of interest and other types is clearer, and `super_fold_with` doesn't exist for most types. - With the current model is easy to get confused and implement a `super_fold_with` method that should be left defaulted. (Some of the precursor commits fixed such cases.) - With the current model it's easy to call `super_fold_with` within `TypeFolder` impls where `fold_with` should be called. The new approach makes this mistake impossible, and this commit fixes a number of such cases. - It's potentially faster, because it avoids the `fold_with` -> `super_fold_with` call in all cases except types of interest. A lot of the time the compile would inline those away, but not necessarily always.
bdfa336
to
90db033
Compare
Thank you for the review! I have rebased. @bors r=jackh726 |
📌 Commit 90db033 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (64a7aa7): comparison url. Instruction count
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Footnotes |
The perf effects are fairly small and there are more improvements than regressions. @rustbot label: +perf-regression-triaged |
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
Rustup to rust-lang/rust#97447 Fixes #316 Signed-off-by: Yuki Okushi <jtitor@2k36.org>
rust-lang#97447 added folding of unevaluated constants, but did not include an override of the default (fallible) operation in the blanket impl of `FallibleTypeFolder` for infallible folders. Here we provide that missing override. r? @nnethercote
…allibletypefolder, r=nnethercote `try_fold_unevaluated` for infallible folders rust-lang#97447 added folding of unevaluated constants, but did not include an override of the default (fallible) operation in the blanket impl of `FallibleTypeFolder` for infallible folders. Here we provide that missing override. r? `@nnethercote`
…allibletypefolder, r=nnethercote `try_fold_unevaluated` for infallible folders rust-lang#97447 added folding of unevaluated constants, but did not include an override of the default (fallible) operation in the blanket impl of `FallibleTypeFolder` for infallible folders. Here we provide that missing override. r? ``@nnethercote``
…allibletypefolder, r=nnethercote `try_fold_unevaluated` for infallible folders rust-lang#97447 added folding of unevaluated constants, but did not include an override of the default (fallible) operation in the blanket impl of `FallibleTypeFolder` for infallible folders. Here we provide that missing override. r? ```@nnethercote```
r? @ghost