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
[stm] fix regression introduced in de2d782 #17743
Conversation
The finish API is called both by clients and internally by the STM whenever a VtNow command is executed to obtain the new parsing state. Commit de2d782 makes finish cache the state, which is not a problem if do it once, but may increase memory consumption substantially when checking documents containing many commands classified as VtNow.
@coqbot bench |
Successfully tested on order.v in MathComp. |
It may be worth backporting to 8.17 if a new point release is to happen, CC @Zimmi48 |
Sure, I was planning an 8.17.1 release, but this fix is even a good justification in itself to do it. |
Do we know why mathcomp is particularly impacted? Are there that much more notations than elsewhere? |
🏁 Bench results:
INFO: failed to install 🐢 Top 25 slow downs┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SLOW DOWNS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 41.3820 45.6070 4.2250 10.21% 1002 coq-perennial/src/program_proof/simplepb/pb_apply_proof.v.html │ │ 31.0840 33.8430 2.7590 8.88% 1730 coq-perennial/src/program_proof/simplepb/simplelog/proof.v.html │ │ 21.8120 24.2930 2.4810 11.37% 667 coq-perennial/src/program_proof/simplepb/pb_roapply_proof.v.html │ │ 20.4750 22.8750 2.4000 11.72% 1357 coq-perennial/src/program_proof/wal/installer_proof.v.html │ │ 45.5530 46.7840 1.2310 2.70% 558 coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/insertionsort.v.html │ │ 5.5400 6.3550 0.8150 14.71% 1391 coq-perennial/src/program_proof/aof/proof.v.html │ │ 80.9060 81.5720 0.6660 0.82% 618 coq-bedrock2/bedrock2/src/bedrock2Examples/lightbulb.v.html │ │ 3.7540 4.3010 0.5470 14.57% 5 coq-mathcomp-algebra/mathcomp/algebra/ssrint.v.html │ │ 39.7310 40.2640 0.5330 1.34% 827 coq-vst/veric/binop_lemmas4.v.html │ │ 4.7070 5.1950 0.4880 10.37% 1470 coq-perennial/src/program_proof/simplepb/apps/eesm_proof.v.html │ │ 60.9800 61.4270 0.4470 0.73% 139 coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html │ │ 128.6070 128.9930 0.3860 0.30% 999 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 27.6350 28.0130 0.3780 1.37% 12 coq-fourcolor/theories/job223to226.v.html │ │ 13.3730 13.7410 0.3680 2.75% 187 coq-perennial/src/goose_lang/interpreter/disk_interpreter.v.html │ │ 5.3410 5.7040 0.3630 6.80% 429 coq-perennial/src/program_proof/grove_shared/urpc_proof.v.html │ │ 42.9060 43.2680 0.3620 0.84% 236 coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap.v.html │ │ 30.9690 31.3250 0.3560 1.15% 577 coq-perennial/src/program_proof/simplepb/pb_becomeprimary_proof.v.html │ │ 128.9970 129.3490 0.3520 0.27% 968 coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html │ │ 50.0710 50.4000 0.3290 0.66% 365 coq-mathcomp-odd-order/theories/PFsection4.v.html │ │ 2.9250 3.2490 0.3240 11.08% 1409 coq-perennial/src/program_proof/wal/installer_proof.v.html │ │ 2.0560 2.3800 0.3240 15.76% 209 coq-stdlib/setoid_ring/Ncring_tac.v.html │ │ 0.0330 0.3520 0.3190 966.67% 279 coq-perennial/src/program_proof/wal/circ_proof_crash.v.html │ │ 0.0300 0.3390 0.3090 1030.00% 509 coq-fiat-crypto-with-bedrock/src/Bedrock/Field/Synthesis/New/UnsaturatedSolinas.v.html │ │ 1.2670 1.5620 0.2950 23.28% 1874 coq-perennial/src/program_proof/wal/recovery_proof.v.html │ │ 0.5270 0.8080 0.2810 53.32% 422 coq-stdlib/MSets/MSetList.v.html │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 🐇 Top 25 speed ups┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TOP 25 SPEED UPS │ │ │ │ OLD NEW DIFF %DIFF Ln FILE │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ 59.8310 58.8770 -0.9540 -1.59% 27 coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html │ │ 142.3870 141.5810 -0.8060 -0.57% 1190 coq-unimath/UniMath/CategoryTheory/GrothendieckConstruction/IsPullback.v.html │ │ 25.8210 25.0990 -0.7220 -2.80% 2293 coq-perennial/src/goose_lang/logical_reln_fund.v.html │ │ 29.8430 29.1830 -0.6600 -2.21% 12 coq-fourcolor/theories/job287to290.v.html │ │ 17.2040 16.5760 -0.6280 -3.65% 3269 coq-fiat-crypto-with-bedrock/src/Assembly/WithBedrock/Proofs.v.html │ │ 3.2940 2.7580 -0.5360 -16.27% 487 coq-stdlib/Numbers/HexadecimalFacts.v.html │ │ 27.5300 27.0300 -0.5000 -1.82% 12 coq-fourcolor/theories/job227to230.v.html │ │ 52.0230 51.5940 -0.4290 -0.82% 915 coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoor.v.html │ │ 24.5460 24.1180 -0.4280 -1.74% 12 coq-fourcolor/theories/job384to398.v.html │ │ 9.1290 8.7040 -0.4250 -4.66% 1508 coq-perennial/src/program_proof/wal/recovery_proof.v.html │ │ 43.0380 42.6160 -0.4220 -0.98% 236 coq-rewriter/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap.v.html │ │ 4.5600 4.1560 -0.4040 -8.86% 1388 coq-perennial/src/program_proof/simplepb/apps/eesm_proof.v.html │ │ 1.5200 1.1160 -0.4040 -26.58% 587 coq-metacoq-erasure/erasure/theories/ErasureFunction.v.html │ │ 20.2820 19.8910 -0.3910 -1.93% 12 coq-fourcolor/theories/job271to278.v.html │ │ 33.7230 33.3610 -0.3620 -1.07% 12 coq-fourcolor/theories/job001to106.v.html │ │ 31.4980 31.1390 -0.3590 -1.14% 12 coq-fourcolor/theories/job563to588.v.html │ │ 22.9470 22.6000 -0.3470 -1.51% 12 coq-fourcolor/theories/job307to310.v.html │ │ 27.1980 26.8660 -0.3320 -1.22% 12 coq-fourcolor/theories/job299to302.v.html │ │ 5.2730 4.9470 -0.3260 -6.18% 747 coq-perennial/src/program_proof/fencing/frontend_proof.v.html │ │ 0.3740 0.0490 -0.3250 -86.90% 1447 coq-perennial/src/program_proof/aof/proof.v.html │ │ 29.6800 29.3690 -0.3110 -1.05% 12 coq-fourcolor/theories/job399to438.v.html │ │ 1.2140 0.9040 -0.3100 -25.54% 202 coq-fiat-crypto-with-bedrock/src/PushButtonSynthesis/BaseConversion.v.html │ │ 5.9470 5.6450 -0.3020 -5.08% 167 coq-vst/veric/binop_lemmas6.v.html │ │ 27.6800 27.3860 -0.2940 -1.06% 12 coq-fourcolor/theories/job499to502.v.html │ │ 0.5980 0.3050 -0.2930 -49.00% 233 coq-fiat-crypto-with-bedrock/src/PushButtonSynthesis/SolinasReduction.v.html │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
It's obviously linked to hierarchy-builder since the affected files are the heavy users of HB but I don't have a better understanding (note that even with the patch, those files remain memory heavy). |
@coqbot run full ci |
Elpi commands can import a module, so for now they are declared as |
Bench is good, CI failures are unrelated, let's merge. @coqbot merge now |
@proux01: You can't merge the PR because it hasn't been approved yet. |
@coqbot merge now |
Unfortunately, a naive backport of this PR doesn't produce code that builds, probably due to #17059, which also creates difficulties for backporting #17620. This creates the question whether backporting #17059 too would be worthwhile. Unfortunately, it changes quite a few signatures in the API of the STM. I don't know if these functions should be considered internal. |
It's not |
@@ -2695,7 +2695,7 @@ let process_transaction ~doc ?(newtip=Stateid.fresh ()) x c = | |||
begin match w with | |||
| VtNow -> | |||
(* We need to execute to get the new parsing state *) | |||
ignore(finish ~doc:dummy_doc); | |||
let () = observe ~doc:dummy_doc (VCS.get_branch_pos (VCS.current_branch ())) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore (observe ...)
should work for the backport
Alternative to #17742