Skip to content

perf: memoize the Lines read model (explicit invalidation + 60s TTL net) - #19

Closed
lr00rl wants to merge 1 commit into
feat/design-15-metadata-syncfrom
feat/lines-read-model-cache
Closed

perf: memoize the Lines read model (explicit invalidation + 60s TTL net)#19
lr00rl wants to merge 1 commit into
feat/design-15-metadata-syncfrom
feat/lines-read-model-cache

Conversation

@lr00rl

@lr00rl lr00rl commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • lineReadModel(): cached groups + line_hash_id index; lines.get resolves via the index (no more fleet rebuild + linear scan per call).
  • Explicit invalidation on every state change that feeds the view: sing-box inventory ingest, proxy inbound/user/profile upserts+deletes, node upserts+delete, vpn-core identity mutations, proxycore apply outcomes, profile configure.
  • 60s TTL as documented safety net for missed edge paths — operator-driven mutations all invalidate explicitly, so the UI never reads stale after its own actions.

Stacked on #18.

Verification

  • gofmt/go vet clean; go test ./internal/server/ ok (20.9s)
  • New tests: build-once + serve-cached, stale until invalidate, index lookup, TTL forces rebuild, ingest invalidates

Refs LatticeNet/lattice#2.

The unified Lines view used to rebuild fleet-wide on every call —
lines.get included a full rebuild plus a linear scan for a single hash.
A small cache now holds the built groups and a line_hash_id index,
rebuilt only after explicit invalidation: inventory ingest, proxy
inbound/user/profile writes, node writes, vpn-core identity mutations,
and apply outcomes. A 60s TTL is the documented safety net for a missed
edge path; operator-driven mutations all invalidate explicitly, so the
UI never reads stale after its own actions.
@lr00rl

lr00rl commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #20, which rebased the complete remaining Design 15 stack onto alpha/v0.2.2 and passed go test, go vet, gosec, govulncheck, formatting, and Docker contract CI before merge as 86422a1.

@lr00rl lr00rl closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant