-
Notifications
You must be signed in to change notification settings - Fork 682
Set some basic rewriting primitives in Type opaque for TC search. #18910
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
Set some basic rewriting primitives in Type opaque for TC search. #18910
Conversation
@coqbot bench |
🏁 Bench results:
INFO: failed to install coq-metacoq-safechecker (dependency coq-metacoq-pcuic failed) 🐢 Top 25 slow downs┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 49.5620 50.9320 1.3700 2.76% 558 coq-bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html │ │ 62.4160 63.7700 1.3540 2.17% 609 coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 2.3220 3.4280 1.1060 47.63% 490 coq-stdlib/Reals/Cauchy/ConstructiveCauchyRealsMult.v.html │ │ 153.0510 153.7850 0.7340 0.48% 1190 coq-unimath/UniMath/CategoryTheory/GrothendieckConstruction/IsPullback.v.html │ │ 2.3770 3.1090 0.7320 30.80% 487 coq-stdlib/Numbers/HexadecimalFacts.v.html │ │ 235.7560 236.3610 0.6050 0.26% 141 coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html │ │ 95.4390 96.0340 0.5950 0.62% 103 coq-fiat-crypto-with-bedrock/src/Arithmetic/BarrettReduction.v.html │ │ 39.2410 39.7920 0.5510 1.40% 338 coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html │ │ 34.0880 34.5290 0.4410 1.29% 1333 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvFunctions.v.html │ │ 26.9680 27.3760 0.4080 1.51% 147 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html │ │ 82.0490 82.4500 0.4010 0.49% 48 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html │ │ 27.4000 27.6960 0.2960 1.08% 68 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/VerifyDecode.v.html │ │ 8.5870 8.8470 0.2600 3.03% 673 coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Wf.v.html │ │ 46.8330 47.0780 0.2450 0.52% 926 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoor.v.html │ │ 16.9180 17.1630 0.2450 1.45% 12 coq-fourcolor/theories/job550to553.v.html │ │ 15.0840 15.3200 0.2360 1.56% 613 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlattenExpr.v.html │ │ 23.0370 23.2690 0.2320 1.01% 12 coq-fourcolor/theories/job554to562.v.html │ │ 14.8600 15.0830 0.2230 1.50% 611 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlattenExpr.v.html │ │ 0.5580 0.7710 0.2130 38.17% 590 coq-stdlib/Strings/Byte.v.html │ │ 25.1570 25.3690 0.2120 0.84% 24 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/MultiRetSplit.v.html │ │ 17.7980 18.0070 0.2090 1.17% 32 coq-performance-tests-lite/src/pattern.v.html │ │ 3.1280 3.3320 0.2040 6.52% 142 coq-vst/veric/Clight_mapsto_memory_block.v.html │ │ 0.4320 0.6330 0.2010 46.53% 21 coq-stdlib/MSets/MSetPositive.v.html │ │ 0.2990 0.4900 0.1910 63.88% 1364 coq-stdlib/FSets/FMapAVL.v.html │ │ 46.3640 46.5520 0.1880 0.41% 110 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 50.9090 49.4890 -1.4200 -2.79% 558 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html │ │ 1.8620 0.7780 -1.0840 -58.22% 736 coq-stdlib/Reals/Cauchy/ConstructiveCauchyReals.v.html │ │ 133.9900 132.9530 -1.0370 -0.77% 22 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html │ │ 99.2520 98.2620 -0.9900 -1.00% 376 coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html │ │ 73.3430 72.7190 -0.6240 -0.85% 905 coq-unimath/UniMath/ModelCategories/Generated/LNWFSCocomplete.v.html │ │ 3.0100 2.4630 -0.5470 -18.17% 102 coq-fiat-parsers/src/Parsers/ParserImplementation.v.html │ │ 2.5800 2.0810 -0.4990 -19.34% 32 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html │ │ 29.6700 29.1970 -0.4730 -1.59% 12 coq-fourcolor/theories/job001to106.v.html │ │ 81.3220 80.8780 -0.4440 -0.55% 365 coq-mathcomp-odd-order/theories/PFsection4.v.html │ │ 44.0950 43.6750 -0.4200 -0.95% 827 coq-vst/veric/binop_lemmas4.v.html │ │ 25.1070 24.6890 -0.4180 -1.66% 12 coq-fourcolor/theories/job499to502.v.html │ │ 253.6920 253.3030 -0.3890 -0.15% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 2.0140 1.6370 -0.3770 -18.72% 20 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html │ │ 1.1940 0.8220 -0.3720 -31.16% 384 coq-stdlib/MSets/MSetAVL.v.html │ │ 100.4600 100.0960 -0.3640 -0.36% 20 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html │ │ 37.4610 37.0980 -0.3630 -0.97% 548 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/MMIO.v.html │ │ 0.9170 0.5570 -0.3600 -39.26% 170 coq-stdlib/Numbers/HexadecimalNat.v.html │ │ 1.2000 0.8480 -0.3520 -29.33% 467 coq-stdlib/Numbers/DecimalFacts.v.html │ │ 28.8620 28.5120 -0.3500 -1.21% 32 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/MontgomeryLadderRISCV.v.html │ │ 0.4880 0.1450 -0.3430 -70.29% 915 coq-stdlib/Reals/Cauchy/ConstructiveCauchyReals.v.html │ │ 67.2230 66.8830 -0.3400 -0.51% 368 coq-mathcomp-odd-order/theories/PFsection4.v.html │ │ 0.6620 0.3490 -0.3130 -47.28% 868 coq-stdlib/MSets/MSetRBT.v.html │ │ 0.5130 0.2090 -0.3040 -59.26% 12 coq-stdlib/MSets/MSets.v.html │ │ 3.4190 3.1260 -0.2930 -8.57% 122 coq-stdlib/setoid_ring/Ncring_initial.v.html │ │ 18.4480 18.1630 -0.2850 -1.54% 12 coq-fourcolor/theories/job207to214.v.html │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
🔴 CI failures at commit 11d9f29 without any failure in the test-suite ✔️ Corresponding jobs for the base commit c481f44 succeeded ❔ Ask me to try to extract minimal test cases that can be added to the test-suite 🏃
|
The stdlib speed up is real, this is CReals rewriting going way faster. |
We guide unification a bit to prevent TC resolution from relying on a previously transparent Coq primitive.
The fix in category-theory is a one-liner, so I think this is a safe change. |
11d9f29
to
c6af6a2
Compare
@coqbot bench |
🏁 Bench results:
🐢 Top 25 slow downs┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 2.3570 3.6090 1.2520 53.12% 490 coq-stdlib/Reals/Cauchy/ConstructiveCauchyRealsMult.v.html │ │ 62.4240 63.4300 1.0060 1.61% 609 coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 95.4920 96.2770 0.7850 0.82% 103 coq-fiat-crypto-with-bedrock/src/Arithmetic/BarrettReduction.v.html │ │ 38.7140 39.4370 0.7230 1.87% 224 coq-performance-tests-lite/PerformanceExperiments/rewrite_lift_lets_map.v.html │ │ 99.8420 100.5080 0.6660 0.67% 20 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html │ │ 66.2100 66.8730 0.6630 1.00% 27 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html │ │ 41.6880 42.2760 0.5880 1.41% 139 coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html │ │ 28.8750 29.3770 0.5020 1.74% 12 coq-fourcolor/theories/job001to106.v.html │ │ 21.3300 21.8070 0.4770 2.24% 40 coq-fiat-crypto-with-bedrock/src/PushButtonSynthesis/SolinasReductionReificationCache.v.html │ │ 132.8640 133.2640 0.4000 0.30% 22 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html │ │ 24.0370 24.3610 0.3240 1.35% 85 coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/AffineProofs.v.html │ │ 25.4090 25.7230 0.3140 1.24% 345 coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/XZProofs.v.html │ │ 0.3280 0.6070 0.2790 85.06% 868 coq-stdlib/MSets/MSetRBT.v.html │ │ 43.8140 44.0750 0.2610 0.60% 827 coq-vst/veric/binop_lemmas4.v.html │ │ 17.6950 17.9530 0.2580 1.46% 32 coq-performance-tests-lite/src/pattern.v.html │ │ 23.4860 23.7310 0.2450 1.04% 12 coq-fourcolor/theories/job231to234.v.html │ │ 15.3680 15.6130 0.2450 1.59% 417 coq-fiat-crypto-with-bedrock/src/Bedrock/Group/ScalarMult/MontgomeryLadder.v.html │ │ 25.7250 25.9520 0.2270 0.88% 129 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/Projective.v.html │ │ 3.7770 4.0030 0.2260 5.98% 275 coq-category-theory/Construction/Comma/Adjunction.v.html │ │ 7.3130 7.5380 0.2250 3.08% 356 coq-rewriter/src/Rewriter/Rewriter/Wf.v.html │ │ 25.0700 25.2900 0.2200 0.88% 24 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/MultiRetSplit.v.html │ │ 9.5680 9.7790 0.2110 2.21% 79 coq-rewriter/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap.v.html │ │ 0.0050 0.2120 0.2070 4140.00% 324 coq-metacoq-pcuic/pcuic/theories/Bidirectional/BDToPCUIC.v.html │ │ 0.0130 0.2190 0.2060 1584.62% 161 coq-metacoq-pcuic/pcuic/theories/PCUICPrincipality.v.html │ │ 0.0520 0.2530 0.2010 386.54% 41 coq-metacoq-pcuic/pcuic/theories/Bidirectional/BDStrengthening.v.html │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 256.7870 253.8340 -2.9530 -1.15% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 1.4880 0.0450 -1.4430 -96.98% 81 coq-metacoq-safechecker/safechecker/theories/PCUICWfReduction.v.html │ │ 180.7430 179.5320 -1.2110 -0.67% 233 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/DecodeByExtension.v.html │ │ 1.8270 0.7300 -1.0970 -60.04% 736 coq-stdlib/Reals/Cauchy/ConstructiveCauchyReals.v.html │ │ 94.9910 94.3720 -0.6190 -0.65% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 11.4670 10.9200 -0.5470 -4.77% 55 coq-category-theory/Construction/Comma/Natural/Transformation.v.html │ │ 94.8030 94.2760 -0.5270 -0.56% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 2.9210 2.4280 -0.4930 -16.88% 102 coq-fiat-parsers/src/Parsers/ParserImplementation.v.html │ │ 81.3270 80.8390 -0.4880 -0.60% 48 coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html │ │ 67.1310 66.7100 -0.4210 -0.63% 1629 coq-metacoq-pcuic/pcuic/theories/PCUICSR.v.html │ │ 10.5580 10.1680 -0.3900 -3.69% 496 coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Wf.v.html │ │ 7.0510 6.6760 -0.3750 -5.32% 63 coq-category-theory/Construction/Comma/Natural/Transformation.v.html │ │ 38.0330 37.6830 -0.3500 -0.92% 3 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/bedrock2_fiat_crypto.v.html │ │ 26.7220 26.3850 -0.3370 -1.26% 35 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/MontgomeryLadderRISCV.v.html │ │ 22.2420 21.9450 -0.2970 -1.34% 1073 coq-metacoq-safechecker/safechecker/theories/PCUICSafeReduce.v.html │ │ 29.0000 28.7200 -0.2800 -0.97% 79 coq-rewriter/src/Rewriter/Rewriter/Examples/PerfTesting/SieveOfEratosthenes.v.html │ │ 1.2600 0.9820 -0.2780 -22.06% 36 coq-category-theory/Structure/Pullback/Limit.v.html │ │ 3.3430 3.0650 -0.2780 -8.32% 77 coq-category-theory/Structure/Monoidal/Compose.v.html │ │ 25.8400 25.5780 -0.2620 -1.01% 12 coq-fourcolor/theories/job399to438.v.html │ │ 8.8070 8.5470 -0.2600 -2.95% 149 coq-category-theory/Structure/Monoid.v.html │ │ 36.5930 36.3410 -0.2520 -0.69% 2 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/fiat_crypto.v.html │ │ 3.4160 3.1680 -0.2480 -7.26% 122 coq-stdlib/setoid_ring/Ncring_initial.v.html │ │ 4.7670 4.5200 -0.2470 -5.18% 5 coq-fiat-crypto-with-bedrock/src/Assembly/Parse/Examples/fiat_p256_mul_optimised_seed11.v.html │ │ 1.0920 0.8650 -0.2270 -20.79% 2242 coq-corn/reals/stdlib/CMTIntegrableFunctions.v.html │ │ 0.3780 0.1520 -0.2260 -59.79% 915 coq-stdlib/Reals/Cauchy/ConstructiveCauchyReals.v.html │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
Should be ready now. |
test-suite/bugs/bug_7675_3.v
Outdated
@@ -58,19 +58,20 @@ Ltac test S b1 b2 b3 b4 := | |||
unfold arrow, Basics.arrow; now rewrite <- HR | clear Ht ]. | |||
|
|||
Goal True. | |||
test Ri true true true true. | |||
Proof. | |||
(* test Ri true true true true. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't these be edited to fit the new result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test doesn't make sense now. I could just remove them if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the test so I don't know why it wouldn't make sense, removing is ok I guess
cc @olaure01 who wrote the test AFAICT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original goal of the test was to track different behaviors between setoid rewriting in Prop and in Type, but I think they know behave similarly on these examples.
The corresponding Prop primitives are already set opaque in Classes.Init, hence I think this is an overview. These low-level primitives being transparent mean that TC search when setoid rewriting in Type fires off a crapload of search branches that should not be there to begin with. Hopefully nobody relies on that in the wild.
236e681
to
73c46f4
Compare
Just removed the commented out examples from the test. |
@coqbot merge now |
The corresponding Prop primitives are already set opaque in Classes.Init, hence I think this is an oversight. These low-level primitives being transparent mean that TC search when setoid rewriting in Type fires off a crapload of search branches that should not be there to begin with. Hopefully nobody relies on that in the wild.
cc @mattam82
Backward compatible overlay: