Skip to content

Resolve transparent heads in hint dnets through cached head summaries. - #22934

Merged
coqbot-app[bot] merged 3 commits into
rocq-prover:masterfrom
ppedrot:tc-dnet-head-summaries
Dec 4, 2026
Merged

coqbot-app[bot] merged 3 commits into
rocq-prover:masterfrom
ppedrot:tc-dnet-head-summaries

Conversation

@ppedrot

@ppedrot ppedrot commented Nov 27, 2026

Copy link
Copy Markdown
Member

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.

@ppedrot ppedrot added kind: performance Improvements to performance and efficiency. request: full CI Use this label when you want your next push to trigger a full CI. kind: experiment labels Nov 27, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Nov 27, 2026
@ppedrot

ppedrot commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

@coqbot bench

@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label Nov 27, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Nov 27, 2026
@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label Nov 27, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Nov 27, 2026
@ppedrot

ppedrot commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

@coqbot bench

@Janno

Janno commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

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 without any failures. There does seem to be a noticeable slowdown on small files, probably from the extra work that goes into preparing the dnets. I would say in total that part costs roughly 10 to 15% of what the speedup would have been without it but that's just a guess.

@coqbot-app

coqbot-app Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

🏁 Bench results:

┌─────────────────────────────────────┬──────────────────────────┬────────────────────────────────────────┬──────────────────────────┐
│                                     │      user time [s]       │            CPU instructions            │  max resident mem [KB]   │
│                                     │                          │                                        │                          │
│            package_name             │   NEW      OLD    PDIFF  │      NEW             OLD        PDIFF  │   NEW      OLD    PDIFF  │
├─────────────────────────────────────┼──────────────────────────┼────────────────────────────────────────┼──────────────────────────┤
│                rocq-metarocq-common │  100.21   123.36  -18.77 │   628954835281    771705619963  -18.50 │ 2209464  2288660   -3.46 │
│                 rocq-metarocq-pcuic │  525.69   594.18  -11.53 │  3231786310227   3617932949167  -10.67 │ 2937468  2903756    1.16 │
│               rocq-metarocq-erasure │  642.32   722.40  -11.09 │  4057312162714   4530155903761  -10.44 │ 2032760  2389568  -14.93 │
│                           coq-color │  212.52   221.65   -4.12 │  1301850557116   1358782879335   -4.19 │ 1275476  1288188   -0.99 │
│                    coq-math-classes │   74.81    77.01   -2.86 │   427391324087    438520597889   -2.54 │  545924   546812   -0.16 │
│                   coq-iris-examples │  308.01   315.67   -2.43 │  1874545545205   1926054323787   -2.67 │ 1149348  1150872   -0.13 │
│           rocq-metarocq-safechecker │  268.17   272.44   -1.57 │  1967018226855   1991917162487   -1.25 │ 2018700  2017168    0.08 │
│                        coq-rewriter │  285.09   287.61   -0.88 │  2084056370272   2091478117363   -0.35 │ 1469296  1476412   -0.48 │
│        coq-fiat-crypto-with-bedrock │ 6514.24  6552.41   -0.58 │ 52663536652045  52767541193521   -0.20 │ 5209392  5209384    0.00 │
│                            coq-hott │  163.01   163.83   -0.50 │  1029474858049   1032250634744   -0.27 │  495596   495580    0.00 │
│                       coq-fourcolor │ 1342.98  1349.46   -0.48 │ 12645282827689  12643254594253    0.02 │ 1079160  1078672    0.05 │
│                         coq-unimath │ 1578.80  1585.58   -0.43 │ 13261179374509  13260892376670    0.00 │ 1920820  1920576    0.01 │
│         coq-rewriter-perf-SuperFast │  368.04   369.57   -0.41 │  2841573186705   2844119156855   -0.09 │ 2052364  2065248   -0.62 │
│                      rocq-equations │   14.67    14.73   -0.41 │   100875530765    100857965283    0.02 │  417864   417932   -0.02 │
│                    coq-fiat-parsers │  268.13   269.22   -0.40 │  2038192815343   2047722875362   -0.47 │ 2292240  2292040    0.01 │
│                            coq-corn │  547.13   549.09   -0.36 │  3558250553816   3568475399054   -0.29 │  752868   750292    0.34 │
│                             coq-vst │  705.88   708.27   -0.34 │  5141375722544   5148195219590   -0.13 │ 2288036  2288692   -0.03 │
│                           rocq-core │   11.34    11.37   -0.26 │    73857618397     73834097249    0.03 │  451632   452080   -0.10 │
│              rocq-metarocq-template │   91.68    91.89   -0.23 │   619098533267    625667219638   -1.05 │ 1707028  1707444   -0.02 │
│                         coq-coqutil │   44.48    44.58   -0.22 │   268258015969    268257545459    0.00 │  519652   519624    0.01 │
│                 rocq-mathcomp-order │   96.11    96.25   -0.15 │   623206448842    623173371832    0.01 │  968232   967908    0.03 │
│ coq-neural-net-interp-computed-lite │  243.11   243.41   -0.12 │  2397170252673   2397222380151   -0.00 │  947128   946828    0.03 │
│  rocq-mathcomp-group-representation │   73.81    73.86   -0.07 │   471114543765    470461512002    0.14 │ 1513056  1512952    0.01 │
│                 rocq-mathcomp-field │  160.56   160.56    0.00 │  1066639293113   1064148098021    0.23 │ 2632960  2639332   -0.24 │
│                 rocq-metarocq-utils │   19.29    19.29    0.00 │   122759435658    122748161871    0.01 │  623624   623836   -0.03 │
│                 coq-category-theory │ 1295.41  1294.60    0.06 │  9063848468890   9071600688915   -0.09 │ 7098928  7102564   -0.05 │
│          rocq-mathcomp-finite-group │   20.78    20.76    0.10 │   124664333791    124604041921    0.05 │  638908   639180   -0.04 │
│                      coq-coquelicot │   38.22    38.15    0.18 │   219190343775    219084454792    0.05 │  696488   694580    0.27 │
│               rocq-mathcomp-algebra │  323.08   322.48    0.19 │  2124501857408   2124416531700    0.00 │ 1431092  1434180   -0.22 │
│              rocq-mathcomp-analysis │ 1169.20  1166.74    0.21 │  7904275637881   7903311897799    0.01 │ 2397784  2396848    0.04 │
│          coq-performance-tests-lite │  747.24   745.52    0.23 │  5945687326427   5947580960136   -0.03 │ 1853224  1853408   -0.01 │
│               coq-engine-bench-lite │  114.80   114.53    0.24 │   881843044506    881870206285   -0.00 │ 1047152  1046948    0.02 │
│              rocq-mathcomp-solvable │   67.56    67.40    0.24 │   419257207355    418185345441    0.26 │ 1006364  1004440    0.19 │
│                        rocq-runtime │  272.23   271.53    0.26 │  1999622792995   1998889677682    0.04 │  593644   594068   -0.07 │
│                         rocq-stdlib │  240.84   240.21    0.26 │  1458131451593   1458593287046   -0.03 │  810184   809524    0.08 │
│                        coq-bedrock2 │  245.36   244.62    0.30 │  1814697339908   1814650469827    0.00 │  940812   940044    0.08 │
│                       coq-fiat-core │   63.53    63.29    0.38 │   400900294728    400704387173    0.05 │  537264   536988    0.05 │
│              coq-mathcomp-odd-order │  392.67   390.96    0.44 │  2709675795827   2703871846634    0.21 │ 3689032  3681132    0.21 │
│                        coq-compcert │  283.39   282.14    0.44 │  1786328078600   1769592896734    0.95 │ 1379392  1405308   -1.84 │
│                  rocq-mathcomp-boot │   38.31    38.14    0.45 │   210595637159    210500715757    0.05 │  685864   686172   -0.04 │
│                           rocq-elpi │   26.63    26.49    0.53 │   183012331610    183010318344    0.00 │  497308   497356   -0.01 │
│          rocq-metarocq-translations │   20.32    20.14    0.89 │   138845175420    138900006296   -0.04 │ 1243220  1242868    0.03 │
│                        rocq-bignums │   22.15    21.92    1.05 │   137134952706    135688828020    1.07 │  509556   509204    0.07 │
│                            coq-core │    5.91     5.83    1.37 │    42695999444     42694013113    0.00 │  110096   110088    0.01 │
│             rocq-mathcomp-ssreflect │    1.24     1.20    3.33 │     7483274116      7482952089    0.00 │  662216   661792    0.06 │
│                        coq-coqprime │   60.22    58.24    3.40 │   388322749181    384573183923    0.97 │  915088   914516    0.06 │
└─────────────────────────────────────┴──────────────────────────┴────────────────────────────────────────┴──────────────────────────┘

