-
Notifications
You must be signed in to change notification settings - Fork 682
Refold before evar instantiation #19987
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
base: master
Are you sure you want to change the base?
Conversation
@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. |
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.
rocq-prover/rocq#19987 refolds terms before using them to instantiate evars. There is one instance where we need to unfold by hand.
MetaRocq/metarocq#1152 is only a small performance improvement, so I think we might as well retry the CI now. |
@coqbot bench |
🏁 Bench results:
INFO: failed to install rocq-mathcomp-ssreflect (dependency rocq-elpi failed) 🐢 Top 25 slow downs┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 0.186 1.31 1.1193 602.38% 170 coq-unimath/UniMath/ModelCategories/Generated/OneStepMonad.v.html │ │ 0.183 1.29 1.1115 606.64% 238 coq-unimath/UniMath/ModelCategories/Generated/OneStepMonadSmall.v.html │ │ 0.204 1.19 0.9903 485.35% 196 coq-unimath/UniMath/ModelCategories/Generated/OneStepMonad.v.html │ │ 200 201 0.8305 0.41% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 0.00368 0.718 0.7140 19390.66% 264 coq-hott/theories/Algebra/AbSES/PullbackFiberSequence.v.html │ │ 0.0183 0.684 0.6661 3642.66% 303 coq-unimath/UniMath/CategoryTheory/DisplayedCats/Fiberwise/DependentSums.v.html │ │ 0.0169 0.680 0.6631 3926.99% 301 coq-unimath/UniMath/CategoryTheory/DisplayedCats/Fiberwise/DependentProducts.v.html │ │ 0.179 0.780 0.6005 334.95% 380 coq-unimath/UniMath/CategoryTheory/DisplayedCats/Fiberwise/DependentProducts.v.html │ │ 0.0198 0.462 0.4424 2236.08% 369 coq-hott/theories/Algebra/AbSES/PullbackFiberSequence.v.html │ │ 42.476 42.918 0.4420 1.04% 834 coq-vst/veric/binop_lemmas4.v.html │ │ 7.41 7.80 0.3983 5.38% 604 coq-unimath/UniMath/CategoryTheory/EnrichedCats/Colimits/Examples/StructureEnrichedColimits.v.html │ │ 2.92 3.19 0.2651 9.07% 597 coq-unimath/UniMath/CategoryTheory/DisplayedCats/Examples/SetGroupoidComprehension.v.html │ │ 0.254 0.506 0.2519 99.10% 2011 coq-unimath/UniMath/CategoryTheory/ExactCategories/ExactCategories.v.html │ │ 0.274 0.522 0.2480 90.48% 2109 coq-unimath/UniMath/CategoryTheory/ExactCategories/ExactCategories.v.html │ │ 0.280 0.524 0.2439 87.13% 2093 coq-unimath/UniMath/CategoryTheory/ExactCategories/ExactCategories.v.html │ │ 0.267 0.510 0.2434 91.18% 2081 coq-unimath/UniMath/CategoryTheory/ExactCategories/ExactCategories.v.html │ │ 0.00170 0.240 0.2388 14070.12% 159 coq-unimath/UniMath/CategoryTheory/DisplayedCats/Fiberwise/DependentProducts.v.html │ │ 0.00157 0.235 0.2337 14892.22% 160 coq-unimath/UniMath/CategoryTheory/DisplayedCats/Fiberwise/DependentSums.v.html │ │ 12.3 12.5 0.1983 1.61% 930 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html │ │ 0.0664 0.242 0.1752 263.85% 794 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERMonomorphisms.v.html │ │ 0.0636 0.237 0.1732 272.39% 848 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERMonomorphisms.v.html │ │ 0.121 0.283 0.1612 132.77% 1227 coq-unimath/UniMath/CategoryTheory/DisplayedCats/Examples/Reindexing.v.html │ │ 8.28 8.43 0.1506 1.82% 648 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html │ │ 8.57 8.72 0.1504 1.75% 950 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html │ │ 0.0523 0.197 0.1450 277.33% 776 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERMonomorphisms.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 66.1 62.0 -4.1371 -6.26% 609 coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 19.2 18.8 -0.3602 -1.88% 481 coq-verdi-raft/theories/RaftProofs/EndToEndLinearizability.v.html │ │ 16.8 16.4 -0.3204 -1.91% 905 coq-unimath/UniMath/ModelCategories/Generated/LNWFSCocomplete.v.html │ │ 11.8 11.5 -0.2711 -2.31% 410 coq-verdi-raft/theories/RaftProofs/LeaderLogsLogMatchingProof.v.html │ │ 10.1 9.83 -0.2493 -2.47% 325 coq-engine-bench-lite/coq/PerformanceDemos/one_step_reduction.v.html │ │ 10.2 9.96 -0.2416 -2.37% 214 coq-engine-bench-lite/coq/PerformanceDemos/one_step_reduction.v.html │ │ 101 101 -0.2048 -0.20% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 26.4 26.2 -0.1946 -0.74% 375 coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html │ │ 0.188 0.000650 -0.1873 -99.65% 14865 coq-coqprime/src/Coqprime/examples/BasePrimes.v.html │ │ 36.6 36.4 -0.1869 -0.51% 139 coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html │ │ 3.753 3.57 -0.1830 -4.88% 126 coq-vst/veric/Clight_mapsto_memory_block.v.html │ │ 1.32 1.17 -0.1531 -11.61% 196 coq-unimath/UniMath/HomologicalAlgebra/KATriangulated.v.html │ │ 48.6 48.5 -0.1433 -0.29% 376 coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html │ │ 7.67 7.53 -0.1412 -1.84% 420 coq-engine-bench-lite/coq/PerformanceDemos/one_step_reduction.v.html │ │ 24.0 23.9 -0.1368 -0.57% 558 coq-bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html │ │ 101 101 -0.1343 -0.13% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 7.81 7.68 -0.1260 -1.61% 31 coq-performance-tests-lite/src/pattern.v.html │ │ 0.114 0.00231 -0.1119 -97.97% 202 coq-iris-examples/theories/logatom/counter_with_backup/counter_proof.v.html │ │ 0.134 0.0228 -0.1108 -82.91% 287 coq-iris-examples/theories/logrel/F_mu_ref_conc/binary/rules.v.html │ │ 4.69 4.58 -0.1100 -2.35% 116 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html │ │ 0.110 0.00242 -0.1081 -97.81% 195 coq-iris-examples/theories/logatom/herlihy_wing_queue/hwq.v.html │ │ 0.119 0.0121 -0.1068 -89.83% 94 coq-iris-examples/theories/hocap/fg_bag.v.html │ │ 0.138 0.0320 -0.1060 -76.83% 129 coq-iris-examples/theories/hocap/cg_bag.v.html │ │ 0.109 0.00337 -0.1059 -96.91% 333 coq-iris-examples/theories/locks/array_based_queuing_lock/abql.v.html │ │ 0.122 0.0167 -0.1058 -86.40% 226 coq-iris-examples/theories/logatom/snapshot/atomic_snapshot.v.html │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
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: