Fix zonal dask memory guards and stats filtering#1112
Merged
brendancol merged 5 commits intomasterfrom Mar 31, 2026
Merged
Conversation
Parallel subagent triage + ralph-loop workflow for auditing all xrspatial modules for performance bottlenecks, OOM risk under 30TB dask workloads, and backend-specific anti-patterns.
7 tasks covering command scaffold, module scoring, parallel subagent dispatch, report merging, ralph-loop generation, and smoke tests.
- Improve _regions_dask memory guard: use shape*itemsize instead of .nbytes to avoid triggering graph inspection on large arrays, and provide actionable error message explaining the limitation. - Add missing memory guard to _regions_dask_cupy using GPU free memory. - Replace iterrows() zone filtering in _stats_dask_numpy with boolean .isin() indexing to avoid per-row materialization.
- test_regions_dask_memory_guard: verifies MemoryError is raised before .compute() when available memory is insufficient - test_stats_dask_zone_filter: verifies zone_ids filtering works correctly with the new .isin() approach
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
_regions_daskmemory guard: usesshape * itemsizeinstead of.nbytesto avoid triggering graph inspection on large arrays, with an actionable error message explaining the limitation_regions_dask_cupyusing GPU free memoryiterrows()zone filtering in_stats_dask_numpywith.isin()to avoid per-row materializationContext
Found during performance sweep triage (#1110).
da.unique().compute()was initially flagged as HIGH severity but confirmed to be safe (it's a per-chunk reduction that only materializes the small unique-values array). The real OOM risk is_regions_daskwhich intentionally.compute()s the full array since connected-component labeling is a global operation. The guard now catches this early.Test plan
test_regions_dask_memory_guard-- verifies MemoryError raised before.compute()when available memory is insufficienttest_stats_dask_zone_filter-- verifies zone_ids filtering works with.isin()