perf: parallelise cmip7repack calls across split output files#549
Merged
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (70.0%) is below the target coverage (90.0%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #549 +/- ##
=======================================
- Coverage 74.9% 74.8% -0.0%
=======================================
Files 36 36
Lines 7156 7163 +7
Branches 1333 1336 +3
=======================================
+ Hits 5357 5361 +4
- Misses 1519 1520 +1
- Partials 280 282 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rbeucher
force-pushed
the
perf/parallel-cmip7-repack
branch
from
July 23, 2026 07:19
02c10d1 to
0a0295d
Compare
When split_years produces N output chunks, cmip7repack was previously called sequentially after each _write_single(), one blocking subprocess at a time. Now all chunk files are written first, then their repacks are dispatched concurrently via ThreadPoolExecutor. CMIP7 validation still runs sequentially after all repacks finish (it must follow repack). The single-file path (split off or fx variables) is unchanged: repack and validate are called synchronously as before. No Dask interference: repack threads start only after all dask computations are flushed and the netCDF file handles are closed.
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.
Summary
When
split_yearsproduces N output chunks,cmip7repackwas previously called sequentially (blocking subprocess) after each chunk was written — one at a time.This PR dispatches all repack calls concurrently using
ThreadPoolExecutoronce all chunk files have been written.Changes
_write_single(): removed the inline_repack_cmip7_output+validate_cmip7_outputcalls.write()— multi-chunk path: writes all chunks sequentially, then repacks in parallel viaThreadPoolExecutor.map(), then validates sequentially (validation must follow repack).write()— single-file path (split off /fxvariables): repack + validate called synchronously as before — no behaviour change.Why threads are safe here
netCDF4.Datasetfile handles are closed, so there is no scheduler contention with dask.subprocess.run(["cmip7repack", ...])on a separate file — no shared state.Impact
For a 165-year monthly run (17 × 10-year chunks), all 17
cmip7repacksubprocesses now run concurrently instead of serially.