perf: memoize the Lines read model (explicit invalidation + 60s TTL net) - #19
Closed
lr00rl wants to merge 1 commit into
Closed
perf: memoize the Lines read model (explicit invalidation + 60s TTL net)#19lr00rl wants to merge 1 commit into
lr00rl wants to merge 1 commit into
Conversation
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.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lineReadModel(): cached groups +line_hash_idindex;lines.getresolves via the index (no more fleet rebuild + linear scan per call).Stacked on #18.
Verification
gofmt/go vetclean;go test ./internal/server/ok (20.9s)Refs LatticeNet/lattice#2.