Feature: netcdf chunked reads - #984
Merged
hellkite500 merged 3 commits intoJun 26, 2026
Merged
Conversation
hellkite500
force-pushed
the
split/netcdf-chunked-reads
branch
from
June 26, 2026 19:09
6e87e47 to
0846019
Compare
The feature enables reading chunks of netcdf variable values instead of
reading all values for a given variable. A 'hint_shared_provider_id'
method is added that enables 'hinting' to a provider one of the id's
that it must provide. this method can be repeatedly called to add
necessary catchments. the netcdf provider keeps a set of the id's that
have been hinted and rebuilds it's chunking index on the first timestep
which is used to read only the necessary data.
I am not satisfied with the hinting approach, but it gets the job done
for now. Alternative approaches are:
- pass down list of catchments when constructing a provider. This would
require a lot of refactoring and extra fiddling that is currently not
required.
- or, create the shared forcing provider from all the id's and pass
that down. has the same issues as described.
- include the catchment-id to the factory forcing provider. This would
enable this functionality but transparently.
Co-authored-by: hellkite500 <nfrazier@lynker.com>
First cut at caching across the Time dimension in the netcdf data provider. We now cache 18 time slices when we read from disk. The access pattern in for each netcdf variable: n sim catchments x 18. I found in a crude runtime analysis on a HF with 160 divides simulating over the periods of 1 month _and_ 1 year that 18 was the sweet spot on my M2 Pro w/ 10 cpu & 32 GiB ram. This is for sure a tunable parameter that _seems_ highly dependent on how variables in your HDF5 enabled netcdf file are chunked and if they are compressed. Co-authored-by: hellkite500 <nfrazier@lynker.com>
hellkite500
force-pushed
the
split/netcdf-chunked-reads
branch
from
June 26, 2026 19:55
0846019 to
8cb46f1
Compare
PhilMiller
reviewed
Jun 26, 2026
| if(cache_slice_t_size > num_times){ | ||
| cache_slice_t_size = num_times; | ||
| }else if(cache_slice_t_size <= 0){ | ||
| cache_slice_t_size = 24; // default to 24 if no chunking info found |
Contributor
There was a problem hiding this comment.
I don't think this case can ever be hit, because there's the in-class initializer cache_slice_t_size = 18;. Did you mean to change that to = 0 when you added this?
Contributor
Author
There was a problem hiding this comment.
Fixed and squashed.
PhilMiller
reviewed
Jun 26, 2026
| const std::string& var_name = var_pair.first; | ||
| auto var = var_pair.second; | ||
| // Skip the Time variable itself and ids, look for data variables with at least 2 dimensions | ||
| if (var_name == "Time" || var_name == "ids" || var_name == "catchment-id" || var.getDimCount() < 2) continue; |
Contributor
There was a problem hiding this comment.
I think the DimCount check covers all of this?
PhilMiller
requested changes
Jun 26, 2026
PhilMiller
left a comment
Contributor
There was a problem hiding this comment.
I'm concerned about cache_slice_t_size as noted above
Co-authored-by: Austin Raney <austin.raney@noaa.gov>
hellkite500
force-pushed
the
split/netcdf-chunked-reads
branch
from
June 26, 2026 21:12
8cb46f1 to
b21ca03
Compare
PhilMiller
approved these changes
Jun 26, 2026
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.
This is the core of #944 after factoring out #982 and #983. The 18 remaining commits were logically grouped into the 6 on this branch. Note that this is based on the HEAD of #982 currently, will need rebased once that merges.
Additions
hint_shared_provider_id) so the provider reads only the catchments a simulation requests, not every feature in the file.align_cache_with_chunks()to size the cache from the variable's on-disk chunking when present....UsingIds,...Span,...MultiSpan, etc.).Removals
= delete) — there is no valid un-parameterized provider.Changes
get_valuereworked to read through, and serve from, the chunked time-dimension cache.N_EXPECTED_FORCING_VARS) rather than a magic number.Testing
Known issue: cache sizing
Per @PhilMiller's profiling note on #944: the cache is currently sized to match the working set. A functional cache needs to be larger than the working set — a request spanning more than one time step will thrash an exactly-matched cache. Carried over from #944.
Coordination
get_valueoverlaps the NGWPC reader rework in NGWPC NWM Regionalization, Hindcast, and Coastal Tools 2026-06-09 #979 (its dimension-ordering /imapchanges touch the same function). Will look at cherry picking that work here.Checklist
Target Environment support