feat: offline tile prefetch scheduler with LRU eviction and predictive caching#93
Open
real-venus wants to merge 1 commit into
Open
feat: offline tile prefetch scheduler with LRU eviction and predictive caching#93real-venus wants to merge 1 commit into
real-venus wants to merge 1 commit into
Conversation
…e caching (Utility-Protocol#48) Anticipates the operator's viewport trajectory (GPS heading/velocity/zoom) and pre-warms the surrounding tile pyramid into IndexedDB with bounded LRU eviction, so pinch-zoom and connectivity loss no longer fall back to grey squares. - types/tile.ts: TileId/TileMeta/GeoSample/Viewport/BBox/PrefetchRequest and bounds (2500 cap / 2250 evict threshold, 3x3 x +/-2 zoom = 45-tile burst, >2 m/s prefetch, 30deg stale-heading cancel, 7d/48h TTL by zoom) - utils/tileMath.ts: slippy-map tile math (lng/lat<->tile, bounds, tilesInBBox), trajectory prediction (predictCenter/burstTiles/predictBBox), heading/velocity gating, and zoom-dependent TTL/staleness - utils/lruEviction.ts: doubly-linked LRU list; eviction prefers stale tiles then the lowest access_count/age ratio (LRU tie-break) - services/tileCache.ts: IndexedDB tile-blob + metadata stores, hit accounting, and an eviction check every 10 writes past the threshold - workers/tilePrefetch.worker.ts: expands bbox x zoom range to tiles, fetches off-thread, writes blobs to IndexedDB, skips fresh tiles, cancels superseded bursts - hooks/useGeoLocation.ts (1 Hz GPS) + useMapViewport.ts (Mapbox camera) - store/slices/tileCacheSlice.ts: hit/miss/eviction/byte/pending stats + hit ratio; components/dashboard/TileCacheOverlay.tsx debug overlay (feature-flagged) - tests for tile math, LRU eviction ordering/staleness, and the stats store
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.
Offline Geospatial Tile Prefetch Scheduler with LRU Eviction & Predictive Caching (#48)
Closes #48
What's included
src/types/tile.tsTileId/TileMeta/GeoSample/Viewport/BBox/PrefetchRequestand bounds (2,500 cap, 2,250 evict threshold, 3×3 × ±2-zoom = 45-tile burst, >2 m/s prefetch, 30° stale-heading cancel, 7-day/48-h TTL by zoom, eviction check every 10 writes).src/utils/tileMath.tslngLatToTile/tileBounds/tilesInBBox), trajectory prediction (predictCenter/burstTiles/predictBBox/zoomLevelsFor), heading/velocity gating (headingDelta/isStaleHeading/shouldPrefetch), and zoom-dependent TTL/isStale.src/utils/lruEviction.tsaccess_count / ageratio, with LRU as the final tie-break. Tracks size + byte usage.src/services/tileCache.tssrc/workers/tilePrefetch.worker.tsbbox × zoomLevelsinto tiles, fetches off the main thread, writes blobs to IndexedDB, skips already-cached tiles, and cancels superseded bursts (a sharp heading change supersedes the in-flight request).src/hooks/useGeoLocation.tsnavigator.geolocationwatch →GeoSample(heading, speed).src/hooks/useMapViewport.tsmapbox-gldependency).src/store/slices/tileCacheSlice.tsselectHitRatio.src/components/dashboard/TileCacheOverlay.tsxtests/unit/*