Optimisation: avoid emitting verify bounds that always hold#152579
Optimisation: avoid emitting verify bounds that always hold#152579amandasystems wants to merge 2 commits intorust-lang:mainfrom
Conversation
… hold This makes more sense than you'd imagine since empty `All` bounds which always hold is relatively common.
d55cf4c to
6b612a0
Compare
compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
Outdated
Show resolved
Hide resolved
|
|
||
| // If this bound is always satisfied, a complex bound should never have been | ||
| // constructed and we should have gotten [[`VerifyBound::always_satisfied`]] | ||
| debug_assert!( |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Optimisation: avoid emitting verify bounds that always hold
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (158e3b6): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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 Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 480.119s -> 484.722s (0.96%) |
| this.append(&mut that); | ||
| VerifyBound::AnyBound(this) | ||
| } | ||
| // FIXME: This can still nest arbitrarily. |
This PR normalises verify bounds that always hold and uses that logic to cheaply detect that case and never emit them.
This leaves a ton of tripwire assertions around that will activate if these assumptions are violated.
VerifyBound::or()is now also short-circuiting and flattens immediately nested Any bounds. Note that the short-circuiting means information may be lost if both bounds are failing and we want to keep both failing bounds.r? @lcnr