Files
meshcore-analyzer/cmd/server/resolved_pubkeys_bench_test.go
n30nexandn30nex d80ce90976 fix(store): release evicted packet references from secondary indexes (#2327)
Addresses #2324 for upstream SQLite; PostgreSQL qualification remains
separate.

Eviction releases actual node memberships, pointer tails and cache roots
without SQL reconstruction. Borrowed distance snapshots and bounded
hash-migration ownership remain protected.

Review correction `0b1049b5` skips each distance-array copy when no
record is evicted from that array. When affected, it clones once and
filters the suffix beginning at the first match, preserving borrowed
snapshots and the surviving prefix. Work remains O(distance records); no
new locks, reader bookkeeping, settings or general speedup claim.

Tests-only `16509577` reaches [three real assertion failures in
CI](https://github.com/Kpa-clawbot/CoreScope/actions/runs/43200112374/job/131121073845).
GREEN leaves those tests unchanged. Cases cover
neither/hops-only/paths-only impact, repeated removals, live prefixes,
tail removal and snapshot contents. Parent independently reproduced RED
and reran GREEN.

Full native server/ingestor suites pass. Targeted checks: 167 passed;
race: 165 passed, with two existing timing skips that pass in the
ordinary run. Current master `a0b4e6cf` is normally merged; original
RED/GREEN history is preserved.

Historical November 10 measurements: synthetic retained heap 98.00→27.14
MiB with equal live data; path-update cost at 30k hops/10k paths
0.591→3.675ms and 2,824→5,368,584 B/op. The older ~30ms extra eviction
lock time at 240k transmissions is unremeasured. Large-window
qualification/optimization: #2393. Invalidated migration progress:
#2394; no SQL migration redesign here.

Browser verified: populated matching revision (500 transmissions/502
observations), 3/3 interactions. [Final
CI](https://github.com/Kpa-clawbot/CoreScope/actions/runs/43202356164)
and three independent reviews pass. No settings changes.

---------

Co-authored-by: n30nex <6686206+n30nex@users.noreply.github.com>
2026-11-15 12:24:43 +01:00

28 lines
656 B
Go

package main
import (
"fmt"
"strings"
"testing"
)
// One resolved_path per observation: 5 relays and 3 unresolved hops, drawn
// from a pool of 2,000 relays, as on a busy instance.
func BenchmarkResolvedPubkeysFromJSON(b *testing.B) {
const pool = 2000
paths := make([]string, 256)
for i := range paths {
hops := make([]string, 0, 8)
for h := 0; h < 5; h++ {
hops = append(hops, fmt.Sprintf(`"%064x"`, (i*7+h*131)%pool))
}
hops = append(hops, "null", "null", "null")
paths[i] = "[" + strings.Join(hops, ",") + "]"
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = resolvedPubkeysFromJSON(paths[i%len(paths)])
}
}