Skip to content
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

Track unused constant arguments in Genlambda and erase them. #19014

Merged
merged 1 commit into from May 21, 2024

Conversation

ppedrot
Copy link
Member

@ppedrot ppedrot commented May 11, 2024

We replace arguments that do not appear in the lambda body of constants by a dummy constant value. The rationale is that most arguments in symbolic code are type annotations that have no computational content, hence there is no point in generating them in the first place.

This patch seems to have wonderful effects on degenerate examples from UniMath.

Depends on #19015.

@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label May 11, 2024
@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 May 11, 2024
@ppedrot
Copy link
Member Author

ppedrot commented May 11, 2024

@coqbot bench

Copy link
Contributor

coqbot-app bot commented May 12, 2024

🏁 Bench results:

┌─────────────────────────────────────┬──────────────────────────┬────────────────────────────────────────┬────────────────────────────────────────┬─────────────────────────┐
│                                     │      user time [s]       │               CPU cycles               │            CPU instructions            │  max resident mem [KB]  │
│                                     │                          │                                        │                                        │                         │
│            package_name             │   NEW      OLD    PDIFF  │      NEW             OLD        PDIFF  │      NEW             OLD        PDIFF  │   NEW      OLD    PDIFF │
├─────────────────────────────────────┼──────────────────────────┼────────────────────────────────────────┼────────────────────────────────────────┼─────────────────────────┤
│ coq-neural-net-interp-computed-lite │  263.40   301.92  -12.76 │  1201186088954   1377669919370  -12.81 │  3208546246494   3617774004974  -11.31 │ 1113100  1115076  -0.18 │
│        coq-fiat-crypto-with-bedrock │ 5938.32  6211.54   -4.40 │ 27040006005317  28296427156202   -4.44 │ 48739846457862  51216964249354   -4.84 │ 3246020  3246184  -0.01 │
│                    coq-fiat-parsers │  306.02   311.38   -1.72 │  1365423616584   1388499795012   -1.66 │  2419077173277   2471135154622   -2.11 │ 2231176  2408940  -7.38 │
│                            coq-hott │  159.25   160.88   -1.01 │   711031037707    718906437493   -1.10 │  1132122778065   1140368322953   -0.72 │  473972   476640  -0.56 │
│                            coq-core │  128.31   129.33   -0.79 │   506286195899    500091704243    1.24 │   532378770428    531839606940    0.10 │  457616   457980  -0.08 │
│                 coq-category-theory │  688.13   691.71   -0.52 │  3129318955362   3145487397318   -0.51 │  5254272636995   5263597746672   -0.18 │  956616   956560   0.01 │
│             coq-metacoq-safechecker │  418.93   420.81   -0.45 │  1917686241221   1927571445714   -0.51 │  3180444030995   3184122275106   -0.12 │ 2043736  2070552  -1.30 │
│                           coq-color │  251.56   252.62   -0.42 │  1130670048972   1135115315079   -0.39 │  1636207884741   1636186663209    0.00 │ 1161140  1176472  -1.30 │
│                  coq-mathcomp-field │  141.80   142.36   -0.39 │   647058349242    650249574028   -0.49 │  1074181124789   1074301674362   -0.01 │ 1485320  1484680   0.04 │
│               coq-engine-bench-lite │  155.71   156.26   -0.35 │   660588964606    661380331649   -0.12 │  1223256885464   1222372911596    0.07 │ 1234220  1323184  -6.72 │
│                         coq-coqutil │   42.83    42.98   -0.35 │   188895950769    188851696359    0.02 │   270910734407    270909222421    0.00 │  561660   560752   0.16 │
│              coq-mathcomp-ssreflect │  218.95   219.62   -0.31 │   999599786942   1003637703081   -0.40 │  1675731380877   1675860725433   -0.01 │ 1732968  1724676   0.48 │
│                       coq-fiat-core │   59.88    60.04   -0.27 │   249754062709    249736431090    0.01 │   368530357119    368621362643   -0.02 │  482192   482764  -0.12 │
│              coq-mathcomp-character │  108.53   108.79   -0.24 │   495874954832    497198264159   -0.27 │   790451704824    790346697367    0.01 │ 1135684  1134584   0.10 │
│                      coq-verdi-raft │  583.52   584.61   -0.19 │  2654226608383   2659821346828   -0.21 │  4161305391358   4161377632237   -0.00 │  844108   848344  -0.50 │
│                        coq-rewriter │  389.44   390.12   -0.17 │  1770176865901   1773119584372   -0.17 │  2977358624019   2990704912971   -0.45 │ 1475616  1478040  -0.16 │
│                 coq-metacoq-erasure │  502.84   503.65   -0.16 │  2294749211568   2298933668653   -0.18 │  3583082094993   3581647836144    0.04 │ 2115780  2104872   0.52 │
│                       coq-equations │    7.60     7.61   -0.13 │    31252892724     31284830564   -0.10 │    50839918284     50938717283   -0.19 │  389696   388416   0.33 │
│                      coq-coquelicot │   39.75    39.77   -0.05 │   176686462071    176974639588   -0.16 │   249286550375    249305123619   -0.01 │  851948   853440  -0.17 │
│              coq-mathcomp-odd-order │  794.87   795.08   -0.03 │  3639497097446   3641449312617   -0.05 │  6077856690212   6078099989729   -0.00 │ 1654536  1655276  -0.04 │
│                coq-metacoq-template │  151.10   151.06    0.03 │   670031841654    670455606476   -0.06 │  1046071883348   1047070942703   -0.10 │ 1485480  1516928  -2.07 │
│                   coq-metacoq-pcuic │  986.38   986.06    0.03 │  4420763772663   4419131544889    0.04 │  6469254515349   6470249853624   -0.02 │ 2681056  2682248  -0.04 │
│         coq-rewriter-perf-SuperFast │  788.05   787.44    0.08 │  3579198036620   3577222279206    0.06 │  6227205678108   6257078560348   -0.48 │ 1575688  1574532   0.07 │
│                       coq-fourcolor │ 1361.61  1359.76    0.14 │  6225414147131   6217907799559    0.12 │ 12906192787860  12909842830139   -0.03 │ 2182760  2183860  -0.05 │
│          coq-performance-tests-lite │  714.61   713.61    0.14 │  3225973170843   3224499742069    0.05 │  5683640015849   5685663242999   -0.04 │ 2278288  2275884   0.11 │
│                coq-mathcomp-algebra │  259.02   258.46    0.22 │  1181922189783   1178550256868    0.29 │  2000519141473   2000511548075    0.00 │ 1337324  1338888  -0.12 │
│               coq-mathcomp-solvable │  118.29   117.98    0.26 │   540187602779    539115849079    0.20 │   856396566606    857267514365   -0.10 │  877636   877204   0.05 │
│                        coq-coqprime │   48.51    48.38    0.27 │   217467377227    216734046445    0.34 │   334518110023    334429675919    0.03 │  785420   785764  -0.04 │
│                           coq-verdi │   49.09    48.95    0.29 │   221394201993    220264409992    0.51 │   340859205399    340861791343   -0.00 │  531688   531964  -0.05 │
│                         coq-bignums │   29.64    29.55    0.30 │   134337243140    133951897844    0.29 │   192319073312    192336137177   -0.01 │  480268   472344   1.68 │
│                            coq-corn │  719.47   716.81    0.37 │  3268692666431   3256729861436    0.37 │  5078295563200   5078491687725   -0.00 │  761000   762480  -0.19 │
│                        coq-compcert │  281.75   280.48    0.45 │  1274643461528   1269312662845    0.42 │  1941296891198   1945986797551   -0.24 │ 1142724  1105080   3.41 │
│                   coq-iris-examples │  471.12   468.58    0.54 │  2140597271127   2131036516351    0.45 │  3276860169743   3276876638908   -0.00 │ 1112140  1116788  -0.42 │
│                          coq-stdlib │  351.81   349.71    0.60 │  1499009761163   1486185642758    0.86 │  1259274798397   1258581115534    0.06 │  718012   720060  -0.28 │
│                      coq-test-suite │  702.68   698.44    0.61 │  2998976686033   2987778279917    0.37 │  5376821650823   5374974488871    0.03 │ 2450280  2460368  -0.41 │
│                        coq-bedrock2 │  360.61   358.28    0.65 │  1643893993706   1633085125628    0.66 │  3101747062590   3102564223267   -0.03 │  865880   860024   0.68 │
│                         coq-unimath │ 2471.04  2453.90    0.70 │ 11249178514473  11171549065271    0.69 │ 22168404622060  22200248228368   -0.14 │ 1254028  1254340  -0.02 │
│                             coq-vst │  884.04   876.97    0.81 │  4019620491575   3986230922509    0.84 │  6743264912997   6743353575810   -0.00 │ 2321752  2322268  -0.02 │
│                    coq-math-classes │   86.40    85.57    0.97 │   388797112036    384849533144    1.03 │   536936836974    536903151720    0.01 │  503752   503364   0.08 │
│               coq-mathcomp-fingroup │   30.83    30.52    1.02 │   140346326588    138808411554    1.11 │   207649928118    207783750808   -0.06 │  564528   565300  -0.14 │
│            coq-metacoq-translations │   17.19    16.76    2.57 │    76748595471     75631987673    1.48 │   125044541687    125151096335   -0.09 │  846452   843708   0.33 │
└─────────────────────────────────────┴──────────────────────────┴────────────────────────────────────────┴────────────────────────────────────────┴─────────────────────────┘

🐢 Top 25 slow downs
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                 TOP 25 SLOW DOWNS                                                                 │
│                                                                                                                                                   │
│   OLD       NEW      DIFF   %DIFF    Ln                      FILE                                                                                 │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  95.8350   98.1720  2.3370   2.44%   376  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                             │
│  19.6590   21.9630  2.3040  11.72%  2061  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvFunctions.v.html        │
│  46.4290   48.5100  2.0810   4.48%   558  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html       │
│  46.7060   48.5860  1.8800   4.03%   558  coq-bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html                                         │
│   3.7590    4.8640  1.1050  29.40%    22  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html                                  │
│  72.4010   73.4610  1.0600   1.46%   905  coq-unimath/UniMath/ModelCategories/Generated/LNWFSCocomplete.v.html                                    │
│  38.3090   39.2210  0.9120   2.38%   338  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                             │
│  44.1800   44.9290  0.7490   1.70%   827  coq-vst/veric/binop_lemmas4.v.html                                                                      │
│ 256.3580  257.0640  0.7060   0.28%  1629  coq-metacoq-pcuic/pcuic/theories/PCUICSR.v.html                                                         │
│   2.3610    2.9980  0.6370  26.98%   487  coq-stdlib/Numbers/HexadecimalFacts.v.html                                                              │
│ 100.4930  101.1180  0.6250   0.62%    20  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html                                             │
│   2.6560    3.2640  0.6080  22.89%    34  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html                                  │
│   2.8070    3.3790  0.5720  20.38%   490  coq-stdlib/Reals/Cauchy/ConstructiveCauchyRealsMult.v.html                                              │
│  30.6860   31.2520  0.5660   1.84%   147  coq-vst/veric/expr_lemmas4.v.html                                                                       │
│  67.1070   67.6310  0.5240   0.78%    27  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html                                │
│  24.6220   25.1420  0.5200   2.11%   374  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                             │
│  24.6100   25.1140  0.5040   2.05%   375  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                             │
│  23.0480   23.5210  0.4730   2.05%    49  coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html                                 │
│  32.9770   33.4480  0.4710   1.43%  1333  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvFunctions.v.html        │
│   4.7300    5.1690  0.4390   9.28%   237  coq-fiat-parsers/src/Parsers/ParserFromParserADT.v.html                                                 │
│ 180.9980  181.4340  0.4360   0.24%   233  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/DecodeByExtension.v.html │
│  29.8030   30.2160  0.4130   1.39%   194  coq-vst/veric/expr_lemmas4.v.html                                                                       │
│ 138.3620  138.7380  0.3760   0.27%   155  coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html                              │
│  25.6190   25.9720  0.3530   1.38%   454  coq-unimath/UniMath/SyntheticHomotopyTheory/Circle2.v.html                                              │
│   7.2000    7.5450  0.3450   4.79%   604  coq-unimath/UniMath/CategoryTheory/EnrichedCats/Colimits/Examples/StructureEnrichedColimits.v.html      │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                             TOP 25 SPEED UPS                                                              │
│                                                                                                                                           │
│   OLD       NEW       DIFF     %DIFF   Ln                    FILE                                                                         │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 260.1730  221.4150  -38.7580  -14.90%    8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │
│  23.6380    0.1790  -23.4590  -99.24%  121  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  23.5700    0.1800  -23.3900  -99.24%  130  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  26.8950   13.4570  -13.4380  -49.96%   22  coq-fiat-crypto-with-bedrock/src/Spec/Test/X25519.v.html                                      │
│  26.8760   13.4920  -13.3840  -49.80%   17  coq-fiat-crypto-with-bedrock/src/Spec/Test/X25519.v.html                                      │
│  15.7680    3.9510  -11.8170  -74.94%   33  coq-fiat-crypto-with-bedrock/src/Curves/EdwardsMontgomery25519.v.html                         │
│  12.2430    0.4340  -11.8090  -96.46%  130  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  12.0870    0.4230  -11.6640  -96.50%  121  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.3920    0.0740  -11.3180  -99.35%  178  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.2860    0.0080  -11.2780  -99.93%  179  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.5470    0.2800  -11.2670  -97.58%  181  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.4510    0.2190  -11.2320  -98.09%  166  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.2370    0.0060  -11.2310  -99.95%  162  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.2390    0.0400  -11.1990  -99.64%  161  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  21.0720   10.5410  -10.5310  -49.98%   25  coq-fiat-crypto-with-bedrock/src/Spec/Test/X25519.v.html                                      │
│   8.8790    0.7270   -8.1520  -91.81%   78  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/Field25519.v.html                     │
│  10.4470    2.3200   -8.1270  -77.79%   78  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/Field25519.v.html                     │
│  15.3810    7.7370   -7.6440  -49.70%   99  coq-fiat-crypto-with-bedrock/src/Spec/Curve25519.v.html                                       │
│  50.4030   43.8540   -6.5490  -12.99%   50  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  52.7390   46.4890   -6.2500  -11.85%   50  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  13.9640    8.0260   -5.9380  -42.52%   12  coq-fiat-crypto-with-bedrock/src/Spec/Test/X25519.v.html                                      │
│  16.0670   10.2420   -5.8250  -36.25%   25  coq-fiat-crypto-with-bedrock/src/Curves/EdwardsMontgomery25519.v.html                         │
│  41.7570   36.8200   -4.9370  -11.82%  139  coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html                                  │
│   5.2310    1.2820   -3.9490  -75.49%   96  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/Field25519.v.html                     │
│   5.1280    1.1820   -3.9460  -76.95%  150  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/Field25519.v.html                     │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@SkySkimmer
Copy link
Contributor

twenty largest absolute vosize reductions

coq-unimath/./UniMath/CategoryTheory/Monads/Derivative.vo 13210224 3089947 -10120277 -76.6094%
coq-fiat-parsers/./src/Parsers/Refinement/SharpenedJSON.vo 29139985 20073623 -9066362 -31.1131%
coq-hott/./theories/WildCat/Products.vo 8347908 4035637 -4312271 -51.6569%
coq-hott/./theories/Spaces/Torus/TorusEquivCircles.vo 7585395 3652677 -3932718 -51.8459%
coq-unimath/./UniMath/CategoryTheory/DisplayedCats/Adjunctions.vo 4897552 1086129 -3811423 -77.823%
coq-metacoq-safechecker/./safechecker/theories/PCUICSafeReduce.vo 11357932 7839812 -3518120 -30.975%
coq-hott/./theories/Homotopy/CayleyDickson.vo 4353922 1866067 -2487855 -57.1406%
coq-hott/./theories/Spaces/Spheres.vo 3414825 944643 -2470182 -72.337%
coq-unimath/./UniMath/HomologicalAlgebra/CohomologyComplex.vo 2803193 456586 -2346607 -83.7119%
coq-hott/./theories/Colimits/Colimit_Flattening.vo 3364330 1073155 -2291175 -68.102%
coq-hott/./theories/Colimits/Sequential.vo 3432599 1315566 -2117033 -61.6743%
coq-category-theory/./Functor/Construction/Product/Monoidal.vo 6954179 4861601 -2092578 -30.0909%
coq-hott/./theories/Pointed/Core.vo 4572341 2697314 -1875027 -41.008%
coq-unimath/./UniMath/CategoryTheory/Monoidal/AlternativeDefinitions/EquivalenceWhiskeredNonCurriedMonoidalCategories.vo 5390267 3563601 -1826666 -33.8882%
coq-metacoq-safechecker/./safechecker/theories/PCUICSafeRetyping.vo 5272346 3479978 -1792368 -33.9956%
coq-unimath/./UniMath/CategoryTheory/LocalizingClass.vo 1985890 284914 -1700976 -85.6531%
coq-unimath/./UniMath/CategoryTheory/Inductives/LambdaCalculus.vo 1967417 370596 -1596821 -81.1633%
coq-category-theory/./Construction/Comma/Isomorphism.vo 2010029 442169 -1567860 -78.0019%
coq-unimath/./UniMath/CategoryTheory/DisplayedCats/Isos.vo 2445813 917924 -1527889 -62.4696%

There are also some vosize increases, 10 largest ones:

coq-test-suite/./_build/default/test-suite/bugs/bug_4955.vo 21459 22832 1373 6.39825%
coq-hott/./theories/Classes/interfaces/orders.vo 110453 111953 1500 1.35804%
coq-compcert/./x86/SelectOp.vo 4674598 4676234 1636 0.0349977%
coq-fiat-crypto-with-bedrock/./src/Bedrock/End2End/X25519/Field25519.vo 1925993 1927924 1931 0.10026%
coq-engine-bench-lite/./coq/PerformanceDemos/one_step_reduction.vo 36112 38270 2158 5.97585%
coq-engine-bench-lite/./coq/PerformanceExperiments/one_step_reduction_common.vo 51763 53922 2159 4.17093%
coq-color/./Coccinelle/examples/cime_trace/or_ext_generated.vo 382450 385373 2923 0.764283%
coq-test-suite/./_build/default/test-suite/complexity/constructor.vo 160472 164488 4016 2.50262%
coq-neural-net-interp-computed-lite/./theories/Util/Relations/Relation_Definitions/Dependent.vo 136496 140519 4023 2.94734%
coq-fiat-crypto-with-bedrock/./src/UnsaturatedSolinasHeuristics/Tests.vo 1586642 1611106 24464 1.54187%

@ppedrot
Copy link
Member Author

ppedrot commented May 12, 2024

The increases are probably due to the fact we now have to store a mask for constants. I guess we could find a more compact representation, right now it's a list of booleans. But honestly I think that compared to the other numbers it's premature optimization.

@ppedrot
Copy link
Member Author

ppedrot commented May 12, 2024

The additional good thing with the vo size reduction provided by this PR is that it compounds with #18959, because it's the code itself that gets smaller, not its representation. (cc @silene)

@ppedrot
Copy link
Member Author

ppedrot commented May 12, 2024

For safety, I think that this PR should go after #19015. Indeed on master the VM and native may generate slightly different lambda codes due to different inlining strategies, and this PR relies on the bound rel computation from the VM even for native. I don't think it actually matters, as native optimization is somewhat more aggressive than the VM one, so if a rel doesn't appear in the VM code it shouldn't appear either in the native one, but better safe than sorry.

@ppedrot ppedrot added the kind: performance Improvements to performance and efficiency. label May 12, 2024
@coqbot-app coqbot-app bot added 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 May 13, 2024
@ppedrot ppedrot added needs: merge of dependency This PR depends on another PR being merged first. and removed needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. labels May 13, 2024
@ppedrot ppedrot added request: full CI Use this label when you want your next push to trigger a full CI. and removed needs: merge of dependency This PR depends on another PR being merged first. labels May 16, 2024
@ppedrot ppedrot added this to the 8.20+rc1 milestone May 16, 2024
@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 May 16, 2024
@ppedrot ppedrot marked this pull request as ready for review May 16, 2024 11:51
@ppedrot ppedrot requested review from a team as code owners May 16, 2024 11:51
@ppedrot
Copy link
Member Author

ppedrot commented May 16, 2024

This should be ready now.

@silene
Copy link
Contributor

silene commented May 16, 2024

Just to be sure I understand. On the following code

Definition comma {A B C} (f : A -> B) (g : B -> C) := fun x => g (f x).
Definition double {A} (f : A -> A) := comma f f.
Definition times4 := double (fun x => x + x).

the bytecode for double would now create three arguments out of thin air and pass them to comma instead of passing its first argument? In turn, the first argument of double would be detected as pointless, and this would cause times4 to pass a dummy argument in place of Nat.nat? Could you post the output of Set Dump Bytecode on this example, just so that I can check whether my understanding is correct?

I feel we should go a bit further. (But perhaps this is something you already have in mind for a future pull request.) We should not even pass dummy arguments. We should create two versions of each symbol: one with only meaningful arguments, and the other one which accepts all the arguments, but passes only the meaningful ones to the first version. Then, when we encounter an application of the symbol, there are two possible cases. Either the symbol is applied to sufficiently many arguments (i.e., any extra argument would be meaningful, according to the mask), in which case the first version of the symbol would be invoked. Otherwise, the second symbol is invoked, and meaningless arguments are filled with a dummy value.

This should reduce the size of the bytecode much further. The only case where it would increase is if there is a symbol with some meaningless arguments, but this symbol is never applied, in which a few opcodes would be used to create the closure of the useless version, but no opcode would ever be gained from its (non) application.

kernel/vmbytegen.ml Outdated Show resolved Hide resolved
@ppedrot
Copy link
Member Author

ppedrot commented May 16, 2024

Could you post the output of Set Dump Bytecode

Here it is, although you can already see the effect with Dump Lambda since the PR only touches the constr -> lambda phase. But indeed your analysis is correct.

comma:

closure L0, 0
stop

restart
L0:
grab 5
acc 5
push
acc 4
short_apply 1
push
acc 5
appterm 1, 7

double:

closure L0, 0
stop

restart
L0:
grab 1
acc 1
push
acc 2
push
const 0
push
const 0
push
const 0
push
getglobal Top.comma
appterm 5, 7

times4:

code =
closure L0, 0
push
const 0
push
getglobal Top.double
short_apply 2
stop

L0:
acc 0
push
acc 1
push
getglobal Coq.Init.Nat.add
appterm 2, 3

We should not even pass dummy arguments

I thought about that but decided against, at least for a start. This makes the compilation more involved, but in practice I doubt this would make much difference in the output code. Indeed, what is important for reduction is not so much the arity of closures but rather the fact that we pass huge type annotations that are completely irrelevant for the runtime behaviour. At most you'd get with your enhancement a couple of instructions less for the root irrelevant calls, but everything that is below an irrelevant type barrier doesn't matter.

@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label May 16, 2024
@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 May 16, 2024
let cb = lookup_constant kn env in
begin match cb.const_body with
| Primitive op -> lambda_of_prim env c op (lambda_of_args cache env sigma 0 args)
| Def csubst -> (* TODO optimize if f is a proj and argument is known *)
if cb.const_inline_code then lambda_of_app cache env sigma csubst args
else
mkLapp (Lconst (kn, u)) (lambda_of_args cache env sigma 0 args)
(* Erase unused arguments *)
let mask = Array.of_list mask in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should just store mask as an array of boolean right from the start. Keeping it as a list and converting it again and again to an array is a waste of cycles and memory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ppedrot ppedrot added the request: full CI Use this label when you want your next push to trigger a full CI. label May 16, 2024
We replace arguments that do not appear in the lambda body of constants
by a dummy constant value. The rationale is that most arguments in symbolic
code are type annotations that have no computational content, hence there is
no point in generating them in the first place.

This patch seems to have wonderful effects on degenerate examples from UniMath.
@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 May 16, 2024
Copy link
Contributor

@silene silene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the mask has been trimmed and turned into an array, it could be interesting to rerun a bench. But it is not mandatory.

@SkySkimmer
Copy link
Contributor

@coqbot bench

@SkySkimmer SkySkimmer self-assigned this May 17, 2024
@ppedrot
Copy link
Member Author

ppedrot commented May 17, 2024

Personally I think this will not change anything performance-wise.

@silene
Copy link
Contributor

silene commented May 17, 2024

I am not really concerned about performance. I am more interested in knowing whether we still need a followup pull request that uses a bitvector instead of an array of booleans.

@ppedrot
Copy link
Member Author

ppedrot commented May 17, 2024

Why would it matter? The mask is typically small, as it's bounded by the syntactic arity of the definition, and it is stored at toplevel in a single place for every constant. Even the process of creating it from the list at runtime for every constant found in the lambda code is probably cheap.

@silene
Copy link
Contributor

silene commented May 17, 2024

It matters because some .vo files have grown by several tens of kilobytes. So, I dispute your "typically small".

Copy link
Contributor

coqbot-app bot commented May 18, 2024

🏁 Bench results:

┌─────────────────────────────────────┬──────────────────────────┬────────────────────────────────────────┬────────────────────────────────────────┬─────────────────────────┐
│                                     │      user time [s]       │               CPU cycles               │            CPU instructions            │  max resident mem [KB]  │
│                                     │                          │                                        │                                        │                         │
│            package_name             │   NEW      OLD    PDIFF  │      NEW             OLD        PDIFF  │      NEW             OLD        PDIFF  │   NEW      OLD    PDIFF │
├─────────────────────────────────────┼──────────────────────────┼────────────────────────────────────────┼────────────────────────────────────────┼─────────────────────────┤
│ coq-neural-net-interp-computed-lite │  263.05   310.34  -15.24 │  1198780780228   1415413026865  -15.31 │  3208670518100   3618026255246  -11.31 │ 1114948  1113092   0.17 │
│        coq-fiat-crypto-with-bedrock │ 5961.68  6235.87   -4.40 │ 26994968879614  28249966975887   -4.44 │ 48718367244038  51224369222208   -4.89 │ 3246064  3246004   0.00 │
│                    coq-fiat-parsers │  309.43   314.47   -1.60 │  1370155655118   1393741772561   -1.69 │  2433457313883   2487610099610   -2.18 │ 2481736  2415764   2.73 │
│            coq-metacoq-translations │   17.04    17.26   -1.27 │    75356107049     75774580851   -0.55 │   125012045135    125086065035   -0.06 │  843508   844696  -0.14 │
│                        coq-bedrock2 │  361.53   364.70   -0.87 │  1632414366363   1643974987181   -0.70 │  3109637936066   3110761735620   -0.04 │  859944   859884   0.01 │
│                            coq-core │  129.48   130.35   -0.67 │   499684927714    501126714401   -0.29 │   531851540975    531696372518    0.03 │  457928   458076  -0.03 │
│                      coq-coquelicot │   39.72    39.93   -0.53 │   175594045608    176808148041   -0.69 │   249098263632    249122854449   -0.01 │  852292   852672  -0.04 │
│                            coq-hott │  161.06   161.71   -0.40 │   714438907544    717615638093   -0.44 │  1138615907315   1147847031743   -0.80 │  478760   480444  -0.35 │
│         coq-rewriter-perf-SuperFast │  793.50   796.67   -0.40 │  3545447879814   3560874758241   -0.43 │  6226542659670   6257224398361   -0.49 │ 1577420  1576340   0.07 │
│                   coq-iris-examples │  467.32   468.96   -0.35 │  2114827808831   2122557177849   -0.36 │  3274995901523   3275769309612   -0.02 │ 1115124  1117272  -0.19 │
│                        coq-rewriter │  390.32   391.38   -0.27 │  1759881237208   1764410308599   -0.26 │  2975612219557   2990847128086   -0.51 │ 1476924  1480068  -0.21 │
│                           coq-verdi │   49.08    49.21   -0.26 │   219993919690    219401169810    0.27 │   340673052428    340736486513   -0.02 │  533944   530968   0.56 │
│                    coq-math-classes │   85.91    86.13   -0.26 │   384456960721    384390628965    0.02 │   536835259359    536897343872   -0.01 │  502920   503852  -0.18 │
│                        coq-coqprime │   48.37    48.49   -0.25 │   215627547122    216029758165   -0.19 │   334627663073    334613875829    0.00 │  784152   784368  -0.03 │
│                             coq-vst │  881.43   883.37   -0.22 │  3984513710785   3994167070708   -0.24 │  6740007010550   6741048882659   -0.02 │ 2166768  2162664   0.19 │
│                         coq-unimath │ 2466.99  2471.83   -0.20 │ 11184796500512  11202685078373   -0.16 │ 22179148128677  22210316306157   -0.14 │ 1254504  1254464   0.00 │
│                           coq-color │  251.44   251.82   -0.15 │  1123050525402   1123308117833   -0.02 │  1632377383159   1632935937041   -0.03 │ 1161840  1174336  -1.06 │
│               coq-engine-bench-lite │  157.43   157.64   -0.13 │   661266150498    661657263001   -0.06 │  1228735119843   1224601927854    0.34 │ 1229544  1324380  -7.16 │
│                            coq-corn │  715.68   716.03   -0.05 │  3237431618423   3240328735925   -0.09 │  5076764149683   5077665381034   -0.02 │  753396   754412  -0.13 │
│                coq-mathcomp-algebra │  260.49   260.57   -0.03 │  1178227438177   1177127594107    0.09 │  2000288495108   2000321854265   -0.00 │ 1339308  1337376   0.14 │
│              coq-mathcomp-ssreflect │  220.27   220.32   -0.02 │   993608337344    993714870356   -0.01 │  1675646060638   1675425543098    0.01 │ 1728924  1722516   0.37 │
│                  coq-mathcomp-field │  142.54   142.57   -0.02 │   643650646720    643399452517    0.04 │  1074412034389   1074339082064    0.01 │ 1487884  1485508   0.16 │
│                       coq-fourcolor │ 1404.28  1404.39   -0.01 │  6391361326492   6392035187946   -0.01 │ 13505790466888  13510634464012   -0.04 │ 2141524  2137636   0.18 │
│                       coq-fiat-core │   60.11    60.04    0.12 │   248062353992    248221172208   -0.06 │   368603550791    368749628521   -0.04 │  482452   487168  -0.97 │
│                       coq-equations │    7.70     7.69    0.13 │    31234187017     31217901828    0.05 │    50923487770     50948414688   -0.05 │  387396   387268   0.03 │
│                   coq-metacoq-pcuic │  988.08   986.47    0.16 │  4407906885239   4399075300117    0.20 │  6468701661837   6472253538828   -0.05 │ 2678952  2679656  -0.03 │
│                          coq-stdlib │  354.20   353.57    0.18 │  1483808053973   1479885421800    0.27 │  1258400465007   1258609924257   -0.02 │  716344   717716  -0.19 │
│                        coq-compcert │  282.25   281.70    0.20 │  1267165466878   1267692027460   -0.04 │  1940245512330   1945053821663   -0.25 │ 1136420  1104852   2.86 │
│                 coq-metacoq-erasure │  505.15   503.80    0.27 │  2286849923693   2281525090192    0.23 │  3581838406116   3581936532830   -0.00 │ 2084948  2101920  -0.81 │
│               coq-mathcomp-fingroup │   30.58    30.49    0.30 │   138539152324    138468476427    0.05 │   207657641124    207735658217   -0.04 │  568732   567348   0.24 │
│                      coq-verdi-raft │  583.32   581.28    0.35 │  2647646627447   2638492160863    0.35 │  4161299976501   4161671225883   -0.01 │  848136   847664   0.06 │
│                coq-metacoq-template │  152.22   151.60    0.41 │   667810183930    667890525316   -0.01 │  1046619993460   1046813804711   -0.02 │ 1511616  1516440  -0.32 │
│                 coq-category-theory │  692.39   689.23    0.46 │  3133163579938   3121324080119    0.38 │  5254429386453   5264263463005   -0.19 │  955308   957144  -0.19 │
│              coq-mathcomp-character │  109.02   108.49    0.49 │   495460546265    493129973961    0.47 │   790292644885    790442967864   -0.02 │ 1135804  1136268  -0.04 │
│                         coq-coqutil │   42.76    42.55    0.49 │   186957990542    187287990374   -0.18 │   270809207300    270948794489   -0.05 │  561464   563756  -0.41 │
│                         coq-bignums │   29.43    29.26    0.58 │   132854727547    132413988109    0.33 │   192268156847    192261670954    0.00 │  472588   480156  -1.58 │
│             coq-metacoq-safechecker │  421.14   418.57    0.61 │  1920410075672   1907682139523    0.67 │  3179378232841   3184797755515   -0.17 │ 2038192  2083936  -2.20 │
│          coq-performance-tests-lite │  713.72   708.23    0.78 │  3195353887072   3171180231227    0.76 │  5684584603880   5682584810946    0.04 │ 2275860  2275460   0.02 │
│               coq-mathcomp-solvable │  118.86   117.82    0.88 │   541019510894    535973866878    0.94 │   856253033197    857137044933   -0.10 │  876676   879208  -0.29 │
│              coq-mathcomp-odd-order │  783.94   776.49    0.96 │  3579462012743   3545746057046    0.95 │  6077642488345   6078467939596   -0.01 │ 1654908  1652984   0.12 │
└─────────────────────────────────────┴──────────────────────────┴────────────────────────────────────────┴────────────────────────────────────────┴─────────────────────────┘

INFO: failed to install
coq-test-suite

🐢 Top 25 slow downs
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                 TOP 25 SLOW DOWNS                                                                 │
│                                                                                                                                                   │
│   OLD       NEW      DIFF   %DIFF    Ln                      FILE                                                                                 │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  94.5620   96.3910  1.8290   1.93%   999  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html                         │
│   5.4880    7.0710  1.5830  28.84%   196  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html                    │
│  76.2380   77.7920  1.5540   2.04%   365  coq-mathcomp-odd-order/theories/PFsection4.v.html                                                       │
│  94.7460   96.0670  1.3210   1.39%   968  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html                         │
│   3.7970    4.9380  1.1410  30.05%    22  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html                                  │
│  66.5220   67.5160  0.9940   1.49%    27  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html                                │
│ 216.6140  217.5890  0.9750   0.45%   103  coq-fiat-crypto-with-bedrock/src/Arithmetic/BarrettReduction.v.html                                     │
│ 154.4160  155.3910  0.9750   0.63%  1190  coq-unimath/UniMath/CategoryTheory/GrothendieckConstruction/IsPullback.v.html                           │
│ 181.2390  182.1060  0.8670   0.48%   233  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/DecodeByExtension.v.html │
│   2.6510    3.4050  0.7540  28.44%    34  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html                                  │
│  63.4400   64.1840  0.7440   1.17%   368  coq-mathcomp-odd-order/theories/PFsection4.v.html                                                       │
│ 138.6420  139.2270  0.5850   0.42%   155  coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html                              │
│  24.3720   24.8360  0.4640   1.90%    85  coq-fiat-crypto-with-bedrock/src/Curves/Montgomery/AffineProofs.v.html                                  │
│  25.1660   25.5700  0.4040   1.61%    24  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/MultiRetSplit.v.html                                   │
│ 101.1090  101.5020  0.3930   0.39%    20  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html                                             │
│  23.4380   23.8270  0.3890   1.66%    23  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/Arith.v.html                                           │
│   4.7410    5.1230  0.3820   8.06%   237  coq-fiat-parsers/src/Parsers/ParserFromParserADT.v.html                                                 │
│  16.8240   17.1920  0.3680   2.19%    24  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/MulSplit.v.html                                        │
│  33.8250   34.1920  0.3670   1.08%   839  coq-unimath/UniMath/CategoryTheory/GrothendieckConstruction/IsPullback.v.html                           │
│   0.3340    0.6650  0.3310  99.10%   868  coq-stdlib/MSets/MSetRBT.v.html                                                                         │
│ 242.5260  242.8410  0.3150   0.13%   141  coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html                              │
│   9.5990    9.8930  0.2940   3.06%    87  coq-engine-bench-lite/coq/PerformanceDemos/quadratic_reduction.v.html                                   │
│  17.6750   17.9580  0.2830   1.60%    32  coq-performance-tests-lite/src/pattern.v.html                                                           │
│  12.6230   12.9040  0.2810   2.23%  1555  coq-fiat-crypto-with-bedrock/src/Util/FSets/FMapTrie.v.html                                             │
│  30.2910   30.5610  0.2700   0.89%    12  coq-fourcolor/theories/job165to189.v.html                                                               │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                             TOP 25 SPEED UPS                                                              │
│                                                                                                                                           │
│   OLD       NEW       DIFF     %DIFF   Ln                    FILE                                                                         │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 268.2550  221.1870  -47.0680  -17.55%    8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │
│  23.7330    0.1500  -23.5830  -99.37%  121  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  23.5890    0.1900  -23.3990  -99.19%  130  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  26.9430   13.5480  -13.3950  -49.72%   22  coq-fiat-crypto-with-bedrock/src/Spec/Test/X25519.v.html                                      │
│  26.9310   13.5880  -13.3430  -49.55%   17  coq-fiat-crypto-with-bedrock/src/Spec/Test/X25519.v.html                                      │
│  15.8110    3.9420  -11.8690  -75.07%   33  coq-fiat-crypto-with-bedrock/src/Curves/EdwardsMontgomery25519.v.html                         │
│  12.2320    0.4750  -11.7570  -96.12%  130  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  12.0810    0.4970  -11.5840  -95.89%  121  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.3540    0.0080  -11.3460  -99.93%  179  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.3900    0.0780  -11.3120  -99.32%  178  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.2950    0.0060  -11.2890  -99.95%  162  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.3240    0.0450  -11.2790  -99.60%  161  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.5420    0.3090  -11.2330  -97.32%  181  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  11.4570    0.2380  -11.2190  -97.92%  166  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  21.1310   10.5970  -10.5340  -49.85%   25  coq-fiat-crypto-with-bedrock/src/Spec/Test/X25519.v.html                                      │
│  10.4580    2.2810   -8.1770  -78.19%   78  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/Field25519.v.html                     │
│   8.8840    0.7280   -8.1560  -91.81%   78  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/Field25519.v.html                     │
│  15.3620    7.7100   -7.6520  -49.81%   99  coq-fiat-crypto-with-bedrock/src/Spec/Curve25519.v.html                                       │
│  53.0150   46.3100   -6.7050  -12.65%   50  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  50.5470   44.1120   -6.4350  -12.73%   50  coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/Examples/p224_64_new.v.html          │
│  14.0070    8.0690   -5.9380  -42.39%   12  coq-fiat-crypto-with-bedrock/src/Spec/Test/X25519.v.html                                      │
│  16.2090   10.2870   -5.9220  -36.54%   25  coq-fiat-crypto-with-bedrock/src/Curves/EdwardsMontgomery25519.v.html                         │
│  41.9310   37.4040   -4.5270  -10.80%  139  coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html                                  │
│   5.1190    1.1740   -3.9450  -77.07%  150  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/Field25519.v.html                     │
│   5.1610    1.2970   -3.8640  -74.87%   96  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/Field25519.v.html                     │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@ppedrot
Copy link
Member Author

ppedrot commented May 18, 2024

Ten biggest increases with the last version:

coq-fiat-crypto-with-bedrock/./src/UnsaturatedSolinasHeuristics/Tests.vo 1606508 1611862 -5354 (0%)
coq-fiat-crypto-with-bedrock/./src/Bedrock/Field/Synthesis/Examples/p224_64_new.vo 2343536 2348044 -4508 (0%)
coq-engine-bench-lite/./coq/PerformanceExperiments/one_step_reduction_common.vo 51750 53916 -2166 (4%)
coq-engine-bench-lite/./coq/PerformanceDemos/one_step_reduction.vo 36107 38271 -2164 (6%)
coq-neural-net-interp-computed-lite/./theories/Util/Relations/Relation_Definitions/Dependent.vo 136451 138547 -2096 (2%)
coq-fiat-crypto-with-bedrock/./src/Bedrock/End2End/Poly1305/Field1305.vo 519301 520495 -1194 (0%)
coq-math-classes/./theory/adjunctions.vo 81237 82199 -962 (1%)
coq-mathcomp-ssreflect/./mathcomp/ssreflect/bigop.vo 915310 916138 -828 (0%)
coq-color/./Coccinelle/examples/cime_trace/or_ext_generated.vo 380162 380954 -792 (0%)
coq-compcert/./x86/SelectOp.vo 3836451 3837039 -588 (0%)

@silene
Copy link
Contributor

silene commented May 18, 2024

Does that ring a bell?

[ERROR] The compilation of coq-test-suite.dev failed at "dune build -p coq -j 1 --promote-install-files=false @runtest".
...
- output/ltac2_unused_var.v...Error! (unexpected output)
...
- File "./bugs/bug_11766.v", line 10, characters 0-8:
- Error:  Universe bug_11766.1 (File "./bugs/bug_11766.v", line 9, characters 19-23) is unbound.
...
- File "./ltac2/std_tactics.v", line 134, characters 2-26:
- Error: Anomaly "in retyping: Not a type."
...
ocamlfind: Package `ounit2' not found

@SkySkimmer
Copy link
Contributor

Running the test suite as a separate package means we don't need special code to skip it when t fails, but it also means we get the test suite from master even though we're testing some other commit. So when a bug is newly fixed in master its test fails.

@SkySkimmer
Copy link
Contributor

@coqbot merge now

@coqbot-app coqbot-app bot merged commit 562ff17 into coq:master May 21, 2024
6 of 8 checks passed
@ppedrot ppedrot deleted the vm-skip-dummy-args branch May 21, 2024 13:00
@SkySkimmer
Copy link
Contributor

Should this have had a changelog? It can be nice to advertise significant performance boosts.

@ppedrot
Copy link
Member Author

ppedrot commented May 21, 2024

Maybe the VM enhancements should be mentioned in the release notes, but a single changelog seems a bit too much.

@SkySkimmer
Copy link
Contributor

This change does mean that

Unset Guard Checking.

Fixpoint loop (x:unit) : unit := loop x.

Definition ignore {A} (x:A) := tt.

Eval vm_compute in ignore (loop tt).

will behave differently (you can also replace the unsafe loop with a safe function which terminates after a long time)

@ppedrot
Copy link
Member Author

ppedrot commented May 21, 2024

Repeat after me: CIC is call-by-name.

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. part: native compiler part: VM Virtual machine.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants