Repository navigation
Resolve transparent heads in hint dnets through cached head summaries. - #22934
Conversation
|
@coqbot bench |
|
@coqbot bench |
|
We tried this a while ago on our internal prefiltering step. Transparency is by far the biggest issue we have with typeclass search. Unfortunately our prefiltering really only deals in patterns and let's just say that writing reduction rules for patterns wasn't fun. (And most of the slow TC search that was left actually sidesteps our prefiltering for one reason or another). I am glad to see that a proper implementation directly in rocq seems to work. @gmalecha used to call this idea "translucency". It's a good term, I think. EDIT: I tested this on our codebase and it's a 2.5% instruction count improvement |
|
🏁 Bench results: 🐢 Top 25 slow downs┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 56.5 58.6 2.1031 3.72% 3 coq-performance-tests-lite/PerformanceExperiments/typeclass_reification_let_in_HOAS/_0_SuperFast.v.html │ │ 46.9 48.7 1.7944 3.83% 4 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/WithBedrock/fiat_crypto.v.html │ │ 0. 1.462 1.4620 inf% 1080 coq-compcert/backend/Stackingproof.v.html │ │ 38.7 39.8 1.1572 2.99% 116 coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ │ 31.1 32.2 1.1499 3.70% 96 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/VerifyDecode.v.html │ │ 39.0 39.8 0.8044 2.06% 116 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ │ 32.7 33.1 0.4584 1.40% 197 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 20.9 21.3 0.3977 1.90% 254 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/modinv/beeu_shrtz.v.html │ │ 46.2 46.6 0.3693 0.80% 4 coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/bedrock2_fiat_crypto.v.html │ │ 243 244 0.2771 0.11% 141 coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html │ │ 45.5 45.8 0.2709 0.60% 376 coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html │ │ 42.8 43.1 0.2667 0.62% 52 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 42.5 42.7 0.2489 0.59% 52 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 0.0150 0.258 0.2430 1619.82% 371 coq-category-theory/Instance/Mod/Quotient/Isomorphism.v.html │ │ 65.0 65.2 0.2396 0.37% 279 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 18.8 19.0 0.2388 1.27% 31 coq-engine-bench-lite/coq/PerformanceDemos/pattern.v.html │ │ 1.08 1.32 0.2381 21.98% 331 rocq-metarocq-erasure/_build/default/theories/Erasure/Typed/ExtractionCorrectness.v.html │ │ 0.0200 0.251 0.2309 1153.23% 346 coq-hott/theories/Categories/Category/Sigma/Univalent.v.html │ │ 5.58 5.80 0.2250 4.03% 650 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/New/WordByWordMontgomery.v.html │ │ 5.34 5.56 0.2154 4.03% 670 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/New/WordByWordMontgomery.v.html │ │ 16.7 17.0 0.2104 1.26% 670 coq-performance-tests-lite/src/Nia.v.html │ │ 11.2 11.4 0.1986 1.78% 531 coq-performance-tests-lite/src/Nia.v.html │ │ 27.1 27.3 0.1954 0.72% 145 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html │ │ 5.20 5.40 0.1925 3.70% 664 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/New/WordByWordMontgomery.v.html │ │ 5.44 5.63 0.1912 3.51% 649 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/New/WordByWordMontgomery.v.html │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 54.4 48.8 -5.5465 -10.20% 564 rocq-metarocq-erasure/_build/default/theories/Erasure/EConstantsToValues.v.html │ │ 6.98 2.66 -4.3177 -61.88% 3022 coq-fiat-crypto-with-bedrock/src/Assembly/EquivalenceProofs.v.html │ │ 14.7 11.6 -3.0565 -20.79% 221 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlining.v.html │ │ 3.40 0.861 -2.5438 -74.71% 682 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlining.v.html │ │ 3.61 1.12 -2.4966 -69.08% 643 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlining.v.html │ │ 4.03 1.81 -2.2222 -55.09% 428 rocq-metarocq-erasure/_build/default/theories/Erasure/EConstantsToValues.v.html │ │ 3.85 1.69 -2.1639 -56.17% 444 rocq-metarocq-erasure/_build/default/theories/Erasure/EConstantsToValues.v.html │ │ 3.53 1.54 -1.9890 -56.42% 322 rocq-metarocq-erasure/_build/default/theories/Erasure/EUnboxing.v.html │ │ 3.31 1.46 -1.8532 -55.93% 250 rocq-metarocq-erasure/_build/default/theories/Erasure/EUnboxing.v.html │ │ 2.64 0.806 -1.8348 -69.48% 438 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlining.v.html │ │ 1.89 0.506 -1.3813 -73.21% 62 rocq-metarocq-erasure/_build/default/theories/Erasure/EImplementLazyForce.v.html │ │ 1.86 0.509 -1.3561 -72.71% 66 rocq-metarocq-erasure/_build/default/theories/Erasure/EImplementBox.v.html │ │ 34.3 33.1 -1.2053 -3.52% 913 coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html │ │ 284 282 -1.1054 -0.39% 3 coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap/_10_SuperFast.v.html │ │ 13.6 12.5 -1.0823 -7.96% 345 coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/XZProofs.v.html │ │ 1.28 0.247 -1.0279 -80.60% 579 coq-color/Term/Lambda/LCompClos.v.html │ │ 1.60 0.708 -0.8875 -55.62% 200 coq-iris-examples/theories/hocap/concurrent_runners.v.html │ │ 1.04 0.200 -0.8441 -80.86% 1678 rocq-metarocq-pcuic/_build/default/theories/PCUIC/PCUICSigmaCalculus.v.html │ │ 0.944 0.165 -0.7798 -82.57% 1079 rocq-metarocq-template/_build/default/theories/Template/EtaExpand.v.html │ │ 3.16 2.39 -0.7668 -24.30% 748 rocq-metarocq-erasure/_build/default/theories/Erasure/EUnboxing.v.html │ │ 0.891 0.150 -0.7405 -83.14% 365 rocq-metarocq-pcuic/_build/default/theories/PCUIC/Conversion/PCUICInstConv.v.html │ │ 0.855 0.123 -0.7322 -85.66% 1910 rocq-metarocq-pcuic/_build/default/theories/PCUIC/PCUICParallelReductionConfluence.v.html │ │ 11.1 10.4 -0.7308 -6.57% 2325 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvFunctions.v.html │ │ 1.06 0.344 -0.7152 -67.50% 790 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlineProjections.v.html │ │ 6.97 6.26 -0.7092 -10.17% 868 rocq-metarocq-erasure/_build/default/theories/Erasure/EUnboxing.v.html │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
|
One file failed in my test on our code base. Here's a minimized reproducer: It works on master but not in this branch. |
|
@Janno it seems to be due to a bug in master uncovered by this PR, I'll open an issue and another PR. |
|
🏁 Bench results: 🐢 Top 25 slow downs┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 2.65 2.71 0.0632 2.39% 90 rocq-iris/iris/program_logic/ectx_lifting.v.html │ │ 0.000791 0.0543 0.0535 6761.19% 31 rocq-iris/iris/base_logic/lib/mono_list.v.html │ │ 0.000964 0.0524 0.0514 5335.48% 59 rocq-iris/iris/base_logic/lib/own.v.html │ │ 0.000870 0.0517 0.0509 5847.82% 21 rocq-iris/iris/base_logic/lib/na_invariants.v.html │ │ 0.00172 0.0522 0.0505 2930.72% 8 rocq-iris/iris/base_logic/lib/invariants.v.html │ │ 0.00124 0.0509 0.0497 4002.82% 16 rocq-iris/iris/base_logic/lib/saved_prop.v.html │ │ 0.00671 0.0562 0.0495 737.14% 16 rocq-iris-examples/theories/logrel/F_mu_ref_conc/lang.v.html │ │ 0.000883 0.0499 0.0491 5556.63% 17 rocq-iris/iris/base_logic/lib/ghost_map.v.html │ │ 0.000419 0.0494 0.0490 11690.93% 40 rocq-iris/iris/base_logic/lib/later_credits.v.html │ │ 0.000284 0.0493 0.0490 17247.54% 58 rocq-metarocq-template-pcuic/_build/default/theories/TemplatePCUIC/PCUICTransform.v.html │ │ 0.000858 0.0471 0.0463 5395.10% 37 rocq-iris/iris/base_logic/lib/gset_bij.v.html │ │ 0.0168 0.0608 0.0440 261.19% 115 rocq-iris/iris/proofmode/environments.v.html │ │ 0.0110 0.0546 0.0435 394.85% 13 rocq-iris/iris/proofmode/class_instances_updates.v.html │ │ 0.000521 0.0407 0.0401 7705.95% 288 rocq-iris/iris/proofmode/classes.v.html │ │ 0.00549 0.0455 0.0400 728.16% 18 rocq-iris/iris/proofmode/class_instances_later.v.html │ │ 0.0214 0.0607 0.0394 183.98% 15 rocq-iris/iris/proofmode/class_instances_frame.v.html │ │ 0.000482 0.0380 0.0375 7776.76% 87 rocq-iris/iris/bi/monpred.v.html │ │ 0.00500 0.0411 0.0361 722.36% 18 rocq-iris/iris/proofmode/class_instances_plainly.v.html │ │ 0.000243 0.0352 0.0349 14365.84% 186 rocq-iris/iris/bi/updates.v.html │ │ 0.00113 0.0316 0.0304 2680.70% 92 rocq-iris/iris/bi/big_op.v.html │ │ 0.00633 0.0338 0.0275 433.89% 112 rocq-iris/iris/algebra/dyn_reservation_map.v.html │ │ 0.0263 0.0525 0.0262 99.67% 28 rocq-iris/iris/base_logic/derived.v.html │ │ 0.0239 0.0499 0.0259 108.30% 21 rocq-iris/iris/base_logic/proofmode.v.html │ │ 0.00123 0.0252 0.0240 1944.48% 35 rocq-iris/iris/algebra/gmap.v.html │ │ 0.00334 0.0262 0.0228 681.82% 137 rocq-iris/iris/program_logic/ectxi_language.v.html │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 24.2 18.9 -5.3782 -22.19% 359 rocq-iris/iris/algebra/view.v.html │ │ 1.16 0.280 -0.8824 -75.90% 795 rocq-metarocq-template-pcuic/_build/default/theories/TemplatePCUIC/TemplateToPCUICWcbvEval.v.html │ │ 1.69 0.972 -0.7217 -42.60% 87 rocq-iris/iris/program_logic/weakestpre.v.html │ │ 1.71 0.997 -0.7111 -41.64% 119 rocq-iris/iris/program_logic/weakestpre.v.html │ │ 1.63 0.991 -0.6402 -39.26% 130 rocq-iris/iris/program_logic/weakestpre.v.html │ │ 1.39 0.769 -0.6177 -44.55% 199 rocq-iris-examples/theories/hocap/concurrent_runners.v.html │ │ 1.30 0.722 -0.5733 -44.26% 16 rocq-iris-examples/theories/logrel/F_mu_ref_conc/binary/examples/stack/stack_rules.v.html │ │ 0.923 0.513 -0.4098 -44.40% 137 rocq-iris/iris/base_logic/lib/later_credits.v.html │ │ 0.530 0.264 -0.2660 -50.22% 13 rocq-iris-examples/theories/logrel/F_mu_ref_conc/binary/examples/stack/stack_rules.v.html │ │ 0.382 0.155 -0.2269 -59.42% 2657 rocq-metarocq-template-pcuic/_build/default/theories/TemplatePCUIC/TemplateToPCUICCorrectness.v.html │ │ 0.443 0.241 -0.2019 -45.59% 44 rocq-iris-examples/theories/concurrent_stacks/concurrent_stack1.v.html │ │ 0.430 0.239 -0.1911 -44.48% 251 rocq-iris-examples/theories/concurrent_stacks/concurrent_stack2.v.html │ │ 0.432 0.243 -0.1892 -43.79% 69 rocq-iris-examples/theories/lecture_notes/lists_guarded.v.html │ │ 0.433 0.246 -0.1868 -43.14% 89 rocq-iris/iris/base_logic/lib/invariants.v.html │ │ 0.447 0.268 -0.1795 -40.14% 97 rocq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.412 0.241 -0.1715 -41.62% 66 rocq-iris-examples/theories/logrel/F_mu_ref_conc/unary/logrel.v.html │ │ 0.395 0.239 -0.1558 -39.44% 195 rocq-iris-examples/theories/hocap/concurrent_runners.v.html │ │ 0.377 0.236 -0.1414 -37.50% 71 rocq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ │ 0.297 0.156 -0.1406 -47.40% 57 rocq-iris/iris/program_logic/total_weakestpre.v.html │ │ 0.913 0.778 -0.1343 -14.71% 285 rocq-iris-examples/theories/spanning_tree/spanning.v.html │ │ 0.211 0.0855 -0.1251 -59.39% 201 rocq-iris/iris/program_logic/ownp.v.html │ │ 0.433 0.310 -0.1233 -28.47% 157 rocq-iris/iris/base_logic/lib/own.v.html │ │ 0.340 0.218 -0.1221 -35.88% 39 rocq-iris/iris/base_logic/lib/na_invariants.v.html │ │ 0.293 0.173 -0.1198 -40.94% 81 rocq-iris/iris/program_logic/total_adequacy.v.html │ │ 0.253 0.137 -0.1157 -45.79% 61 rocq-iris-examples/theories/logrel/F_mu_ref_conc/binary/logrel.v.html │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
|
I don't see any CI or bench failures despite some behavioral changes around Transparency(* BUG 1: transparent constant unfolded by a head summary vs. a constant that is opaque
in the db's transparent state but has a Def body. auto/eauto/trivial convert closed
terms with full transparency, so [c] and [f 0] unify, but the dnet now labels them
differently ([c] vs [S]) and drops the hint. *)
Inductive V : nat -> Prop := .
Inductive Wp : nat * nat -> Prop := .
Definition f (x : nat) := S x.
Definition k (x : nat) := f x.
Definition c := S 0.
Axiom h_f0 : V (f 0). (* closed pattern headed by a TRANSPARENT constant *)
Axiom h_c : V c. (* closed pattern headed by an OPAQUE (in the db) Def constant *)
Axiom h_S0 : V (S 0).
Axiom hp : Wp (c, 1).
Create HintDb tt discriminated. (* only f and k transparent; c opaque *)
Hint Constants Opaque : tt.
Hint Transparent f k : tt.
Create HintDb ctl discriminated. (* control: no transparent constant in the hint *)
Hint Constants Opaque : ctl.
Hint Resolve h_S0 : ctl.
(* ---- A. hint V (f 0) ; goal V c *)
Hint Resolve h_f0 : tt.
(* A1 auto: hint V (f 0), goal V c
expected: old=OK branch=FAIL <== REGRESSION *)
Goal V c. first [solve [auto with tt nocore] | idtac "FAIL [A1 auto: hint V (f 0), goal V c] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* A2 eauto: hint V (f 0), goal V c
expected: old=OK branch=FAIL <== REGRESSION *)
Goal V c. first [solve [eauto with tt nocore] | idtac "FAIL [A2 eauto: hint V (f 0), goal V c] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* A3 trivial: hint V (f 0), goal V c
expected: old=OK branch=FAIL <== REGRESSION *)
Goal V c. first [solve [trivial with tt nocore] | idtac "FAIL [A3 trivial: hint V (f 0), goal V c] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* A4 typeclasses eauto: hint V (f 0), goal V c
expected: old=FAIL branch=FAIL (not a regression) *)
Goal V c. first [solve [typeclasses eauto with tt nocore] | idtac "FAIL [A4 typeclasses eauto: hint V (f 0), goal V c] -- same as old (fails in both)"]. Abort.
(* A5 CONTROL auto: hint V (S 0) (no transparent const), goal V c
expected: old=FAIL branch=FAIL (not a regression) *)
Goal V c. first [solve [auto with ctl nocore] | idtac "FAIL [A5 CONTROL auto: hint V (S 0) (no transparent const), goal V c] -- same as old (fails in both)"]. Abort.
(* ---- B. hint V c ; goal V (f 0) (mirror: the opaque constant is in the hint) *)
Create HintDb tb discriminated.
Hint Constants Opaque : tb.
Hint Transparent f k : tb.
Hint Resolve h_c hp : tb.
(* B1 auto: hint V c, goal V (f 0)
expected: old=OK branch=FAIL <== REGRESSION *)
Goal V (f 0). first [solve [auto with tb nocore] | idtac "FAIL [B1 auto: hint V c, goal V (f 0)] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* B2 auto: hint V c, goal V (k 0) (two unfoldings)
expected: old=OK branch=FAIL <== REGRESSION *)
Goal V (k 0). first [solve [auto with tb nocore] | idtac "FAIL [B2 auto: hint V c, goal V (k 0) (two unfoldings)] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* B3 eauto: hint V c, goal V (f 0)
expected: old=OK branch=FAIL <== REGRESSION *)
Goal V (f 0). first [solve [eauto with tb nocore] | idtac "FAIL [B3 eauto: hint V c, goal V (f 0)] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* B4 trivial: hint V c, goal V (f 0)
expected: old=OK branch=FAIL <== REGRESSION *)
Goal V (f 0). first [solve [trivial with tb nocore] | idtac "FAIL [B4 trivial: hint V c, goal V (f 0)] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* B5 auto: hint Wp (c,1), goal Wp (f 0, 1) (nested occurrence)
expected: old=OK branch=FAIL <== REGRESSION *)
Goal Wp (f 0, 1). first [solve [auto with tb nocore] | idtac "FAIL [B5 auto: hint Wp (c,1), goal Wp (f 0, 1) (nested occurrence)] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.eta(* BUG 2: a goal argument forwarded through a transparent head ([idr x] unfolds to [x])
is labelled as the rigid variable [x], but conversion can eta-expand [x : R] to
[{| ra := x.(ra); rb := x.(rb) |}] and match a hint headed by the constructor. *)
Set Primitive Projections.
Record R := { ra : nat; rb : nat }.
Inductive W : R -> Prop := .
Definition idr (r : R) := r.
Definition swp (r : R) := {| ra := rb r; rb := ra r |}.
Axiom hm : forall a b, W {| ra := a; rb := b |}.
Create HintDb tt discriminated.
Hint Constants Transparent : tt.
Hint Projections Transparent : tt.
Hint Variables Transparent : tt.
Hint Resolve hm : tt.
(* C1 eauto: bare variable, goal W x (historical limitation of the dnet)
expected: old=FAIL branch=FAIL (not a regression) *)
Goal forall x : R, W x. intros x. first [solve [eauto with tt nocore] | idtac "FAIL [C1 eauto: bare variable, goal W x (historical limitation of the dnet)] -- same as old (fails in both)"]. Abort.
(* C2 eauto: goal W (idr x)
expected: old=OK branch=FAIL <== REGRESSION *)
Goal forall x : R, W (idr x). intros x. first [solve [eauto with tt nocore] | idtac "FAIL [C2 eauto: goal W (idr x)] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* C3 auto: goal W (idr x)
expected: old=OK branch=FAIL <== REGRESSION *)
Goal forall x : R, W (idr x). intros x. first [solve [auto with tt nocore] | idtac "FAIL [C3 auto: goal W (idr x)] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* C4 eauto: goal W (idr (idr x))
expected: old=OK branch=FAIL <== REGRESSION *)
Goal forall x : R, W (idr (idr x)). intros x. first [solve [eauto with tt nocore] | idtac "FAIL [C4 eauto: goal W (idr (idr x))] -- REGRESSION (old: succeeds, branch: FAILS)"]. Abort.
(* C5 typeclasses eauto: goal W (idr x) (tc eauto cannot eta-expand here)
expected: old=FAIL branch=FAIL (not a regression) *)
Goal forall x : R, W (idr x). intros x. first [solve [typeclasses eauto with tt nocore] | idtac "FAIL [C5 typeclasses eauto: goal W (idr x) (tc eauto cannot eta-expand here)] -- same as old (fails in both)"]. Abort.
(* C6 eauto: goal W (swp x): works in both, the constructor path already returns Everything for eta records.
expected: old=OK branch=OK *)
Goal forall x : R, W (swp x). intros x. first [solve [eauto with tt nocore] | idtac "FAIL [C6] -- UNEXPECTED"]. Abort. |
8dc2e6f to
81bad55
Compare
|
@coqbot run full ci |
|
The branch now contains fixes and tests for @Janno's examples, and an additional refinement which is likely to have a big effect on iris. |
|
@coqbot bench |
81bad55 to
c99399b
Compare
|
@coqbot bench |
|
@coqbot bench |
|
🏁 Bench results: 🐢 Top 25 slow downs┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 214 219 5.1706 2.42% 8 coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │ │ 57.2 59.4 2.1848 3.82% 3 coq-performance-tests-lite/PerformanceExperiments/typeclass_reification_let_in_HOAS/_0_SuperFast.v.html │ │ 49.3 50.5 1.1665 2.36% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 49.5 50.6 1.0734 2.17% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 234 234 0.7012 0.30% 141 coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html │ │ 17.7 18.3 0.6107 3.45% 978 coq-category-theory/Instance/Grp/Colimit/Presentation.v.html │ │ 131 132 0.5183 0.39% 155 coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html │ │ 70.7 71.2 0.4893 0.69% 22 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html │ │ 11.5 11.9 0.3926 3.41% 3 coq-performance-tests-lite/PerformanceExperiments/Reify/Ltac2/_4_SuperFast.v.html │ │ 38.5 38.9 0.3802 0.99% 116 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ │ 4.47 4.78 0.3119 6.97% 482 coq-category-theory/Construction/Comma/Diagram.v.html │ │ 42.2 42.5 0.2886 0.68% 52 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 65.5 65.8 0.2813 0.43% 279 coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html │ │ 25.195 25.463 0.2680 1.06% 195 coq-vst/veric/expr_lemmas4.v.html │ │ 25.344 25.608 0.2640 1.04% 147 coq-vst/veric/expr_lemmas4.v.html │ │ 42.6 42.9 0.2564 0.60% 52 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html │ │ 38.5 38.8 0.2531 0.66% 116 coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html │ │ 24.2 24.4 0.2337 0.97% 68 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/VerifyDecode.v.html │ │ 18.1 18.3 0.2318 1.28% 572 coq-mathcomp-odd-order/theories/PFsection9.v.html │ │ 14.435 14.666 0.2310 1.60% 1209 coq-vst/floyd/Component.v.html │ │ 24.4 24.6 0.2202 0.90% 374 coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html │ │ 13.5 13.7 0.2173 1.61% 391 coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Existential.v.html │ │ 14.418 14.624 0.2060 1.43% 1515 coq-vst/floyd/VSU.v.html │ │ 0.0128 0.213 0.1998 1563.56% 371 coq-category-theory/Instance/Mod/Quotient/Isomorphism.v.html │ │ 30.7 30.9 0.1990 0.65% 96 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/VerifyDecode.v.html │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 295 288 -7.7096 -2.61% 3 coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap/_10_SuperFast.v.html │ │ 55.1 48.9 -6.2164 -11.27% 564 rocq-metarocq-erasure/_build/default/theories/Erasure/EConstantsToValues.v.html │ │ 24.8 18.6 -6.1734 -24.90% 359 rocq-iris/iris/algebra/view.v.html │ │ 6.87 2.70 -4.1683 -60.67% 3022 coq-fiat-crypto-with-bedrock/src/Assembly/EquivalenceProofs.v.html │ │ 14.7 11.7 -2.9801 -20.33% 221 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlining.v.html │ │ 3.35 0.862 -2.4856 -74.24% 682 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlining.v.html │ │ 3.57 1.13 -2.4394 -68.42% 643 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlining.v.html │ │ 3.96 1.78 -2.1826 -55.11% 428 rocq-metarocq-erasure/_build/default/theories/Erasure/EConstantsToValues.v.html │ │ 3.79 1.68 -2.1075 -55.61% 444 rocq-metarocq-erasure/_build/default/theories/Erasure/EConstantsToValues.v.html │ │ 3.58 1.53 -2.0422 -57.10% 322 rocq-metarocq-erasure/_build/default/theories/Erasure/EUnboxing.v.html │ │ 2.69 0.803 -1.8874 -70.16% 438 rocq-metarocq-erasure/_build/default/theories/Erasure/EInlining.v.html │ │ 3.31 1.47 -1.8422 -55.58% 250 rocq-metarocq-erasure/_build/default/theories/Erasure/EUnboxing.v.html │ │ 1.90 0.522 -1.3823 -72.57% 66 rocq-metarocq-erasure/_build/default/theories/Erasure/EImplementBox.v.html │ │ 1.88 0.516 -1.3686 -72.61% 62 rocq-metarocq-erasure/_build/default/theories/Erasure/EImplementLazyForce.v.html │ │ 9.42 8.15 -1.2635 -13.42% 669 coq-category-theory/Theory/Multicategory/Endomorphism.v.html │ │ 13.7 12.6 -1.1355 -8.29% 345 coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/XZProofs.v.html │ │ 2.88 1.76 -1.1122 -38.67% 195 coq-category-theory/Structure/Topos/Power.v.html │ │ 1.25 0.255 -0.9902 -79.51% 579 coq-color/Term/Lambda/LCompClos.v.html │ │ 36.4 35.5 -0.9250 -2.54% 573 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/EdwardsXYZT.v.html │ │ 1.05 0.197 -0.8556 -81.28% 1678 rocq-metarocq-pcuic/_build/default/theories/PCUIC/PCUICSigmaCalculus.v.html │ │ 1.13 0.280 -0.8489 -75.19% 795 rocq-metarocq-template-pcuic/_build/default/theories/TemplatePCUIC/TemplateToPCUICWcbvEval.v.html │ │ 39.4 38.6 -0.8184 -2.07% 518 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/EdwardsXYZT.v.html │ │ 7.11 6.32 -0.7945 -11.17% 868 rocq-metarocq-erasure/_build/default/theories/Erasure/EUnboxing.v.html │ │ 0.945 0.173 -0.7719 -81.66% 1079 rocq-metarocq-template/_build/default/theories/Template/EtaExpand.v.html │ │ 1.74 0.982 -0.7601 -43.64% 87 rocq-iris/iris/program_logic/weakestpre.v.html │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
|
Amazing, while keeping compat! |
6a958dd to
90a0424
Compare
|
Undrafting, this should be ready. I squashed some of the commits and cleaned up the code further a bit. We could try to have an even cleaner way to store the cache, but hintdbs are already storing impure data so it's not as if it were a priority. |
|
(I'm not sure how dead the horse is, but at least this should make what remains of the iris-rocq users happy...) |
|
Gitlab seemingly went crazy, so let's try again to @coqbot run full ci |
|
The code is understandably a bit unwiedly in dnets, but I don't object. Could we get some documentation on the meaning of the constructors in approx though? |
Discriminated hint databases used to turn every transparent constant into a wildcard, so goals and hints mentioning them were barely discriminated, and typeclass resolution kept trying instances that could never apply. Such constants are now looked through: the dnet indexes them by the head their body reduces to, as long as no conversion can change that head. To keep lookups cheap, the head of each constant body is approximated once and cached in the hint database. We also only approximate up to βδζ, leaving ι and fix out due to performance issues. As a reminder, we have to be careful about a few situations. Heads mentioned by Hint Extern patterns, which match syntactically, keep the former wildcard behaviour. Constructors of primitive records are η-expandable and should thus be considered a wildcard. Some plugins call the dnet on missing constants and inductive types, so we also have to be robust to this.
Looking through transparent constants is only correct when the user of the database cannot convert more than its transparent state allows. This holds for typeclass resolution, but auto, eauto and trivial convert closed terms with full transparency, so a constant that is opaque in the database could be unfolded and match a label found through a head approximation. They are now only used for lookups that request them, which typeclass resolution does, while other lookups keep the previous discrimination. Each dnet keeps a pattern net for each mode, built lazily.
90a0424 to
e821fa4
Compare
|
@mattam82 done. I agree that the code is not extremely nice but we have to work around the fact that legacy unification loves to not respect anything opaque-related and mimic it somehow. |
|
I know, similar problem as the recent cs-primproj adaptations |
|
@coqbot merge |
|
@coqbot merge now |
Discriminated hint databases used to turn every transparent constant into a wildcard, so goals and hints mentioning them were barely discriminated, and typeclass resolution kept trying instances that could never apply. Such constants are now looked through: the dnet indexes them by the head their body reduces to, as long as no conversion can change that head.
To keep lookups cheap, the head of each constant body is summarised once and cached in the hint database. Heads mentioned by Hint Extern patterns, which match syntactically, keep the former wildcard behaviour.