Skip to content

perf(rpc): Cache allocation policy instances - #8244

Open
scttcper wants to merge 1 commit into
masterfrom
scttcper/cache-rpc-allocation-policies
Open

perf(rpc): Cache allocation policy instances#8244
scttcper wants to merge 1 commit into
masterfrom
scttcper/cache-rpc-allocation-policies

Conversation

@scttcper

@scttcper scttcper commented Jul 30, 2026

Copy link
Copy Markdown
Member

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.

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
scttcper marked this pull request as ready for review July 30, 2026 21:21
@scttcper
scttcper requested review from a team as code owners July 30, 2026 21:21
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