perf(mapillary): race dart-throw windows concurrently

Each Mapillary window query costs ~1-5s and most windows hold no
panoramas, so throwing them one at a time made /api/new-game wait for
the sum of every miss. Measured in production: median 17.8s, max 90.5s
over 18 samples.

Throw 8 windows per round instead, race them with Promise.any and abort
the losers once one yields panoramas. Wall time becomes one round-trip
in the common case. Same 20-window budget, same per-city delta, same
401 short-circuit.

After the change, over 10 samples: median 5.6s, max 20.3s.
This commit is contained in:
tiennm99 committed 2026-08-29 14:27:42 +07:00
1 parent 493f29621e
commit 1c62e3e1dd
4 files changed
+93 -48

No files matched your search

+2 -1
View File
@@ -7,7 +7,8 @@
## Street View & Mapping
- **Mapillary API**: Panoramic street-level imagery provider (thumb_original_url, is_pano=true filter)
- **Dart-throw strategy**: pick random point in city bbox, query small fixed-size sub-bbox (2×delta), re-roll on empty. Keeps query cost under Mapillary cap.
- **Dart-throw strategy**: pick random points in city bbox, query small fixed-size sub-bboxes (2×delta), re-roll on empty. Keeps query cost under Mapillary cap.
- **Concurrent rounds**: 8 windows raced per round (20 max total). A Mapillary round-trip costs ~1-5s, so racing keeps wall time at one round-trip instead of the sum of every miss.
- **Per-city delta**: configurable in CITIES enum (`src/lib/game.js`). HN: 0.003° (~333m), others: 0.005° (~556m)
- **Leaflet**: Interactive mapping library for guess placement
- **OpenStreetMap**: Map tile provider for base maps