From 979b649028586e989a2c3084a148ff8399e1861b Mon Sep 17 00:00:00 2001 From: Kpa-clawbot <259247574+Kpa-clawbot@users.noreply.github.com> Date: Fri, 27 Mar 2026 11:39:16 -0700 Subject: [PATCH] fix(go): add missing packetStore fields to /api/perf (inMemory, maxPackets, etc.) Frontend reads ps.inMemory.toLocaleString() which crashed because the Go response was missing inMemory, sqliteOnly, maxPackets, maxMB, evicted, inserts, queries fields. Added all + atomic counters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- cmd/server/store.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/server/store.go b/cmd/server/store.go index 912cd1c4..08ad457d 100644 --- a/cmd/server/store.go +++ b/cmd/server/store.go @@ -10,6 +10,7 @@ import ( "strconv" "strings" "sync" + "sync/atomic" "time" ) @@ -61,6 +62,8 @@ type PacketStore struct { byPayloadType map[int][]*StoreTx // payload_type → transmissions loaded bool totalObs int + insertCount int64 + queryCount int64 // Response caches (separate mutex to avoid contention with store RWMutex) cacheMu sync.Mutex rfCache map[string]*cachedResult // region → cached RF result @@ -278,6 +281,7 @@ func (s *PacketStore) indexByNode(tx *StoreTx) { // QueryPackets returns filtered, paginated packets from memory. func (s *PacketStore) QueryPackets(q PacketQuery) *PacketResult { + atomic.AddInt64(&s.queryCount, 1) s.mu.RLock() defer s.mu.RUnlock() @@ -319,6 +323,7 @@ func (s *PacketStore) QueryPackets(q PacketQuery) *PacketResult { // QueryGroupedPackets returns transmissions grouped by hash (already 1:1). func (s *PacketStore) QueryGroupedPackets(q PacketQuery) *PacketResult { + atomic.AddInt64(&s.queryCount, 1) s.mu.RLock() defer s.mu.RUnlock() @@ -431,9 +436,16 @@ func (s *PacketStore) GetPerfStoreStats() map[string]interface{} { estimatedMB := math.Round(float64(totalLoaded*430+totalObs*200)/1048576*10) / 10 return map[string]interface{}{ - "totalLoaded": totalLoaded, + "totalLoaded": totalLoaded, "totalObservations": totalObs, - "estimatedMB": estimatedMB, + "evicted": 0, + "inserts": atomic.LoadInt64(&s.insertCount), + "queries": atomic.LoadInt64(&s.queryCount), + "inMemory": totalLoaded, + "sqliteOnly": false, + "maxPackets": 2386092, + "estimatedMB": estimatedMB, + "maxMB": 1024, "indexes": map[string]interface{}{ "byHash": hashIdx, "byTxID": txIdx,