Fix OOM in geotiff dask read, sieve memory, and reproject GPU fallback#1183
Merged
brendancol merged 1 commit intomasterfrom Apr 11, 2026
Merged
Fix OOM in geotiff dask read, sieve memory, and reproject GPU fallback#1183brendancol merged 1 commit intomasterfrom
brendancol merged 1 commit intomasterfrom
Conversation
Three performance fixes from the Phase 2 sweep targeting WILL OOM verdicts under 30TB workloads: geotiff: read_geotiff_dask() was reading the entire file into RAM just to extract metadata before building the lazy dask graph. Now uses _read_geo_info() which parses only the IFD via mmap -- O(1) memory regardless of file size. Peak memory during dask setup dropped from 4.41 MB to 0.21 MB at 512x512 (21x reduction). sieve: region_val_buf was allocated at rows*cols (16 GB for a 46K x 46K raster) when the actual region count is typically orders of magnitude smaller. Now counts regions first, allocates at actual size. Also reuses the dead rank array as root_to_id, saving another 4 bytes/pixel. Memory guard fixed from a misleading 5x multiplier to an accurate 28 bytes/pixel estimate. reproject: _reproject_dask_cupy pre-allocated the full output on GPU via cp.full(out_shape), which OOMs for large outputs. Now checks available GPU memory and falls back to the existing map_blocks path (with is_cupy=True) when the output exceeds VRAM. Fast path preserved for outputs that fit.
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
read_geotiff_dask()was reading the entire file into RAM to extract metadata (shape, dtype, nodata) before building the lazy dask graph. Now uses_read_geo_info(), which parses only the TIFF IFD via mmap. Peak memory during graph setup dropped from 4.41 MB to 0.21 MB at 512x512. For a 30TB file this was an instant OOM; now it's a few kilobytes of header parsing.sieve._label_connected()allocatedregion_val_bufatrows * colsentries -- 16 GB of float64 for a 46K x 46K raster, even though the actual region count is typically around 100K. Now counts regions in a first pass and allocates at the real size. The deadrankarray gets reused asroot_to_idinstead of allocating a separate n-element array. Memory guard multiplier fixed from an inaccurate 5x to 28 bytes/pixel._reproject_dask_cupypre-allocated the full output on GPU withcp.full(out_shape), raisingMemoryErrorif it exceeded VRAM. Now it checks available GPU memory first and falls back to the existingmap_blocks(is_cupy=True)path when the output won't fit. The fast pre-allocation path is still used when the output does fit.Test plan