-
Notifications
You must be signed in to change notification settings - Fork 632
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
speed up lia
by vm_computing the certificate checker only at Qed time
#15654
Comments
I think this used to be wrapped in |
Replacing |
It's supposed to move the time from Qed to the tactic call, not double them both. What if you replace Qed with Defined? What if you replace |
Hi, |
Am I assuming correctly that if If yes, I'd actually prefer to run all the certificate checking at Qed time, rather than to slow down every interactive step. One single lia invocation is not too bad, but if each interactive step tries to rewrite in * and uses lia as the sidecondition solver for the rewrite lemmas, the time spent in lia quickly adds up and makes the interactive experience painfully slow. On the other hand, having to take a short break at each Qed is much less of a problem. As for being able to better localize the error: If someone reports that they get a typechecking error at Qed involving |
I wonder if we could instead get a mutable flag to set, whatever the default? That way a user can enable/disable the early checking for their development without duplicating the |
I like the idea of a |
For the record, the following is what I use in CoqInterval: Ltac do_reduction nocheck native :=
clear ;
lazymatch nocheck with
| true =>
match native with
| true => native_cast_no_check (eq_refl true)
| false => vm_cast_no_check (eq_refl true)
end
| false =>
(abstract
match native with
| true => native_cast_no_check (eq_refl true)
| false => vm_cast_no_check (eq_refl true)
end) ||
fail "Numerical evaluation failed to conclude. You may want to adjust some parameters"
end. In other words, reflexive tactics are controlled by two boolean flags. One flag indicates whether the proof term should be type-checked immediately (default behavior) or if the check should be delayed at |
This issue is actually good news:
lia
has become so fast that now evaluating the reflective certificate checker becomes a noticeable proportion (ca 25% in one example) of its running time.Here's an example of the kind of goals that I'd like to solve as fast as possible:
It displays the following Ltac profile on my machine:
In this issue, I'll focus on the 25.6% of the time spent in
exact (uconstr)
(but of course, if this example inspires @fajb to optimize thexlia
part that takes 71.1%, that would be a welcome side effect of this issue... 😉).Currently,
zchecker
is implemented as follows:Note that
<:
means VMCast, ie it usesvm_compute
to prove that the inferred type matches the annotated type.But this means that
vm_compute
is run twice: Once during the invocation ofzchecker
(even though we already know the equality check will succeed) and a second time when checking theQed
.Now, if I override
zchecker
as follows:and remove the
Ltac Profiling
commands, but keep theTime
commands, and run in bashand import the printed numbers in a spreadsheet, and add up all
lia
times and allQed
times, thelia
time decreases by 25%, and theQed
time remains the same (I think the 1% improvement I measured is just noise).So it might make sense to open a PR that changes
zchecker
as suggested above, but since I'm not very familiar withvm_cast_no_check
wizardry, nor withlia
internals, I first wanted to ask if someone (@JasonGross ?) has ideas to improve thevm_cast_no_check
aspect, or if someone (@fajb ?) has comments on thelia
aspects?Coq version: 8.15+rc1
The text was updated successfully, but these errors were encountered: