Files
meshcore-analyzer/cmd/server
n30nex 63d63ea90a perf(healthz): avoid scanning retained packets after startup (#2305)
Fixes #2301.

Readiness probes currently scan every retained transmission while
holding the packet-store read lock. Once `StartupLoadDone` closes, this
reads the maintained observation counter beside the transmission count
under that same lock. Count extraction becomes O(1), with no new cache,
query or allocation.

Startup retains the original scan: the background loader publishes
indexes before its packet slice, so switching on readiness or
`LoadComplete` would be premature. Response fields, readiness status,
ingestion and configuration remain unchanged.

Whole-handler benchmark medians, microseconds per probe:

| Retained transmissions | Upstream | Candidate |
| ---: | ---: | ---: |
| 1,000 | 72.14 | 83.84 |
| 30,000 | 320.85 | 65.74 |
| 100,000 | 1,228.50 | 81.97 |

Four alternating pairs, 10,000 iterations/size, real SQLite-loaded
fixtures with three observations per transmission on average; Go 1.27.2,
Windows/amd64, two CPUs. All samples retained; shared-host variability
means no small-cache or production-latency improvement is claimed.
Allocations remain 36/probe. The included benchmark supports
reproduction against unchanged upstream production plus the identical
harness.

TDD exemption: pure performance refactor; **all pre-existing test files
are byte-unchanged**. Added characterization tests pass before and
after, covering loaders, deduplication, live updates, eviction, partial
startup failures, concurrent snapshots and liveness. Independent review
prompted test-only follow-up `2a0083b1`, which detects premature counter
use; production remains identical to measured `1b8e6680`.

Full server, race, ingestor and post-push browser/API checks pass
locally. [Final-head CI
passes](https://github.com/Kpa-clawbot/CoreScope/actions/runs/40213482779),
including all browser shards and architecture builds. No customizer
changes.
2026-10-26 15:42:15 +01:00
..