Render the history plots in parallel - #350
Merged
Merged
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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)