Fix hotspots dask performance: streaming 2-pass architecture#855
Merged
brendancol merged 1 commit intomasterfrom Feb 20, 2026
Merged
Conversation
…mory Rewrite _hotspots_dask_numpy to eliminate the global barrier that forced materialization of the full intermediate convolution output. The old implementation created a task graph where every chunk's z-score depended on both the per-chunk convolution and global reductions over ALL chunks, making it infeasible for datasets larger than RAM. New approach: - Pass 1: eagerly compute global_mean/global_std (two scalars, single co-scheduled graph traversal via da.compute) - Pass 2: fuse convolution + z-score + classification into one map_overlap call, so each chunk streams through independently Also fixes: redundant astype calls, pointwise map_overlap misuse, separate nanmean/nanstd accumulation, and re-enables zero-std check.
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
_hotspots_dask_numpyto eliminate the global barrier that forced materialization of the full intermediate convolution output, making hotspots infeasible for datasets larger than RAMmap_overlapcall that streams chunk-by-chunk with O(chunk_size) memoryastypecalls, and eliminates misuse ofmap_overlapfor a pointwise functionFixes #460
Impact at scale (e.g. 30 TB raster, 16 GB RAM)
Test plan
pytest xrspatial/tests/test_focal.py -k hotspots -v— all 3 tests pass (zero-std, numpy, dask_numpy)