perf(rpc): Cache allocation policy instances - #8244
Open
scttcper wants to merge 1 commit into
Open
Conversation
RPC routing builds the same three EAP allocation policies before and after each query. Reuse those immutable policy definitions while continuing to read runtime config for every decision. Saves around 50-70 microseconds of Python CPU per normal RPC. Co-Authored-By: Codex <noreply@openai.com>
scttcper
marked this pull request as ready for review
July 30, 2026 21:21
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.
RPC storage routing asks for the default EAP allocation policies before query execution and again afterward to update balances. Each lookup currently reconstructs the same three policies and their configuration definitions, so a normal RPC builds six policy objects.
This caches the policy instances while returning a fresh list to callers. Runtime config is still read for every decision. The current policies do not keep per-request instance state, and regular storage already reuses policy instances this way.
A policy lookup drops from 25.89 us to 0.05 us, saving about 52 us of Python CPU for a normal RPC with two lookups.