mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-05-24 21:25:22 +00:00
6dacdef6b8
The subpaths analytics endpoint iterated ALL packets on every cold query, taking ~900ms. The TTL cache only masked the problem. Fix: maintain a precomputed raw-hop subpath index (map[string]int) that is built once during Load() and incrementally updated during IngestNewFromDB() and IngestNewObservations(). At query time the fast path iterates only unique raw subpaths (typically a few thousand entries) instead of all packets (30K+), resolves hop prefixes to names, and merges counts. Region-filtered queries still fall back to the O(N) path since they require per-transmission observer checks. Expected cold-hit improvement: ~900ms → <5ms for the common no-region case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>