| @@ -1,14 +1,14 @@ |
| 1 | 1 | # Folding small modules into their only importer |
| 2 | 2 | |
| 3 | | -Issue S-5 (#14). Measured on main at `ba4a037`: 582 modules fold into 343 files of 68 families, and the tree goes from 54.73 T instructions over 2,587 files to 50.94 T over 2,005 (−6.9%; T is 10¹²). |
| 3 | +Issue S-5 (#14). As it landed, at `066869d`: 557 modules folded into 335 files, and the tree went from 54.73 T instructions over 2,587 files (main at `77edee3`, before the series) to 50.81 T over 2,030 (−7.2%; T is 10¹²; 0.29 T of it is #668's two instances, merged in between). The first plan, measured on main at `ba4a037`, was 582 modules into 343 files of 68 families, 50.94 T over 2,005 files; the table by family below is that plan's, and "The rule" and "Statements" say why fewer landed. |
| 4 | 4 | |
| 5 | 5 | ## The rule |
| 6 | 6 | |
| 7 | | -A module is folded when exactly one file of the repository imports it, that file is in the same folder and the same family (first word of the file name), the module has at most 200 lines, the file takes in at most 600 lines, and neither states results (no file with `Comparator`, `Solution`, `Theorem`, `PaperResult`, `Results` or `Statement` in its name). The module's text goes into the file unchanged, under a heading that names it, in a `section` of its own, before the file's own text; the scopes it left open at its end are closed there; the file takes over its imports. Chains fold from the leaf up while the limits hold. |
| 7 | +A module is folded when exactly one file of the repository imports it, that file is in the same folder and the same family (first word of the file name), the module has at most 200 lines, the file stands at no more than 600 lines once folded, and neither states results (no file with `Comparator`, `Solution`, `Theorem`, `PaperResult`, `Results` or `Statement` in its name). The module's text goes into the file unchanged, under a heading that names it, in a `section` of its own, before the file's own text; the scopes it left open at its end are closed there; the file takes over its imports. Chains fold from the leaf up while the limits hold. |
| 8 | 8 | |
| 9 | 9 | ### What the two limits count |
| 10 | 10 | |
| 11 | | -Both limits count text: a module's own lines for the 200, a file's own lines plus those of the modules it takes for the 600. That is what `fold.py plan` compares, and it is read off the sources before anything is folded. The lines a fold adds to a file are not counted: a heading that names the file the text came from, the `section` it opens, and the `end`s that close the scopes the module left open at its end, which come to 47 lines for the six modules of `Euler/DriftCorrectionBootstrap.lean`. That file takes in 575 lines of text (its own 100 and the 475 of the six modules) and stands at 622: the cap is on the 575, the 622 is the file. The headings and the `end`s are what makes a folded file navigable — where each piece came from, where its scopes end — and they are the same for every module; a file that takes in 600 lines of text and carries ten headings is not a file of 600 lines of text, and the cap is a bound on the text, as the 200 is on the module's. The series keeps it there, and every count this page gives for a file is the text it takes in. |
| 11 | +The 200 counts a module's own lines. The 600 counts the file as `fold.py apply` writes it: its own text, the text of the modules it takes, and the lines each fold adds (a heading that names the file the text came from, the `section` it opens, and the `end`s that close the scopes the module left open at its end). That is what `fold.py plan` compares since #717. Before it, `plan` compared the sum of the texts, and a file could pass and overrun once written: #716's first head had `Euler/WholeSpaceGaussianFields.lean` at 609 lines, and as merged it takes four modules, not five, and stands at 473. One file merged under the earlier count stands over the cap: `Euler/DriftCorrectionBootstrap.lean` takes in 575 lines of text (its own 100 and the 475 of six modules) and stands at 622 with the 47 lines its six folds add (#694). It stands as merged; whether its last module comes out again is not decided on this page. |
| 12 | 12 | |
| 13 | 13 | ## Why it is cheaper |
| 14 | 14 | |
| @@ -18,12 +18,12 @@ Every module loads what it imports before its first line is read. The cheapest m |
| 18 | 18 | |
| 19 | 19 | ```sh |
| 20 | 20 | python3 -I docs/s5-folding/fold.py self-test |
| 21 | | -python3 -I docs/s5-folding/fold.py plan . /tmp/plan.json --small 200 --cap 600 # what would fold on the tree as it stands |
| 21 | +python3 -I docs/s5-folding/fold.py plan . /tmp/plan.json --small 200 --cap 600 # what would fold on the tree as it stands (skip.txt's files left alone) |
| 22 | 22 | python3 -I docs/s5-folding/fold.py apply . /tmp/plan.json # do it |
| 23 | 23 | python3 -I docs/s5-folding/fold.py check . <a pull request's plan.json> # is the working tree main's text, folded? |
| 24 | 24 | ``` |
| 25 | 25 | |
| 26 | | -Each pull request of the series keeps its plan in its route notes (`routes/<branch>/plan.json`). A fold whose file did not build was taken back before the count (0 files). |
| 26 | +A new fold has to pass the listing of "Statements" below as well: the build does not notice a name that resolves to another definition. Each pull request of the series keeps its plan in its route notes (`routes/<branch>/plan.json`). A fold whose file did not build was taken back before the count (0 files). |
| 27 | 27 | |
| 28 | 28 | ## What is checked |
| 29 | 29 | |
| @@ -104,7 +104,7 @@ Each pull request of the series keeps its plan in its route notes (`routes/<bran |
| 104 | 104 | |
| 105 | 105 | ## What this does not show |
| 106 | 106 | |
| 107 | | -The wall-clock time of a build on your machine; that every file is now in its best shape for reading (P-8 splits the large ones; no file takes in more than 600 lines of text, and the largest, `Euler/DriftCorrectionBootstrap.lean`, stands at 622 with the headings and `end`s of its six folds). |
| 107 | +The wall-clock time of a build on your machine; that every file is now in its best shape for reading (P-8 splits the large ones; one folded file stands over 600 lines, `Euler/DriftCorrectionBootstrap.lean` at 622: see "The rule"). |
| 108 | 108 | |
| 109 | 109 | ## Statements, and the series as it was opened |
| 110 | 110 | |
| @@ -112,7 +112,9 @@ The first pull request of the series was cut from a plan of 582 folds. Before th |
| 112 | 112 | |
| 113 | 113 | The first plan did not pass. Of 53,802 named constants, 12 differed. In one, `Euler.ComparatorBridge.compactSolenoidalTests_representation`, the word `divergence` resolved to `Euler.divergence` in the folded file and to `EulerSmoothLimit.divergence` on main: once folded, the text saw more names. The build passed all the same. In the others an instance was found by another path (`NormedCommRing ℂ` through the C⋆-algebra instances, `DistribSMul ℝ` through the semiring), or a proof inside the statement differed. |
| 114 | 114 | |
| 115 | | -Two changes followed. `fold.py` now puts a folded module's imports where its import line stood, so that every other module is loaded in the order it was loaded before (a plan file says which way it was cut, and `check` follows it, so the first pull request still checks). And five files keep their modules: `Euler/CompactProjectedEulerLaw.lean`, `Euler/CylinderJetLpAlgebra.lean`, `Euler/MeanCutoffDifferenceBound.lean`, `NavierStokes/R3/CompactEnergy.lean`, `NavierStokes/R3/PressureRecovery.lean`. |
| 115 | +Two changes followed. `fold.py` now puts a folded module's imports where its import line stood, so that every other module is loaded in the order it was loaded before (a plan file says which way it was cut, and `check` follows it, so the first pull request still checks). And five files keep their modules: `Euler/CompactProjectedEulerLaw.lean`, `Euler/CylinderJetLpAlgebra.lean`, `Euler/MeanCutoffDifferenceBound.lean`, `NavierStokes/R3/CompactEnergy.lean`, `NavierStokes/R3/PressureRecovery.lean`. They are listed in `skip.txt` beside the tool and `plan` leaves them alone: without that list, a plan on main as it stood after the series folds seven modules into those five files again. |
| 116 | + |
| 117 | +The series as it landed was listed the same way: main before the other families were merged (`394a2e7`, with #667 and #668 in it: 53,804 named constants) and main after the last (`066869d`). The two lists are equal, none missing, none with another type or value. |
| 116 | 118 | |
| 117 | 119 | The series as opened is 575 folds into 338 files. On it the two listings are equal: 53,802 named constants, none missing, none with another type or value; the first pull request's twelve folds were checked alone and are equal too. The whole tree goes from 54.73 T instructions over 2,587 files to 50.97 T over 2,012 (−6.9%), in place of the figures at the top of this page. |
| 118 | 120 | |