🐢 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                                  │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@Janno

Janno commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

One file failed in my test on our code base. Here's a minimized reproducer:

Inductive sb_tag := sb_L | sb_R.
Definition sb_left := sb_L.
Definition sb_right := sb_R.

Class SBTarget (t : sb_tag) := {}.
Class SBChoice (t : sb_tag) := { sb_choice : SBTarget t }.

#[local] Instance sb_pick_left : SBChoice sb_left | 1 :=
  {| sb_choice := Build_SBTarget sb_left |}.
#[local] Instance sb_pick_right : SBChoice sb_right | 2 :=
  {| sb_choice := Build_SBTarget sb_right |}.

Definition sb_consume `{SBTarget sb_right} : Prop := True.

Set Typeclasses Debug.
Lemma sb_test : let i := sb_choice in sb_consume.
Proof. exact I. Qed.

It works on master but not in this branch.

@ppedrot

ppedrot commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

@Janno it seems to be due to a bug in master uncovered by this PR, I'll open an issue and another PR.

@ppedrot

ppedrot commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

@Janno see #22943.

@coqbot-app

coqbot-app Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

🏁 Bench results:

┌──────────────────────────────┬───────────────────────┬─────────────────────────────────────┬─────────────────────────┐
│                              │     user time [s]     │          CPU instructions           │  max resident mem [KB]  │
│                              │                       │                                     │                         │
│         package_name         │  NEW     OLD    PDIFF │      NEW            OLD       PDIFF │   NEW      OLD    PDIFF │
├──────────────────────────────┼───────────────────────┼─────────────────────────────────────┼─────────────────────────┤
│                    rocq-iris │ 252.12  270.19  -6.69 │ 1491526691451  1619346214854  -7.89 │  770072   784988  -1.90 │
│ rocq-metarocq-template-pcuic │  35.94   37.83  -5.00 │  229859441015   239003826406  -3.83 │ 1282548  1294504  -0.92 │
│           rocq-iris-examples │ 308.92  316.43  -2.37 │ 1945106143347  1994542781714  -2.48 │ 1167052  1169864  -0.24 │
│                     coq-core │   5.87    5.99  -2.00 │   42445750889    42446522918  -0.00 │  112524   112644  -0.11 │
│                    rocq-core │  10.97   11.03  -0.54 │   75220810505    75197867157   0.03 │  453724   454048  -0.07 │
│                 rocq-runtime │ 273.59  273.08   0.19 │ 1997533132191  1996808405305   0.04 │  596128   596176  -0.01 │
└──────────────────────────────┴───────────────────────┴─────────────────────────────────────┴─────────────────────────┘

🐢 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                                │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@Janno

Janno commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

I don't see any CI or bench failures despite some behavioral changes around auto so here's a few examples in case this has gone under the radar.

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.

@github-actions github-actions Bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 30, 2026
@ppedrot
ppedrot force-pushed the tc-dnet-head-summaries branch from 8dc2e6f to 81bad55 Compare November 30, 2026 19:56
@coqbot-app coqbot-app Bot added needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. and removed needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. labels Nov 30, 2026
@ppedrot

ppedrot commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

@coqbot run full ci

@coqbot-app coqbot-app Bot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Nov 30, 2026
@ppedrot

ppedrot commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

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.

@ppedrot

ppedrot commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

@coqbot bench

@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 1, 2026
@ppedrot
ppedrot force-pushed the tc-dnet-head-summaries branch from 81bad55 to c99399b Compare December 1, 2026 07:47
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 1, 2026
@ppedrot

ppedrot commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@coqbot bench

@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 1, 2026
@ppedrot

ppedrot commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@coqbot bench

@coqbot-app

coqbot-app Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

🏁 Bench results:

┌─────────────────────────────────────┬──────────────────────────┬────────────────────────────────────────┬──────────────────────────┐
│                                     │      user time [s]       │            CPU instructions            │  max resident mem [KB]   │
│                                     │                          │                                        │                          │
│            package_name             │   NEW      OLD    PDIFF  │      NEW             OLD        PDIFF  │   NEW      OLD    PDIFF  │
├─────────────────────────────────────┼──────────────────────────┼────────────────────────────────────────┼──────────────────────────┤
│                           rocq-iris │  230.16   282.76  -18.60 │  1311219607727   1623904442613  -19.26 │  754116   773340   -2.49 │
│                rocq-metarocq-common │  101.37   124.28  -18.43 │   634992671823    774101678486  -17.97 │ 2262652  2282228   -0.86 │
│                 rocq-metarocq-pcuic │  531.31   595.37  -10.76 │  3254527547994   3636565205125  -10.51 │ 2945816  2892772    1.83 │
│               rocq-metarocq-erasure │  651.16   727.52  -10.50 │  4097552506965   4548491003612   -9.91 │ 2038524  2418164  -15.70 │
│                 coq-category-theory │ 1183.44  1237.08   -4.34 │  8279965917685   8590933995483   -3.62 │ 1195788  1225460   -2.42 │
│                           coq-color │  213.87   222.67   -3.95 │  1308141207841   1363060155004   -4.03 │ 1278356  1280780   -0.19 │
│        rocq-metarocq-template-pcuic │   37.04    38.43   -3.62 │   228632396692    237555076809   -3.76 │ 1282832  1294924   -0.93 │
│                 rocq-iris-heap-lang │   71.64    73.74   -2.85 │   424815717581    437841793019   -2.98 │  837800   837676    0.01 │
│                    coq-math-classes │   75.06    77.26   -2.85 │   428619689580    439696914429   -2.52 │  545308   546592   -0.23 │
│                  rocq-iris-examples │  320.07   328.79   -2.65 │  1951723942957   2000331666600   -2.43 │ 1180392  1160268    1.73 │
│           rocq-metarocq-safechecker │  268.51   274.07   -2.03 │  1974324889096   2000128668897   -1.29 │ 2034192  2031800    0.12 │
│         coq-rewriter-perf-SuperFast │  374.04   381.64   -1.99 │  2854259882659   2856335710792   -0.07 │ 2050716  2072376   -1.05 │
│                          rocq-stdpp │   64.26    65.40   -1.74 │   365444149542    368942433208   -0.95 │  790312   773456    2.18 │
│                            coq-corn │  544.09   552.44   -1.51 │  3533579111861   3577224234246   -1.22 │  702856   747728   -6.00 │
│                 rocq-mathcomp-field │  159.03   161.43   -1.49 │  1065611733657   1065749825174   -0.01 │ 2650000  2649572    0.02 │
│                 coq-fourcolor-reals │    6.87     6.97   -1.43 │    39091387492     38992491476    0.25 │ 1076216  1075320    0.08 │
│                    coq-fiat-parsers │  266.80   270.61   -1.41 │  2010899840568   2030423084936   -0.96 │ 2291308  2290764    0.02 │
│                rocq-mathcomp-finmap │    9.75     9.88   -1.32 │    58395372921     58394582307    0.00 │  582560   582148    0.07 │
│  rocq-mathcomp-group-representation │   73.28    74.17   -1.20 │   471885723372    471961519764   -0.02 │ 1546704  1546488    0.01 │
│                            coq-hott │  161.34   163.15   -1.11 │  1016346286723   1022393835278   -0.59 │  494628   487836    1.39 │
│               rocq-mathcomp-algebra │  313.42   315.71   -0.73 │  2077945955576   2078110564840   -0.01 │ 1426444  1425748    0.05 │
│              rocq-mathcomp-analysis │ 1150.04  1158.37   -0.72 │  7857218889354   7857743708169   -0.01 │ 2426720  2427220   -0.02 │
│              rocq-metarocq-template │   91.64    92.30   -0.72 │   617801763576    624257988746   -1.03 │ 1691292  1700176   -0.52 │
│             rocq-mathcomp-classical │   89.04    89.64   -0.67 │   557754376772    557765732973   -0.00 │ 1787028  1787372   -0.02 │
│          rocq-mathcomp-finite-group │   21.00    21.12   -0.57 │   125498439501    125503050979   -0.00 │  640940   640696    0.04 │
│                 rocq-mathcomp-order │   92.59    93.11   -0.56 │   602242599269    602209936068    0.01 │  974684   973268    0.15 │
│                           rocq-elpi │   27.01    27.16   -0.55 │   184257239938    184249057549    0.00 │  496160   495500    0.13 │
│                 rocq-mathcomp-reals │   43.49    43.72   -0.53 │   267884298872    267954818594   -0.03 │ 2068032  2072092   -0.20 │
│                        coq-rewriter │  287.84   289.33   -0.51 │  2080853899088   2087384047115   -0.31 │ 1530908  1530004    0.06 │
│        coq-fiat-crypto-with-bedrock │ 6534.00  6564.19   -0.46 │ 52566182236188  52659401604234   -0.18 │ 5209252  5209156    0.00 │
│                         coq-unimath │ 1602.42  1609.40   -0.43 │ 13378374780481  13377982695288    0.00 │ 1921480  1920856    0.03 │
│                 rocq-metarocq-utils │   19.36    19.43   -0.36 │   123447887596    123352704931    0.08 │  625216   621536    0.59 │
│                           rocq-core │   11.36    11.40   -0.35 │    74024480784     74012446934    0.02 │  451420   451260    0.04 │
│                        coq-compcert │  281.87   282.80   -0.33 │  1767368964378   1767379774157   -0.00 │ 1459084  1376028    6.04 │
│                           coq-flocq │   79.43    79.68   -0.31 │   445903248268    445786322655    0.03 │  943172   942112    0.11 │
│              rocq-mathcomp-solvable │   67.98    68.11   -0.19 │   420564266817    420457606128    0.03 │ 1007824  1006344    0.15 │
│                         rocq-stdlib │  240.70   241.15   -0.19 │  1455571421181   1462664531590   -0.48 │  809304   810080   -0.10 │
│                  rocq-mathcomp-boot │   38.62    38.69   -0.18 │   212408504110    212392344401    0.01 │  690528   689448    0.16 │
│                             coq-vst │  708.32   709.52   -0.17 │  5160299914672   5164818230244   -0.09 │ 2227824  2227280    0.02 │
│                        coq-bedrock2 │  245.30   245.65   -0.14 │  1820514713083   1820452138929    0.00 │  936616   936416    0.02 │
│              coq-mathcomp-odd-order │  394.62   395.09   -0.12 │  2718996736606   2719082941439   -0.00 │ 3693996  3696344   -0.06 │
│                      coq-coquelicot │   38.32    38.35   -0.08 │   220169000550    220085764397    0.04 │  695772   694612    0.17 │
│                        rocq-runtime │  272.40   272.45   -0.02 │  2006370995715   2005317213865    0.05 │  593448   592804    0.11 │
│                        rocq-bignums │   22.11    22.10    0.05 │   137331938620    136304750996    0.75 │  511012   510432    0.11 │
│                       coq-fourcolor │ 1341.06  1339.99    0.08 │ 12067428036314  12067218469755    0.00 │ 1082620  1082552    0.01 │
│                       coq-fiat-core │   64.14    64.08    0.09 │   402220004378    401837630020    0.10 │  537852   535388    0.46 │
│                            coq-core │    5.92     5.90    0.34 │    42688814220     42690130874   -0.00 │  110152   110028    0.11 │
│               coq-engine-bench-lite │  114.25   113.77    0.42 │   876583689857    876665239041   -0.01 │ 1048880  1047864    0.10 │
│                         coq-coqutil │   44.69    44.50    0.43 │   268898406047    268794096237    0.04 │  523620   521888    0.33 │
│                        coq-coqprime │   58.95    58.51    0.75 │   388023886070    384594336220    0.89 │  914796   914240    0.06 │
│          coq-performance-tests-lite │  748.07   742.18    0.79 │  5906638151670   5899697477370    0.12 │ 1799068  1821368   -1.22 │
│                         coq-ext-lib │   12.47    12.37    0.81 │    80483701001     80466030664    0.02 │  428232   427616    0.14 │
│          rocq-metarocq-translations │   20.60    20.41    0.93 │   139857121090    139753000379    0.07 │ 1246020  1244164    0.15 │
│             rocq-mathcomp-ssreflect │    1.19     1.17    1.71 │     7462053375      7462303975   -0.00 │  664224   663848    0.06 │
│ coq-neural-net-interp-computed-lite │  250.67   245.85    1.96 │  2324224444786   2324249580233   -0.00 │  947572   946788    0.08 │
│                      rocq-equations │   14.83    14.32    3.56 │   101312362128    101294112832    0.02 │  418416   417788    0.15 │
└─────────────────────────────────────┴──────────────────────────┴────────────────────────────────────────┴──────────────────────────┘

🐢 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                                                          │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@mattam82

mattam82 commented Dec 3, 2026

Copy link
Copy Markdown
Member

Amazing, while keeping compat!

@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 3, 2026
@ppedrot
ppedrot force-pushed the tc-dnet-head-summaries branch from 6a958dd to 90a0424 Compare December 3, 2026 16:10
@ppedrot ppedrot added this to the 9.4+rc1 milestone Dec 3, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 3, 2026
@ppedrot
ppedrot marked this pull request as ready for review December 3, 2026 16:10
@ppedrot
ppedrot requested review from a team as code owners December 3, 2026 16:10
@ppedrot

ppedrot commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

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.

@ppedrot

ppedrot commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

(I'm not sure how dead the horse is, but at least this should make what remains of the iris-rocq users happy...)

@ppedrot

ppedrot commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Gitlab seemingly went crazy, so let's try again to @coqbot run full ci

@mattam82 mattam82 self-assigned this Dec 4, 2026
@mattam82

mattam82 commented Dec 4, 2026

Copy link
Copy Markdown
Member

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.
@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 4, 2026
@ppedrot
ppedrot force-pushed the tc-dnet-head-summaries branch from 90a0424 to e821fa4 Compare December 4, 2026 14:17
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 4, 2026
@ppedrot

ppedrot commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

@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.

@mattam82

mattam82 commented Dec 4, 2026

Copy link
Copy Markdown
Member

I know, similar problem as the recent cs-primproj adaptations

@mattam82

mattam82 commented Dec 4, 2026

Copy link
Copy Markdown
Member

@coqbot merge

@mattam82

mattam82 commented Dec 4, 2026

Copy link
Copy Markdown
Member

@coqbot merge now

@coqbot-app
coqbot-app Bot merged commit 3d6633f into rocq-prover:master Dec 4, 2026
8 checks passed
@ppedrot
ppedrot deleted the tc-dnet-head-summaries branch December 4, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: performance Improvements to performance and efficiency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants