Repository navigation
perf: Cull root tiles in raster-tileset to viewport - #464
Merged
Merged
Conversation
The traversal's z=0 loop instantiated every tile in the coarsest level's matrix upfront, relying on frustum culling downstream to discard the ones outside the viewport. For traditional OGC pyramids that's fine (z=0 is ~1 tile), but single-level Zarr descriptors can be thousands × thousands of tiles at their native resolution — e.g. a 4009984 × 1859584 px global raster at 256² tiles would instantiate ~114M RasterTileNodes at startup, effectively hanging the page. Cull to the intersection of the dataset extent and the viewport's WGS84 bounds: project the four corners into the source CRS via descriptor.projectFrom4326 and consult the root level's existing crsBoundsToTileRange. Typical viewport → tens of root tiles. If the viewport and dataset don't overlap, traversal is skipped entirely. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Review feedback on #464: - Introduce MAX_ROOT_TILES_NO_CULL = 100. Small root matrices (any typical OGC pyramid, ECMWF's 3×6=18, etc.) bypass the projection path entirely and behave bit-identically to the pre-patch traversal. Only descriptors with > 100 root tiles pay the projection cost. - Move the culling into createRootTiles() so the call site stays a single helper invocation and the branching logic is self-contained and testable. - Project the viewport-intersected bounds via transformBounds (21 samples per edge) instead of the 4-corner AABB, so non-affine projections like UTM cannot escape the hull. Rename test file + fixtures to track the new entry point. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Closed
Merged
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
Bound the z=0 root-tile allocation in
getTileIndicesso descriptors with very large root matrices (e.g. single-level zarr at native resolution) don't instantiate millions ofRasterTileNodes before frustum culling has a chance to run.createRootTileshelper owns the branching. Small root matrices (≤MAX_ROOT_TILES_NO_CULL = 100) bypass all projection work and iterate every tile — identical behavior to the pre-patch traversal, so any existing OGC pyramid (1 root tile at z=0), Sentinel-2, ECMWF (18), etc. are unaffected.transformBounds(densifying 21 points per edge so a non-linear projection like UTM can't escape the 4-corner hull), and consult the root level's existingcrsBoundsToTileRange. If the viewport and dataset don't overlap, traversal returns an empty root list.Before this change, a ZarrLayer pointed at a dataset like the AlphaEarth Foundations GeoZarr Mosaic (global, ~10 m resolution, 4009984 × 1859584 px @ 256² tiles → ~114M root tiles) instantiated all roots on first render and hung the page.
Test plan
projectFrom4326is not called).pnpm --filter @developmentseed/deck.gl-raster test— 62/62 pass locally (3 new + 59 existing).pnpm --filter @developmentseed/deck.gl-raster typecheck— clean.examples/dynamical-zarr-ecmwf+examples/zarr-sentinel2-tcistill render (small-matrix path — should be unchanged).🤖 Generated with Claude Code