Skip to content

Add a fast path in Mod_subst.reroot. - #22421

Open
ppedrot wants to merge 1 commit into
rocq-prover:masterfrom
ppedrot:module-reroot-fast-path
Open

Add a fast path in Mod_subst.reroot.#22421
ppedrot wants to merge 1 commit into
rocq-prover:masterfrom
ppedrot:module-reroot-fast-path

Conversation

@ppedrot

@ppedrot ppedrot commented Aug 29, 2026

Copy link
Copy Markdown
Member

There is no point in rerooting if the root of the δ-resolver is already the path at which we want to reroot. While not a silver bullet, it really mitigates #22420, which goes from ~22 seconds to ~5 seconds on my machine.

There is no point in rerooting if the root of the δ-resolver is already
the path at which we want to reroot. While not a silver bullet, it really
mitigates rocq-prover#22420, which goes from ~22 seconds to ~5 seconds on my machine.
@ppedrot ppedrot added this to the 9.4+rc1 milestone Aug 29, 2026
@ppedrot
ppedrot requested a review from a team as a code owner August 29, 2026 16:19
@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. labels Aug 29, 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 Aug 29, 2026
@ppedrot

ppedrot commented Aug 29, 2026

Copy link
Copy Markdown
Member Author

@coqbot bench

@ppedrot

ppedrot commented Aug 29, 2026

Copy link
Copy Markdown
Member Author

cc @ebmoon, I don't know if it helps for your practical examples.

@coqbot-app

coqbot-app Bot commented Aug 30, 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-equations │    8.46     8.70  -2.76 │    55029924241     55050396393  -0.04 │  422012   422468  -0.11 │
│          coq-performance-tests-lite │  892.78   903.05  -1.14 │  6917525435637   6921237637700  -0.05 │ 1595452  1556472   2.50 │
│                           rocq-elpi │   17.63    17.75  -0.68 │   118218784435    118219156844  -0.00 │  491732   491428   0.06 │
│                  rocq-mathcomp-boot │   40.87    41.11  -0.58 │   230727695866    230773663416  -0.02 │  664460   664720  -0.04 │
│                           rocq-core │    9.56     9.61  -0.52 │    61760955251     61744311241   0.03 │  550412   550580  -0.03 │
│                 rocq-metarocq-utils │   25.53    25.63  -0.39 │   153929011704    154192977580  -0.17 │  620772   621264  -0.08 │
│                   coq-iris-examples │  384.39   385.73  -0.35 │  2372263314350   2374279660159  -0.08 │ 1096712  1101604  -0.44 │
│                           coq-color │  241.58   242.26  -0.28 │  1423659879638   1426086505864  -0.17 │ 1196132  1195612   0.04 │
│                        rocq-bignums │   26.36    26.43  -0.26 │   158286215086    158671940141  -0.24 │  458068   458332  -0.06 │
│                    coq-fiat-parsers │  284.72   285.42  -0.25 │  2066803697705   2070828514665  -0.19 │ 2262516  2252808   0.43 │
│                        rocq-runtime │   76.10    76.28  -0.24 │   555622364824    555469463445   0.03 │  542652   542748  -0.02 │
│                rocq-metarocq-common │   42.93    43.03  -0.23 │   262646894152    263196136271  -0.21 │  941212   941800  -0.06 │
│         coq-rewriter-perf-SuperFast │  473.18   474.15  -0.20 │  3504355265792   3506633373171  -0.06 │ 1265976  1283300  -1.35 │
│ coq-neural-net-interp-computed-lite │  239.51   239.91  -0.17 │  2244671619300   2245271719097  -0.03 │  840028   840920  -0.11 │
│                            coq-corn │  666.12   667.21  -0.16 │  4273076843835   4277335619979  -0.10 │  663064   661732   0.20 │
│                    coq-math-classes │   86.82    86.96  -0.16 │   491285829925    492116179134  -0.17 │  547064   548344  -0.23 │
│                        coq-bedrock2 │  342.66   343.09  -0.13 │  2671203935197   2675017635274  -0.14 │  856452   856324   0.01 │
│                         rocq-stdlib │  252.91   253.22  -0.12 │  1468751281561   1471166847332  -0.16 │  756780   757364  -0.08 │
│                 coq-category-theory │ 1436.30  1438.01  -0.12 │  9999203877427  10004893641483  -0.06 │ 6744956  6744560   0.01 │
│                       coq-fiat-core │   60.40    60.47  -0.12 │   339579323206    340718615242  -0.33 │  479688   480476  -0.16 │
│                 rocq-mathcomp-field │  210.57   210.81  -0.11 │  1424961781007   1425031283057  -0.00 │ 2225040  2224888   0.01 │
│                       coq-fourcolor │ 1373.60  1374.89  -0.09 │ 12377583827274  12389789440735  -0.10 │ 1008800  1026764  -1.75 │
│              rocq-mathcomp-solvable │  102.12   102.18  -0.06 │   653062747826    653061564350   0.00 │ 1077348  1076812   0.05 │
│                        coq-rewriter │  336.76   336.87  -0.03 │  2414692766766   2415055283179  -0.02 │ 1508072  1490436   1.18 │
│               coq-engine-bench-lite │  128.83   128.87  -0.03 │   940330165559    937356191241   0.32 │ 1162972  1163288  -0.03 │
│                            coq-core │    2.80     2.80   0.00 │    19355616051     19321779933   0.18 │  114352   114188   0.14 │
│                         coq-coqutil │   50.84    50.84   0.00 │   293113846411    293849748856  -0.25 │  562096   562652  -0.10 │
│                             coq-vst │  834.57   834.44   0.02 │  5988019745216   5991429140241  -0.06 │ 2005248  2004820   0.02 │
│               rocq-mathcomp-algebra │  376.18   376.12   0.02 │  2566443748094   2566371133135   0.00 │ 1564012  1564024  -0.00 │
│              coq-mathcomp-odd-order │  626.36   626.07   0.05 │  4194973052057   4194975891638  -0.00 │ 2700284  2714088  -0.51 │
│                            coq-hott │  170.72   170.64   0.05 │  1054972967469   1054943529454   0.00 │  470360   470264   0.02 │
│                         coq-unimath │ 1988.79  1987.33   0.07 │ 15812779246023  15812626708950   0.00 │ 1861940  1862128  -0.01 │
│                 rocq-metarocq-pcuic │  622.08   621.23   0.14 │  3801968760549   3804755161962  -0.07 │ 1727248  1727164   0.00 │
│               rocq-metarocq-erasure │  451.05   450.37   0.15 │  2930169467393   2930855860671  -0.02 │ 1857808  1860848  -0.16 │
│        coq-fiat-crypto-with-bedrock │ 8352.47  8339.66   0.15 │ 67670554005900  67693552050821  -0.03 │ 3970156  3985364  -0.38 │
│           rocq-metarocq-safechecker │  316.04   315.52   0.16 │  2281516128300   2281736866539  -0.01 │ 1755716  1756956  -0.07 │
│                 rocq-mathcomp-order │  100.84   100.67   0.17 │   686152828868    686200169436  -0.01 │  917748   917988  -0.03 │
│              rocq-mathcomp-analysis │ 1460.68  1457.17   0.24 │ 10267466391674  10266987999018   0.00 │ 2192752  2192572   0.01 │
│              rocq-metarocq-template │   83.62    83.41   0.25 │   553889885645    553409062379   0.09 │ 1157692  1149340   0.73 │
│                        coq-coqprime │   57.83    57.63   0.35 │   377495908187    377971484301  -0.13 │  828528   828208   0.04 │
│                        coq-compcert │  316.82   315.65   0.37 │  1963054739414   1964984520444  -0.10 │ 1235364  1232284   0.25 │
│  rocq-mathcomp-group-representation │   99.66    99.24   0.42 │   658255416392    658318247966  -0.01 │ 1519388  1519088   0.02 │
│          rocq-mathcomp-finite-group │   27.65    27.52   0.47 │   170730338684    170720657621   0.01 │  569328   569316   0.00 │
│          rocq-metarocq-translations │   17.35    17.23   0.70 │   113461950031    113680946582  -0.19 │  916848   919124  -0.25 │
│             rocq-mathcomp-ssreflect │    1.24     1.23   0.81 │     7471181065      7422117944   0.66 │  611180   611512  -0.05 │
└─────────────────────────────────────┴─────────────────────────┴───────────────────────────────────────┴─────────────────────────┘

INFO: failed to install
coq-coquelicot (dependency install failed in NEW)

