perf: cache plan-nodes query (provider-scoped, 15s TTL) to fix add-nodes delay#14
Open
Sentinel-Bluebuilder wants to merge 1 commit into
Open
perf: cache plan-nodes query (provider-scoped, 15s TTL) to fix add-nodes delay#14Sentinel-Bluebuilder wants to merge 1 commit into
Sentinel-Bluebuilder wants to merge 1 commit into
Conversation
getNodesForPlan does an RPC QueryNodesForPlan plus a per-member rpcQueryLeasesForNode fan-out. It was re-run on every Add-Nodes keystroke, filter, and post-link refetch, which was the root of the "big delay before added nodes show" symptom. Wrap it in cached() keyed by planId + provider (the per-node lease lookup selects OUR lease via prov_address === getProvAddr(), so the result is provider-specific). Short 15s TTL keeps it fresh. Link/unlink/batch-link/batch-unlink success paths call invalidatePlanNodes(planId) so a just-added or just-removed node is reflected on the very next refetch (subject to chain indexing).
This was referenced Jun 21, 2026
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
Caches the expensive
getNodesForPlanquery and invalidates it on link/unlink.Why
getNodesForPlanperforms an RPCQueryNodesForPlanplus a per-memberrpcQueryLeasesForNodefan-out. It was being re-run on every Add-Nodeskeystroke, every filter change, and every post-link refetch — the root cause of
the "big delay before added nodes show" symptom operators reported.
How
_getNodesForPlanImpl(planId).getNodesForPlan(planId)wraps it incached()with a 15s TTL, keyedby
planNodes:<planId>:<provider>. The key is provider-scoped because theper-node lease lookup selects our lease (
prov_address === getProvAddr()),so results are provider-specific and must not be shared across operators.
invalidatePlanNodes(planId)does an exact-keycacheInvalidate.link,batch-link,unlink,batch-unlink—call
invalidatePlanNodes(planIdNum)right after the ownership gate, so ajust-added/removed node is reflected on the very next refetch (subject to chain
indexing latency).
Notes
getRpcClient()path unchanged inside the impl).cached/cacheInvalidateare already imported fromblue-js-sdk; the SDK'scacheInvalidate(key)is an exact-key delete (no prefix match), which is whyinvalidation reconstructs the same
planNodes:<id>:<prov>key.server.jsonly; no behavior change when the cache misses.🤖 Generated with Claude Code