-
Notifications
You must be signed in to change notification settings - Fork 449
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
refactor: omega: avoid MVar machinery #5991
Conversation
@TwoFX mentioned that in his work on weight-balanced trees he has some `omega` proofs that take very long (16s), had many disjunctions, and already traced it down to `instantiateMVars`. So I got curious and had a look how omega is using the `MVar` machinery, and it is only using it to do case analysis on `Or`. It wasn't hard to rewrite this code to to construct the proof object directly, without using `MVars`, using `Or.elim`, and indeed it brings down the processing time of that particular proof from 16s to just below one second. And we even get a net reduction of the line count!
!bench |
Here are the benchmark results for commit be2bd5c. Benchmark Metric Change
=============================================================
+ big_omega.lean branch-misses -5.2% (-21.2 σ)
+ big_omega.lean branches -9.1% (-829.7 σ)
+ big_omega.lean instructions -10.4% (-1068.9 σ)
+ big_omega.lean MT branches -11.4% (-528.6 σ)
+ big_omega.lean MT instructions -10.9% (-666.8 σ)
- nat_repr task-clock 8.0% (11.6 σ)
- nat_repr wall-clock 7.9% (12.3 σ)
- stdlib instantiate metavars 12.1% (17.7 σ)
- stdlib share common exprs 1.7% (10.9 σ) |
Mixed benchmark results, it seems. In particular instantiate metavars to show up more is strange. |
Especially the
|
And the mathlib perf changes are essentially empty: Is omega used that little in mathlib? I’m inclined to merge anyways, |
I made a mistake while testing, and there is no performance gain after all. Was too good to be true in the first place. |
…to joachim/omega-no-mvar
!bench |
Here are the benchmark results for commit c3d4f27. Benchmark Metric Change
=====================================================
+ big_omega.lean branches -9.0% (-1467.6 σ)
+ big_omega.lean instructions -10.4% (-1882.4 σ)
+ big_omega.lean task-clock -8.0% (-10.2 σ)
+ big_omega.lean wall-clock -8.0% (-10.2 σ)
+ big_omega.lean MT branches -11.3% (-302.2 σ)
+ big_omega.lean MT instructions -10.8% (-221.0 σ)
+ import Lean task-clock -7.6% (-25.6 σ)
+ import Lean wall-clock -7.5% (-25.5 σ)
+ nat_repr task-clock -3.8% (-10.1 σ)
+ nat_repr wall-clock -3.8% (-10.6 σ)
+ stdlib maxrss -1.4% (-60.2 σ) |
This benchmark report looks better, although it makes me wonder if something is amiss with our benchmarks here, because I just pulled in the latest master, and didn’t change anything else. Oh well. |
@kim-em, do you want to have a brief look if you are ok with this change? |
Mathlib CI status (docs):
|
This PR simplifies the implementation of
omega
.When constructing the proof,
omega
is using MVars only for the purpose of doing case analysis onOr
. We can simplify the implementation a fair bit if we just produce the proof directly usingOr.elim
.While it didn’t yield the performance benefits I was hoping for, this still seems a worthwhile simplification, now that we already have it.