🐢 Top 25 slow downs
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                             TOP 25 SLOW DOWNS                                                             │
│                                                                                                                                           │
│   OLD     NEW    DIFF    %DIFF     Ln                     FILE                                                                            │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│    62.4   63.9  1.4476     2.32%   857  rocq-mathcomp-analysis/theories/lebesgue_integral_theory/lebesgue_integral_differentiation.v.html │
│     127    128  0.7322     0.58%   659  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html                             │
│    90.9   91.5  0.5817     0.64%   999  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html                   │
│    66.1   66.6  0.4914     0.74%   608  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html     │
│    53.2   53.7  0.4839     0.91%   567  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/EdwardsXYZT.v.html                        │
│    18.5   19.0  0.4741     2.57%    31  coq-engine-bench-lite/coq/PerformanceDemos/pattern.v.html                                         │
│    9.37   9.84  0.4725     5.04%   436  coq-mathcomp-odd-order/theories/PFsection12.v.html                                                │
│    43.0   43.4  0.4576     1.07%   539  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/EdwardsXYZT.v.html                        │
│    11.8   12.3  0.4547     3.85%  1828  rocq-mathcomp-analysis/theories/ftc.v.html                                                        │
│    65.9   66.3  0.4508     0.68%   794  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html                              │
│    68.0   68.5  0.4501     0.66%   596  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html                             │
│    90.9   91.3  0.4471     0.49%   968  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html                   │
│     107    107  0.4430     0.41%   255  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                     │
│    13.6   14.1  0.4423     3.24%   925  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoor.v.html                         │
│    53.8   54.2  0.4385     0.82%   776  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html                              │
│    27.3   27.7  0.4368     1.60%    13  coq-fourcolor/theories/proof/job611to617.v.html                                                   │
│    26.3   26.7  0.3856     1.46%    62  coq-fiat-crypto-with-bedrock/src/Assembly/Parse/TestAsm.v.html                                    │
│ 0.00970  0.379  0.3697  3813.75%   111  rocq-mathcomp-analysis/theories/lebesgue_integral_theory/lebesgue_integral_differentiation.v.html │
│    65.5   65.8  0.3470     0.53%   305  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/Addchain.v.html                                │
│    24.8   25.2  0.3417     1.38%    49  coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html                           │
│    43.5   43.9  0.3289     0.76%   221  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                      │
│    50.9   51.3  0.3232     0.63%    27  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html                          │
│    32.3   32.6  0.3149     0.98%   255  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html                                        │
│    18.7   19.0  0.3101     1.66%    77  coq-fiat-crypto-with-bedrock/src/Assembly/Parse/TestAsm.v.html                                    │
│    10.4   10.7  0.3057     2.94%  2852  coq-fiat-crypto-with-bedrock/src/Assembly/EquivalenceProofs.v.html                                │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                             TOP 25 SPEED UPS                                                              │
│                                                                                                                                           │
│  OLD     NEW      DIFF     %DIFF   Ln                     FILE                                                                            │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  18.8      17.2  -1.5558   -8.28%  670  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  12.6      11.6  -1.0376   -8.24%  531  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  8.54      7.79  -0.7465   -8.74%  428  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  6.85      6.23  -0.6207   -9.07%  658  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  48.6      48.0  -0.5574   -1.15%    3  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/WithBedrock/fiat_crypto.v.html               │
│  5.01      4.48  -0.5279  -10.55%  330  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  46.8      46.3  -0.4702   -1.00%    2  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/fiat_crypto.v.html                           │
│ 0.386   0.00146  -0.3847  -99.62%  161  rocq-mathcomp-analysis/theories/derive.v.html                                                     │
│ 0.377  0.000687  -0.3766  -99.82%  183  rocq-mathcomp-analysis/theories/sequences.v.html                                                  │
│  3.61      3.24  -0.3707  -10.25%  462  coq-performance-tests-lite/src/Nia.v.html                                                         │
│ 0.372   0.00347  -0.3690  -99.07%  112  rocq-mathcomp-analysis/theories/lebesgue_integral_theory/lebesgue_integral_differentiation.v.html │
│  20.8      20.5  -0.3686   -1.77%  560  coq-mathcomp-odd-order/theories/PFsection9.v.html                                                 │
│  48.7      48.3  -0.3573   -0.73%    3  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/bedrock2_fiat_crypto.v.html                  │
│  31.5      31.1  -0.3523   -1.12%  656  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html                              │
│  22.2      21.8  -0.3487   -1.57%   13  coq-fourcolor/theories/proof/job542to545.v.html                                                   │
│  7.27      6.95  -0.3193   -4.39%  594  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  1.32      1.01  -0.3039  -23.11%  127  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/Poly1305/Field1305.v.html                        │
│   203       203  -0.3026   -0.15%    8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html     │
│  2.80      2.50  -0.2998  -10.71%  108  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  4.53      4.24  -0.2964   -6.54%  814  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  4.52      4.23  -0.2962   -6.55%  815  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  23.5      23.2  -0.2957   -1.26%  743  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JoyeLadder.v.html                              │
│ 0.295   0.00116  -0.2936  -99.61%  251  rocq-mathcomp-analysis/theories/measure_theory/measurable_structure.v.html                        │
│  4.58      4.29  -0.2862   -6.25%  813  coq-performance-tests-lite/src/Nia.v.html                                                         │
│  1.73      1.45  -0.2840  -16.37%    4  rocq-mathcomp-analysis/theories/pi_irrational.v.html                                              │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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.

1 participant