-
Notifications
You must be signed in to change notification settings - Fork 678
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
Refold before evar instantiation #19987
base: master
Are you sure you want to change the base?
Conversation
Until now, the algorithm unfolded terms blindly and instantiated an evar with whatever term was on the other side. Now, we remember the terms from the initial unification problem, and whenever we reach a problem of the form `?e = t`, we replace `t` with its initial version.
@coqbot bench |
🏁 Bench results:
INFO: failed to install coq-math-classes (dependency coq-bignums failed) 🐢 Top 25 slow downs┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 0.1330 4.1990 4.0660 3057.14% 1867 coq-metacoq-pcuic/pcuic/theories/PCUICSR.v.html │ │ 8.0710 11.0050 2.9340 36.35% 591 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/fundamental.v.html │ │ 8.0830 10.9440 2.8610 35.40% 581 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/fundamental.v.html │ │ 7.9850 10.8230 2.8380 35.54% 580 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/fundamental.v.html │ │ 0.2750 1.8080 1.5330 557.45% 177 coq-mathcomp-algebra/mathcomp/algebra/intdiv.v.html │ │ 0.0220 1.2510 1.2290 5586.36% 302 coq-metacoq-pcuic/pcuic/theories/PCUICCasesHelper.v.html │ │ 0.0210 1.1660 1.1450 5452.38% 435 coq-metacoq-pcuic/pcuic/theories/PCUICInductiveInversion.v.html │ │ 0.0450 1.0930 1.0480 2328.89% 1902 coq-metacoq-pcuic/pcuic/theories/PCUICSR.v.html │ │ 0.0140 1.0320 1.0180 7271.43% 1885 coq-metacoq-pcuic/pcuic/theories/PCUICSR.v.html │ │ 63.4600 64.4720 1.0120 1.59% 609 coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 0.0160 1.0210 1.0050 6281.25% 1861 coq-metacoq-pcuic/pcuic/theories/PCUICSR.v.html │ │ 0.0400 1.0360 0.9960 2490.00% 2065 coq-metacoq-pcuic/pcuic/theories/PCUICSR.v.html │ │ 0.0300 1.0080 0.9780 3260.00% 531 coq-metacoq-erasure/erasure/theories/ESubstitution.v.html │ │ 0.0060 0.9330 0.9270 15450.00% 3047 coq-metacoq-pcuic/pcuic/theories/PCUICExpandLetsCorrectness.v.html │ │ 0.0100 0.7910 0.7810 7810.00% 793 coq-metacoq-pcuic/pcuic/theories/PCUICCasesHelper.v.html │ │ 0.0300 0.8000 0.7700 2566.67% 126 coq-metacoq-pcuic/pcuic/theories/Typing/PCUICRenameTyp.v.html │ │ 46.3670 46.8170 0.4500 0.97% 110 coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ │ 10.3170 10.7330 0.4160 4.03% 325 coq-engine-bench-lite/coq/PerformanceDemos/one_step_reduction.v.html │ │ 0.0130 0.4270 0.4140 3184.62% 2483 coq-metacoq-pcuic/pcuic/theories/PCUICInductives.v.html │ │ 10.4990 10.9040 0.4050 3.86% 214 coq-engine-bench-lite/coq/PerformanceDemos/one_step_reduction.v.html │ │ 0.0190 0.3980 0.3790 1994.74% 769 coq-metacoq-pcuic/pcuic/theories/PCUICCasesHelper.v.html │ │ 0.0230 0.4010 0.3780 1643.48% 658 coq-metacoq-pcuic/pcuic/theories/PCUICCasesHelper.v.html │ │ 0.0170 0.3930 0.3760 2211.76% 792 coq-metacoq-pcuic/pcuic/theories/PCUICCasesHelper.v.html │ │ 0.0460 0.4090 0.3630 789.13% 676 coq-metacoq-pcuic/pcuic/theories/PCUICCasesHelper.v.html │ │ 0.0790 0.4380 0.3590 454.43% 84 coq-metacoq-pcuic/pcuic/theories/Typing/PCUICRenameTyp.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 17.8600 17.0050 -0.8550 -4.79% 32 coq-performance-tests-lite/src/pattern.v.html │ │ 42.6870 41.9860 -0.7010 -1.64% 834 coq-vst/veric/binop_lemmas4.v.html │ │ 38.6950 38.1530 -0.5420 -1.40% 224 coq-performance-tests-lite/PerformanceExperiments/rewrite_lift_lets_map.v.html │ │ 36.4320 36.0050 -0.4270 -1.17% 139 coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html │ │ 100.4130 100.0330 -0.3800 -0.38% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 100.5450 100.1960 -0.3490 -0.35% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 18.3110 18.0040 -0.3070 -1.68% 481 coq-verdi-raft/theories/RaftProofs/EndToEndLinearizability.v.html │ │ 0.6460 0.3680 -0.2780 -43.03% 333 coq-metacoq-pcuic/pcuic/theories/PCUICCasesHelper.v.html │ │ 0.5400 0.2810 -0.2590 -47.96% 133 coq-metacoq-pcuic/pcuic/theories/Typing/PCUICRenameTyp.v.html │ │ 8.5320 8.2950 -0.2370 -2.78% 673 coq-rewriter/src/Rewriter/Rewriter/Wf.v.html │ │ 39.0380 38.8140 -0.2240 -0.57% 236 coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap.v.html │ │ 31.2670 31.0520 -0.2150 -0.69% 97 coq-vst/veric/binop_lemmas5.v.html │ │ 0.1910 0.0020 -0.1890 -98.95% 343 coq-metacoq-erasure/erasure/theories/EWcbvEvalCstrsAsBlocksInd.v.html │ │ 11.4870 11.3010 -0.1860 -1.62% 126 coq-vst/veric/binop_lemmas6.v.html │ │ 4.7930 4.6080 -0.1850 -3.86% 2761 coq-metacoq-safechecker/safechecker/theories/PCUICTypeChecker.v.html │ │ 0.1710 0.0000 -0.1710 -100.00% 466 coq-metacoq-erasure/erasure/theories/EArities.v.html │ │ 11.4820 11.3140 -0.1680 -1.46% 410 coq-verdi-raft/theories/RaftProofs/LeaderLogsLogMatchingProof.v.html │ │ 0.5660 0.4030 -0.1630 -28.80% 9 coq-mathcomp-character/mathcomp/character/classfun.v.html │ │ 0.1670 0.0050 -0.1620 -97.01% 300 coq-metacoq-pcuic/pcuic/theories/PCUICCasesHelper.v.html │ │ 5.2680 5.1080 -0.1600 -3.04% 198 coq-compcert/x86/Op.v.html │ │ 0.1630 0.0030 -0.1600 -98.16% 115 coq-mathcomp-field/mathcomp/field/algebraics_fundamentals.v.html │ │ 38.9850 38.8260 -0.1590 -0.41% 236 coq-rewriter/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap.v.html │ │ 0.4330 0.2750 -0.1580 -36.49% 10 coq-mathcomp-character/mathcomp/character/vcharacter.v.html │ │ 9.9620 9.8060 -0.1560 -1.57% 496 coq-rewriter/src/Rewriter/Rewriter/Wf.v.html │ │ 0.1560 0.0010 -0.1550 -99.36% 236 coq-mathcomp-field/mathcomp/field/separable.v.html │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
There are some slowdowns to be investigated, especially the metacoq one seems too huge to be acceptable. |
rocq-prover/rocq#19987 refolds terms before using them to instantiate evars. There is one instance where we need to unfold by hand.
Until now, the algorithm unfolded terms blindly and instantiated an evar with whatever term was on the other side. Now, we remember the terms from the initial unification problem, and whenever we reach a problem of the form
?e = t
, we replacet
with its initial version.This PR does the minimal change that changes the behavior of the unification algorithm as intended, but this makes the control flow a bit awkward and some computations are done twice, which is a bit inefficient. Should I try to be a bit more aggressive and rewrite some of the code?
Fixes / closes #????
make doc_gram_rsts
.Overlays: