M79. The checks of CI side by side, and the examples run in less time

Package: C20. The owner asked whether the checks can take less time (2026-11-25): a run of CI had grown to 30 minutes. This milestone takes what costs no test: the documentation is built beside the tests in CI, and its examples are run in less time. The tests that take the most time are the next package (C21).

What was found

Milestone 31 brought the full check from 17.7 minutes to 4.4. Since then the project has grown from 29 730 lines of Rust to 44 178, and the check with it. The run of CI after milestone 77, and the full check on four cores before this milestone:

Stage

CI

Here

Setting up, building the package, lints

2 min

40 s

Tests and coverage

15 min

8.7 min

Documentation

12 min

4 min

Together

30 min

13 min

The documentation was built with the wrong package. In CI the stages ran one after the other in one job, and the tests leave the package installed that counts every region it runs through. The examples of the documentation then ran with it, on all threads, which is what milestone 31 had found to be slow in the tests. The workflow that publishes the website builds the same pages with the package that users get, and takes 6 to 8 minutes with setting up and publishing.

The examples were run one after the other, and each twice. A page that draws is run once for the light and once for the dark version of the website. One run of the 101 pages takes 110 s on four cores: 47 s to solve and 63 s to draw. So the drawing costs more than the solving, above all the animations, and neither used more than one core for most of the time.

A few tests take most of the time. With the counters of the coverage, 80 of the 658 tests of the core take 87 % of the time. That is package C21.

Decisions

D79.1. The documentation is a job of its own in CI

Developer, 2026-11-26.

The workflow has two jobs, which run side by side: “Lint, test, coverage” and “Documentation”. Each builds the package for itself. The job of the tests does not build the package that users get: the lints do not need it, and scripts/coverage.sh builds the one that is measured. On main the job of the documentation does not run, because the workflow that publishes the website builds it there.

A third job, “Lint, test, coverage, docs”, needs the two and passes when both have passed. It keeps the name that the one job had, because a rule for main may ask for a check by its name (the settings for the owner), and a check that no job reports any more would block every merge. It always runs and looks at the results: a job that is skipped because one that it needs has failed would count as passed.

scripts/check.sh runs its stages one after the other as before. On the cores of one machine nothing is won by running them side by side, and the stage of the tests leaves the right package behind when it does not run in CI.

D79.2. The pages are run in processes, and a page solves once

Developer, 2026-11-26.

The extension docs/_ext/examples.py runs the pages before Sphinx reads them: each in a process of its own, as many at once as there are cores, each process on one thread. The processes are started fresh and not forked, so that none takes the state of matplotlib or of Sphinx with it. What a page drew comes back as the names of its files, and a page that fails stops the build with the message of its example, as before.

Within a process, the solve of the core answers from memory what it has solved for the same problem, plan and data. The run for the dark theme therefore draws the solutions of the run for the light one. The memory is asked by what is given, and not by the order of the calls: a page whose second run asked for something else would simply have it solved. What is handed out is a copy, so that an example that writes into a solution does not change the next answer.

A page whose figures are asked for and that was not run ahead, as for the tile of a page that an incremental build does not read, is run where it is asked for, as before.

The other way to solve once, to keep the solutions and only draw again, would need to know which lines of an example draw. The memory needs to know nothing of the page.

What was built

  • .github/workflows/ci.yml with the two jobs, and the third that says whether both passed.

  • scripts/coverage.sh brings the libraries of the environment up to date without building the package that users get.

  • docs/_ext/examples.py: _draw, which runs the pages ahead in processes, _page, the work of one process, and _remembering, the memory of solves, with a test of the last.

  • The workflow says how CI runs and how the figures are drawn.

What was measured

The documentation was built before and after, on four cores, and the 282 figures of the two builds were compared: every file is the same to the byte.

On four cores

Before

After

The build of the documentation, scripts/docs.sh

229 s

81 s

Of it: running the examples

200 s

50 s

The full check, scripts/check.sh

799 s

707 s

What is left of the build is reading the pages, 8 s, and writing them, 14 s. Of the full check, the tests with their coverage are nine minutes and more, which is what package C21 is about. The table of which check when still said five minutes for it, from milestone 31, and says twelve now.

The first run of CI with two jobs is that of this milestone’s pull request. Its times are in the description of that pull request and in the record of the milestone that follows.

What was left

  • The tests that take the most time (C21).

  • CI repeats its checks on main after every merge (C22, for the owner).

  • Drawing is the larger part of the examples. An animation is drawn frame by frame and written as a GIF, twice. Not looked into.

  • The tests run the examples a third time, for what they print (test_docs.py). They run with the tests, in processes, and cost the full check about 40 s of a core.

  • Under instrumentation the tests are still five to six times slower on one thread, as milestone 31 left it.