Reuse decoded arrays for single full-field GRIB reads - #1609
Open
michaeldiener wants to merge 1 commit into
Open
michaeldiener wants to merge 1 commit into
michaeldiener wants to merge 1 commit into
Conversation
michaeldiener
force-pushed
the
codex/grib-full-field-reuse
branch
from
September 24, 2026 08:22
b322c04 to
5fecf49
Compare
michaeldiener
marked this pull request as ready for review
September 24, 2026 08:43
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.
GribDataReader.DataReceiverallocates and fills a result array before reading a record, then copies the decoded floats into it even for a single complete field.Defer the result allocation and transfer the decoder's fresh array when the requested shape contains exactly one full field, both ranges are contiguous and start at zero, and the decoded array has exactly the required size.
Subsets, strides, composite/scattered ranges, multiple records and oversized decoder output keep the copy path.
Missing records still produce NaNs, and debug zero filling remains supported.
The original result shape and rank are preserved.
This change can be merged independently.
For multi-byte CCSDS fields, the decoder buffer-size fix in #1607 lets more reads use the fast path; oversized arrays safely fall back to copying until then.
With correctly sized decoded arrays, avoiding the second array saves 3.83 GiB of allocation in the 349-field ICON workload.
Validation:
spotlessCheckpasses.Those HTTP 301/400 failures also reproduce using unchanged upstream classes while opening the remote test objects.