perf(map): optimize deck.gl rendering pipeline — supercluster config, viewport caching, data windowing#2669
perf(map): optimize deck.gl rendering pipeline — supercluster config, viewport caching, data windowing#2669dx0rz wants to merge 6 commits intokoala73:mainfrom
Conversation
…indowing Agent-Logs-Url: https://github.com/dx0rz/worldmonitor/sessions/34475267-d8ce-4d68-859e-0302da45b23c Co-authored-by: dx0rz <109863805+dx0rz@users.noreply.github.com>
…st comments Agent-Logs-Url: https://github.com/dx0rz/worldmonitor/sessions/34475267-d8ce-4d68-859e-0302da45b23c Co-authored-by: dx0rz <109863805+dx0rz@users.noreply.github.com>
…rmance perf(map): optimize deck.gl rendering pipeline — supercluster config, viewport caching, data windowing
|
@dx0rz is attempting to deploy a commit to the Elie Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR optimizes the deck.gl rendering pipeline by tuning supercluster radii/maxZoom, adding a viewport cache key coarsening, and windowing FIRMS/UCDP datasets to the visible region. Two P1 issues need attention before merge:
Confidence Score: 4/5Not safe to merge as-is — one claimed optimization is inert (dead code) and the viewport filter can silently drop data in Pacific-region views. Two P1 findings: (1)
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[buildLayers called] --> B[filterByTimeCached for FIRMS fires]
B --> C[filterToViewport — viewport windowing]
C --> D{items.length >= 200?}
D -- No --> E[Return all items unchanged]
D -- Yes --> F[getBounds from maplibreMap]
F --> G{bounds available?}
G -- No --> E
G -- Yes --> H[Compute ±20% lon/lat margin]
H --> I{lon crosses antimeridian?}
I -- Yes, w>e or e>180 --> J[⚠️ Filter may reject valid points]
I -- No --> K[Filter items inside expanded bbox]
K --> L[Filtered dataset passed to deck.gl layer]
M[updateClusterData called] --> N[Get integer zoom + boundsKey 2dp]
N --> O{zoom, boundsKey, layerMask unchanged?}
O -- Yes --> P[Skip — cache hit]
O -- No --> Q[getClusters for each SC layer]
Q --> R[Static radius from construction]
S[getDynamicClusterRadius] -.->|Exported but never called| R
Reviews (1): Last reviewed commit: "Merge pull request #1 from dx0rz/copilot..." | Re-trigger Greptile |
…port, import in tests Agent-Logs-Url: https://github.com/dx0rz/worldmonitor/sessions/4b1317cb-bdc9-4ab2-8c8a-0b6941882b66 Co-authored-by: dx0rz <109863805+dx0rz@users.noreply.github.com>
|
Thanks for the automated review from Greptile — the three findings should now be addressed:
These changes are in commit |
Summary
Optimize the DeckGL map rendering pipeline by:
This reduces redundant cluster recalculations and JS‑side processing during
map panning/zooming, especially for large datasets (FIRMS fires, UCDP events).
Type of change
Affected areas
/api/*)Changes
1. Supercluster configuration (
DeckGLMap.ts)maxZoomfrom 14 → 16 so the cluster index can resolve toindividual markers at city‑level zoom without forcing a full layer rebuild.
2. Dynamic cluster radius helper
Added
getDynamicClusterRadius(zoom, baseRadius)(exported helper) thatscales the effective cluster radius by zoom tier:
zoom <= 2→1.5 × baseRadius(world overview, aggressive merging)3–4→1.25 × baseRadius(continental)5–9→1.0 × baseRadius(normal operation)>= 10→0.75 × baseRadius(finer detail in city views)This keeps marker counts bounded at overview zoom while still fanning clusters
out smoothly when zooming in.
3. Viewport windowing for large datasets
filterToViewport(items, bounds, { margin, minItems })helper:items.length >= 200to avoid overhead on small arrays.This avoids iterating over and rendering global arrays when the user is focused
on a single region.
4. Viewport cluster cache key coarsening
(~1.1 km) when caching cluster results.
getClusters()calls during sub‑kilometre pans andsmooth animation, while keeping cluster layouts stable at human map scales.
Tests
Added
tests/deckgl-map-perf.test.mjswith 12 tests:getDynamicClusterRadius(tier boundaries, rounding behaviour).filterToViewport(threshold bypass, global passthrough, regionalsubsets, 20% margin behaviour, null bounds, and out‑of‑bounds rejection).
npm run typechecknode --import tsx --test tests/deckgl-map-perf.test.mjsScreenshots
N/A – behaviour is performance‑related and visible as smoother panning/zooming
rather than UI changes.