# M31. Checks in less time **Package:** C15. The owner asked for it (2026-11-19): sessions ran the full check very often while developing, and it took more than a quarter of an hour. ## What was found The tests are not slow. The measurement of coverage was. | On four cores | Rust tests | Python tests | |---|---|---| | Plain build | 21 s | 22 s | | Instrumented build, as it was run | 505 s | 432 s | Instrumented code counts every region it runs through, in counters that all threads of a process share. The methods run their loops on all cores since milestone 21, and the test harness runs several tests at once. All of these threads wrote to the same counters. One test, a reaction on a disk, shows it: 0.8 s plain, 4.7 s instrumented on one thread, 32 s instrumented on four, with 120 s of processor time. The full check as a whole took 17.7 minutes. ## What was built - **`scripts/coverage.sh` measures without the fight.** Every computation uses one thread, and the tests are spread over processes in place of threads: the Rust tests in groups of four tests per process, the Python tests with pytest-xdist. Same tests, same coverage to the line: 29 730 lines of Rust with 361 missed before and after, and all 980 statements of Python. - **`scripts/check.sh --fast`**: hygiene, lints and every test of both languages on the plain build, with the coverage floor on Python. It leaves out the instrumented build and the documentation. - **`scripts/test.sh`**: the tests of both languages without instrumentation, all of them or those with a word in their name. - **`scripts/check.sh` says how long each stage took.** - **CI does not check drafts** of pull requests. It checks when a pull request is marked as ready, and every push after that. - **Rules for which check when**, in the [workflow](../workflow.md#which-check-when) and in `CLAUDE.md`. | On four cores | Before | After | |---|---|---| | Full check, `scripts/check.sh` | 17.7 min | 4.4 min | | Fast check, `scripts/check.sh --fast` | | 1 min, up to 3 after Rust sources changed | | The tests of one topic, `scripts/test.sh disk` | | seconds | ## Decisions ### D31.1. The smallest check that can find the mistake *Owner, 2026-11-19: the way of working has to change, and the whole suite need not run every time. Worked out by the developer.* Until now `scripts/check.sh` was to be run before every push, and it was the only check. Sessions also ran it to see whether a change worked. It measured coverage every time. - **While writing code**, the tests of what is being changed, by a word in their name. Seconds. This is the everyday check. - **When a package is finished**, the fast check: all tests of both languages and the lints. It finds what the package broke elsewhere. It does not say whether new code is covered in Rust, and it does not build the documentation. - **Once for a pull request**, the full check, before it is marked as ready, and again after `main` was merged into the branch. - **A push to a draft needs no check.** - **CI** runs the full check, as before, and is what the merge relies on. The floor of 95 % (decision D6) stands. It is enforced where it was, in the full check and in CI, and no longer on every push. ### D31.2. Under instrumentation: one thread, several processes *Developer, 2026-11-19.* `scripts/coverage.sh` sets `RAYON_NUM_THREADS=1` and runs the tests in as many processes as there are cores. Processes do not share counters. For Rust, the test program is asked for the names of its tests, and `xargs` hands them to processes four at a time. This needs no tool that is not there already. A test runner that starts a process per test (cargo-nextest) would do the same, and was not taken because it would be one more tool to install here, in CI and in every environment of a session. For Python, pytest-xdist spreads the tests. It is a development tool like pytest, and not part of what users install. One test still uses four threads under instrumentation, because that is what it tests: that results are the same bits on one thread and on four. ### D31.3. A pull request may be large, and may bundle packages *Owner, 2026-11-19.* A pull request may hold several packages, small and medium ones, and may be very large. Coverage is measured once per pull request, before it is ready, and not once per package. Why: each pull request costs a full check, a run of CI, a review and a merge, and every merge makes the other open pull requests merge `main` again. Fewer and larger pull requests cost less of all of these. What follows from it: a milestone is a pull request, and no longer a package. Its record names the packages it delivered. A session that bundles takes its packages from one lane, so that it does not hold several lanes at once (decision D30.2). ### D31.4. CI does not check drafts *Developer, 2026-11-19.* A pull request is opened as a draft to claim a package (decision D30.2), and stays one while the work goes on. Checking it then would spend the time of CI on work that its author knows to be unfinished. The check for forbidden names still runs on drafts: it takes seconds, and a title or a branch name is wrong from the first moment. ## Left for later - Instrumentation alone, on one thread, still makes the tests five to six times slower. Development builds are optimized lightly (level 1), and counters weigh more there. Not looked into. - CI runs its stages one after the other. Lints, tests and documentation could be jobs that run side by side. - The documentation build takes a minute, most of it for running the examples that draw figures. The tests run the same examples.