perf(server): cache gas-costs and node-sessions reads#16
Open
Sentinel-Bluebuilder wants to merge 1 commit into
Open
perf(server): cache gas-costs and node-sessions reads#16Sentinel-Bluebuilder wants to merge 1 commit into
Sentinel-Bluebuilder wants to merge 1 commit into
Conversation
Two read-heavy LCD endpoints recomputed their full scan on every hit. Wrap both in cached() with invalidation on the writes that change them. - GET /api/feegrant/gas-costs: fires one LCD tx-search per subscriber address (a 900-subscriber plan = ~900 serial 30s-timeout calls, minutes of wall-clock). Cache the whole computed result 5 min keyed by gasCosts:<planId>:<operator> — the operator is in the key because the result filters on fee.granter === getAddr(), so a different signer must not read a stale total. Also switch the per-address probe loop from one-at-a-time to bounded-concurrency waves (GAS_CONCURRENCY = 8) so a cold-cache scan drops from ~N serial calls to ceil(N/8) waves; cap at 8 to avoid saturating the LCD pool (node scan already runs at 30). - GET /api/nodes/:addr/sessions: walks up to 50 LCD pages (25k sessions) client-filtering for one node. Cache 2 min keyed by nodeSessions:<addr>. Invalidate that key on start-session success so the next read reflects the new session. Read-only RPC-first stays intact for the subscriptions sub-query; LCD is fallback. No behavior change to response shapes.
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.
What
Two read-heavy LCD endpoints recomputed their full scan on every request. This wraps both in
cached()and invalidates on the writes that change them.GET /api/feegrant/gas-costsFires one LCD tx-search per subscriber address — a 900-subscriber plan is ~900 serial 30s-timeout calls (minutes of wall-clock) on every hit.
gasCosts:<planId>:<operator>. The operator is in the key because the result filters onfee.granter === getAddr(), so a different signer must not read another operator's stale total.GAS_CONCURRENCY = 8): a cold-cache scan drops from ~N serial calls toceil(N/8)waves. Capped at 8 to avoid saturating the LCD pool (node scan already runs at 30).GET /api/nodes/:addr/sessionsWalks up to 50 LCD pages (25k sessions) client-filtering for one node.
nodeSessions:<addr>.Notes
node --checkpasses. No non-ASCII edits.Relationship to other PRs
Part of the four-way split of an intermingled working tree: #13 (audit hardening), #14 (plan-nodes caching), #15 (FE optimistic reconcile), and this PR (server gas/session read caching). Independent of the others — touches only the two routes above.