perf: pick a single random server without copying the replica set #20951
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.39) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 266 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.334
Real PR Conversation Timeline
1 comments
"Review active on #20951"
general
weight: 0.35
FrankChen021
Description
Tier selector strategies pick one server per segment by calling
ServerSelectorStrategy.pick(servers, segment, 1). When a segment has more than one replica,RandomServerSelectorStrategyhandled that by copying the set into a list, shuffling it, and copying the first element into another list. It did that for every segment of every query: once when routing segments to servers, and once in the result-level cache ETag computation, which checks per segment that the picked server is a Historical.In a sampling profile of a Broker serving result-level cache hits over 160,983 segments, those copies were about 18% of the query thread. The profile had about 110 samples on that thread, so the share is approximate.
Choose one server directly for a single pick
When
numServersToPickis 1 and there is more than one server,RandomServerSelectorStrategynow returns one server chosen withIterators.get(servers.iterator(), random index), the same way its single-serverpick(servers, segment)already did. Every server is still equally likely to be picked. Picks of more than one server, and sets no larger than the number requested, behave as before. Other server and tier selector strategies are unchanged.An alternative was to change
AbstractTierSelectorStrategyto call the single-server pick directly. I didn't, because several tier strategies (preferred, strict, pooled) override the list-returningpick, and their single picks go through that override.<hr>
##### Key changed/added classes in this PR
*
RandomServerSelectorStrategy<hr>
This PR has:
-
TierSelectorStrategyTest: single picks return one server and reach every server, and picks of 2 and 3 servers still work.