Skip to content
This repository was archived by the owner on Oct 6, 2026. It is now read-only.

Performance Improvements for NWM CONUS Retrospective Forcing - #246

Merged
mxkpp merged 1 commit into
developmentfrom
ngwpc-11299-nwm-forcing-performance
Sep 25, 2026
Merged

mxkpp merged 1 commit into
developmentfrom
ngwpc-11299-nwm-forcing-performance

Conversation

@mxkpp

@mxkpp mxkpp commented Sep 23, 2026 •

Copy link
Copy Markdown

The NWM CONUS retrospective (historical) forcing processor had the following inefficiencies, leading to slow run times:

  1. Disk cache was not being leveraged
  2. Variables were being sliced individually and then merged into one dataset, rather than lazy-merging once and then slicing once.
  3. The sliced dataset remained lazy, causing large remote zarr chunks to be fetched repeatedly.

This resolves these issues by leveraging the cache, merging the variables before slicing, and loading the sliced data into memory once. The potential memory impact is mitigated by loading variables sequentially after the lazy merge & slice.

Speed improvement for one small test case

Command ran from nmw-rte via run.sh, a 2-day realization with 3 total iterations (1 initial/baseline iteration, plus 2 calibration iterations), for the small test basin of the USGS gage "01123000":

docker_run python -um "ngen_rte.run_calibration" -n 2 -fconfig "nwm" -start "2013-07-25 00:00:00" -dur 2 --gage_id ${TEST_GAGE} --hydrofab_file "${TEST_HYDROFAB_FILE}"

Before: 19.5 minutes.

After: 0.9 minutes.

The disk cache files were deleted between those 2 calls for apples-to-apples benchmark.

For a deterministic comparison to confirm that outputs are the same before and after this change, the following "default" realization was ran both ways as well, and ngen outputs were inspected:

docker_run python -um "ngen_rte.run_default" -n 2 -fconfig "nwm" -dt "2013-07-25 00:00:00" -dur 2 -rname "default_nwm" --output_format CSV NetCDF --gage_id ${TEST_GAGE} --hydrofab_file "${TEST_HYDROFAB_FILE}"

Additions

  • None

Removals

  • None

Changes

  • See above

Testing

  1. See above

Screenshots

Notes

Todos

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Target Environment support

  • Linux

…ariables, load variables sequentially for optimal memory footprint.
@kevinspurrier
kevinspurrier force-pushed the ngwpc-11299-nwm-forcing-performance branch from f845437 to 881621a Compare September 24, 2026 17:30
@mxkpp
mxkpp merged commit 555b615 into development Sep 25, 2026
7 checks passed
@mxkpp

mxkpp commented Sep 25, 2026

Copy link
Copy Markdown
Author

Test team conducted tests: calibration for the default gage, and "default" workflow for the VPU 03S.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant