Skip to content

Render the history plots in parallel - #350

Merged
sjoelund merged 1 commit into
masterfrom
parallel-all-plots
Sep 4, 2026
Merged

Render the history plots in parallel#350
sjoelund merged 1 commit into
masterfrom
parallel-all-plots

Conversation

@sjoelund

@sjoelund sjoelund commented Sep 4, 2026

Copy link
Copy Markdown
Member

Almost all of the time all-plots.py takes is matplotlib writing svg files: about 0.42s per library for the two plots it draws, near enough independent of how many runs are in the history. Over ~45 branches of ~150 libraries that is more than half an hour of one core, and no library's plot has anything to do with another's.

Hand the rendering to a process pool (-j, all available cpus by default). The queries stay in the main process, and the jobs are generated branch by branch, so the next branch is queried while the previous one is still being drawn; at most 4 jobs per worker are outstanding, as each one carries the whole history of a library.

Everything moves into main() behind an main guard: python 3.14 starts a worker with forkserver, which re-imports the module, and parsing the arguments and connecting to the database again there is not what we want.

Each branch now prints how long its query took, so the log says whether it is the queries or the rendering that is slow.

Measured on a synthetic 80-library database:

jobs  time
   1  28.2s
  12   7.7s
  24   4.0s

The svg files are identical apart from the embedded date and matplotlib's per-run element ids, which differ between two serial runs as well.

Assisted-by: Claude Opus 5 (1M context)

Almost all of the time all-plots.py takes is matplotlib writing svg
files: about 0.42s per library for the two plots it draws, near enough
independent of how many runs are in the history.  Over ~45 branches of
~150 libraries that is more than half an hour of one core, and no
library's plot has anything to do with another's.

Hand the rendering to a process pool (-j, all available cpus by
default).  The queries stay in the main process, and the jobs are
generated branch by branch, so the next branch is queried while the
previous one is still being drawn; at most 4 jobs per worker are
outstanding, as each one carries the whole history of a library.

Everything moves into main() behind an __main__ guard: python 3.14
starts a worker with forkserver, which re-imports the module, and
parsing the arguments and connecting to the database again there is not
what we want.

Each branch now prints how long its query took, so the log says whether
it is the queries or the rendering that is slow.

Measured on a synthetic 80-library database:

    jobs  time
       1  28.2s
      12   7.7s
      24   4.0s

The svg files are identical apart from the embedded date and
matplotlib's per-run element ids, which differ between two serial runs
as well.

Assisted-by: Claude Opus 5 (1M context)
@sjoelund
sjoelund enabled auto-merge (squash) September 4, 2026 08:38
@sjoelund
sjoelund merged commit 0c189c1 into master Sep 4, 2026
7 checks passed
@sjoelund
sjoelund deleted the parallel-all-plots branch September 4, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant