Add a Strategy command for ucmra and cmra projections
Investigate timing consequences of adding a Strategy
command. Motivation was the following example:
From iris.algebra Require Import frac_auth agree numbers auth.
From iris.base_logic Require Import lib.own.
From iris.proofmode Require Import proofmode.
Strategy expand [ucmra_cmraR ucmra_equiv ucmra_dist ucmra_pcore ucmra_op ucmra_valid ucmra_validN ucmra_ofe_mixin ucmra_cmra_mixin].
Section weird_slow_qed. (* using UR here *)
Lemma slow_qed `{!inG Σ (frac_authUR $ optionUR $ agreeR $ natO)} γ1 (n : nat) :
own γ1 (●F (Some $ to_agree n)) ⊢ own γ1 (●F (Some $ to_agree n)).
Proof. time iIntros "$". Time Qed. (* 0.2 seconds -> now 0.01 *)
(* using R here *)
Lemma fast_qed `{!inG Σ (frac_authUR $ optionR $ agreeR $ natO)} γ1 (n : nat) :
own γ1 (●F (Some $ to_agree n)) ⊢ own γ1 (●F (Some $ to_agree n)).
Proof. time iIntros "$". Time Qed. (* instant *)
(* using UR here *)
Lemma slow_qed2 `{!inG Σ (frac_authUR $ frac_authUR $ agreeR $ natO)} γ1 (n : nat) :
own γ1 (●F (●F (to_agree n))) ⊢ own γ1 (●F (●F (to_agree n))).
Proof. time iIntros "$". Time Qed. (* 1.4 seconds! -> now 0.044 *)
(* using R here *)
Lemma fast_qed2 `{!inG Σ (frac_authUR $ frac_authR $ agreeR $ natO)} γ1 (n : nat) :
own γ1 (●F (●F (to_agree n))) ⊢ own γ1 (●F (●F (to_agree n))).
Proof. time iIntros "$". Time Qed. (* instant *)
(* Note that if proven with `reflexivity`, Qed also becomes instant *)
End weird_slow_qed.
where Strategy
offers a drastic performance improvement.
Merge request reports
Activity
- Resolved by Ike Mulder
Timing run started, results will appear at the below URLs
It gives serious performance improvements on individual files in gpfsl, e.g., -30% on
gpfsl-examples/lock/proof_ticket_lock_gps.v
, and no performance regressions.Let's try the version where we also have strategy for cmra.
Edited by Robbert KrebbersRe-run data will appear at:
Edited by Ralf JungThe additional
Strategy
command forcmra
does not seem to have much effect on performance for these projects. My initial guess was that people apparently do not writetyR
iftyO
suffices. But the blowup in unification time also seems much smaller than what happens forucmra
:From iris.algebra Require Import frac_auth agree numbers auth list. From iris.base_logic Require Import lib.own. From iris.proofmode Require Import proofmode. Section weird_slow_qed. Lemma cmra_ofe_10 `{!inG Σ $ agreeR $ optionR $ optionR $ optionR $ optionR $ optionR $ optionR $ optionR $ optionR $ optionR $ optionR $ natO} γ (n : nat) : own γ (to_agree $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some n) ⊢ own γ (to_agree $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some n). Proof. time iIntros "$". Time Qed. (* 0.02 *) Lemma cmra_ofe_11 `{!inG Σ $ agreeR $ optionO $ optionO $ optionO $ optionO $ optionO $ optionO $ optionO $ optionO $ optionO $ optionO $ natO} γ (n : nat) : own γ (to_agree $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some n) ⊢ own γ (to_agree $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some $ Some n). Proof. time iIntros "$". Time Qed. (* 0.005 *) End weird_slow_qed.
Also note that the
Strategy
command forucmra
does not actually fix the blowup in unification time, it just makes sure it becomes bad a bit later. The following takes too long to parse without theStrategy
, but even with the strategy,Qed.
still takes 1.4 seconds.Lemma slow_qed3 `{!inG Σ (frac_authUR $ frac_authUR $ frac_authUR $ agreeR $ natO)} γ1 (n : nat) : own γ1 (●F (●F (●F (to_agree n)))) ⊢ own γ1 (●F (●F (●F (to_agree n)))). Proof. time iIntros "$". Time Qed.
Also note that the
Strategy
command forucmra
does not actually fix the blowup in unification time, it just makes sure it becomes bad a bit later. The following takes too long to parse without theStrategy
, but even with the strategy,Qed.
still takes 1.4 seconds.So... what annotations are missing to make that fast? Or is that the wrong question to ask?
I would say it's best to merge this MR, while keeping in mind that it is only a band-aid (i.e. opening some tracking issue about this problem).
So... what annotations are missing to make that fast? Or is that the wrong question to ask?
I suspect just annotations cannot make it fast. I think the question to ask is:
How do we keep type-checking/unification fast for structures (like
ofe
,cmra
anducmra
) that have combinators (likeoptionUR : cmra → ucmra
) and coercions (likeucmra_cmraR : cmra → ucmra
), especially when stacking alot of these combinators?mentioned in issue #539
added 265 commits
-
6e1e6cea...f0e490d1 - 262 commits from branch
iris:master
- 5b0b111f - Add a strategy command for ucmra projections
- f060e6aa - Add Strategy command for cmra
- aab896fd - Added comment explaining why these particular constants are set to be expanded.
Toggle commit list-
6e1e6cea...f0e490d1 - 262 commits from branch
- Resolved by Ike Mulder