Reduce transient allocations when decoding CCSDS GRIB2 fields - #1607
Merged
lesserwhirls merged 1 commit intoSep 24, 2026
Merged
Conversation
michaeldiener
force-pushed
the
codex/grib2-ccsds-buffer-size
branch
from
September 24, 2026 08:22
a3e219e to
266adf3
Compare
michaeldiener
force-pushed
the
codex/grib2-ccsds-buffer-size
branch
from
September 24, 2026 08:26
266adf3 to
c5a522a
Compare
michaeldiener
marked this pull request as ready for review
September 24, 2026 08:42
lesserwhirls
approved these changes
Sep 24, 2026
lesserwhirls
left a comment
Member
There was a problem hiding this comment.
These are great changes, thank you so much - and thank you for keeping the PR small and targeted (as opposed to combining all three into one larger PR).
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.
CCSDS decoding allocates one float per decoded byte, so 16-bit and 32-bit fields return arrays two or four times the grid size, with trailing zeros.
It also creates full-sized Java arrays for both the compressed input and the decompressed native output.
This change keeps the returned array at
totalNPoints, transfers compressed input through at most 64 KiB of Java scratch storage, and converts decoded samples directly from a big-endian view of native memory.The view is consumed before the native allocation is closed; callers still receive an independent Java float array.
The input transfer uses the existing
RandomAccessFile.readFullyAPI, preserving partial-read and EOF handling for file-backed, in-memory and remote readers.All three changes are kept together because they affect the same CCSDS decoding method.
The coordinate and receiver changes in #1608 and #1609 are independent.
Validation:
spotlessCheckpasses.Those HTTP 301/400 failures were also reproduced using unchanged upstream classes while opening the remote test objects.
Allocation and timing were measured on Linux/Java 21 using captured ICON data.
Against a baseline already containing the array-size, coordinate and receiver fixes, the two buffer changes remove approximately 2.40 GiB of cumulative Java allocation per 349-field import.
In one full application comparison, allocation fell from 6,892 to 4,435 MiB (35.7%), while elapsed time increased from 94.84 to 96.59 seconds (1.8%).
The isolated decode-and-hash benchmark was slower, from a median of 9.92 to 11.46 seconds across three measured runs per variant.
Larger input transfer buffers did not improve those timings, so the scratch limit remains 64 KiB.
These measurements describe allocation churn and a CPU tradeoff, not retained heap or production latency.