Add memory guard to cost_distance iterative Dijkstra + da.block assembly#1119
Merged
brendancol merged 4 commits intomasterfrom Mar 31, 2026
Merged
Add memory guard to cost_distance iterative Dijkstra + da.block assembly#1119brendancol merged 4 commits intomasterfrom
brendancol merged 4 commits intomasterfrom
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.
…1118) - Add memory guard before _preprocess_tiles: estimates ~3x dataset (source + friction cache + result) and raises MemoryError if it would exceed 80% of available RAM, suggesting finite max_cost. - Replace np.concatenate assembly with da.block to avoid building a monolithic numpy array from tile results. Tiles are now wrapped in dask.delayed and assembled lazily.
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
_preprocess_tiles: estimates ~3x dataset size and raisesMemoryErrorif it would exceed 80% of available RAM, suggesting finitemax_costnp.concatenateresult assembly withda.blockto avoid building a monolithic numpy array from tile resultsContext
Found during performance sweep triage (#1118). The iterative tiled Dijkstra path (triggered when
max_cost=infor implied radius > chunk dimensions) caches all tiles in RAM viadask.compute(*blocks). The_assemble_resultthennp.concatenated everything into a single numpy array. At 30TB both are fatal.The
da.blockchange means the assembled result stays as a dask array with proper chunk structure, avoiding the second full materialization.Test plan