fix(policy): spend one round robin turn on a request no worker can take #9233
All Vouch review confidence checks passed
Residual risk 0.34 = Change Risk (0.52) × (1 − Review Confidence (0.34)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 62% · 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
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9233"
general
weight: 0.35
claude[bot]
Description
Under the gateway's in-process option, a
round_robinrequest that no worker can take spends one turn of its list's rotation. It spent two.| What a host sees | Before | Now |
|---|---|---|
| Under the option, a plain request under the
round_robinpreset while no worker of its list is ready, or while every worker is over its thresholds | It spent two turns of the list's rotation. The requests behind it started one worker further along the list | It spends one turn, as the classic selection does where its pass finds nobody over its whole list || The same request, where a worker comes free between its two reads | Two turns, as the classic selection takes there | One turn: the request draws the turn handed back. A difference this change makes, named in the Limits |
| STAYS: a plain request that finds a worker | One turn of its list | The same. The short path's function runs fewer instructions: Numbers |
| STAYS: under the preset, a request whose route's rule refuses the worker its turn lands on | It goes to a rotation of the workers the rule takes | The same. A case holds it |
| STAYS: a caller of
InProcess::pickover a pool no worker of which passes | The turn stays taken | The same. A case holds it || STAYS: a host's picker that takes turns and draws nothing first | It keeps the turn of a pick that kept nobody | The same. A case holds it |
Problem
The short path took a turn of the list for its one pick. Where that pick kept nobody, the whole decision behind it drew the list's turn again. A request that no worker could take so spent two turns, where the classic selection spends one over its whole list.
Solution
The short path hands its turn back where its pick keeps nobody. That is one step back of the list's counter, where the profile's whole decision draws the list's turn and the list holds a worker. A request the whole decision then draws for takes that one turn.
Changes
| File | What |
|---|---|
|
engine/in_process.rs| the short path's pick (pick_ahead) hands the pool to the step back where nobody is kept. The step back (hand_turn_back) is one write behind two tests, out of line. The doc ofInProcess::picksays that its caller keeps its turn at a miss ||
engine/framework/alone.rs|Engine::draws_turn: whether a profile's whole decision draws its list's turn first, by the profile's own mark ||
engine/in_process/single.rs| the short path asks the new pick ||
engine/framework.rs,policies/round_robin.rs| docs alone: what a picker that takes turns does with the list's counter in its one pick, and what the engine does with that turn at a miss ||
docs/design.md| section 5.6 says the miss, its race, what classic does there, and what a route's rule does on the short path. The list of what a decision writes names the step back. The status table names a known fault of the whole decision. Decision 14 gains the exception in a paragraph of its own, and its option (b) names two exceptions || the cases | six new cases, named in the Test Plan's last table; one picker of a host's kind for the third of them; two helpers for the two cases on a route's rule |
No public name or signature changes.
Limits
| Where | What a host sees |
|---|---|
| The step back is a second write of a counter that every deciding thread shares | Between the two writes another request can take the next turn, and the draw behind the miss then lands on that turn too. Where a worker turns eligible in that moment, both requests can go to that one worker, and one turn of the list is passed over |
| A worker comes free between the pick's reads and the draw behind it | The request takes one turn, where the classic selection takes a second step of its list (
select_among). A second read of the list at the miss would cure it. It is not taken: it would read every worker again at each miss || A request the whole decision draws nothing for. One is a later attempt that a host states as a plain request. One is a request declined ahead of the draw, as for an affinity column that does not fit. One is a request that a host's own picker leaves ahead of the counter | It takes no turn at a miss, where it took the one turn of its pick. The test is the profile's own mark, and no fact of the request is made at the miss. The classic selection takes one turn over its whole list. The library's own request type states such a later attempt as plain, and the gateway states none. Where the request finds a worker it takes one turn, as before |
| A whole decision under round robin, where a route's rule refuses the worker its turn lands on | A known fault that this change does not cure. The turn goes to the next of the decision's targets that can be sent to, four at most, which then takes the refused worker's share too: 600 such requests over three workers go 400 and 200. A profile that scores behind
round-robinis decided so, and the preset is not. One case holds it, so that its cure turns the case || A request that states a route's rule, on either road | It takes a turn of the whole list. The classic selection narrows by the rule first, and such a request takes no turn of the whole list there. Where no worker can take it, it takes one such turn now and took two. The design's sentence: "The route's rule is asked of the one picked worker" (section 8.2). A known fault, with a piece of its own to come |
| The first request under a rule | It can go to another worker than under classic. A new set's rotation starts at a drawn worker in the engine, and at the policy's next start in classic |
| The worker a request behind a miss goes to | One worker earlier in the list than on the parent. It is classic's worker where the two started the list at one worker. They start a list at workers of their own (decision 14), as before |
| A request that no worker can take under
randomorpassthrough| It runs the out-of-line test and writes nothing. The parent ran no such test. The test is nine instructions long in the bench's build, and no cell of the bench holds a miss |Test Plan
| Ran | On | Result |
|---|---|---|
| the repository's hooks,
cargo fmt --check, the lint under five feature sets, the three docs builds and the example's check |c0fe07dd5, one change on mainf61ec2c4d| each exits 0 ||
cargo test --locked -p smg-grand-central --all-features| that commit | 5,980 passed, 0 failed, 35 ignored, in 32 programs || the library's cases under
worker-hostalone | that commit | 2,197 passed, 0 failed, 2 ignored || the library's cases with one product line taken out at a time | that commit | the table below |
| the sequences through the gateway's own selection, classic beside the option, by a printing case that is not in the change | that commit, and main
9e89cdc44| the second table below |The author ran every row.
| Line taken out | The library's cases | The cases that turn red |
|---|---|---|
| none | 5,176 passed, 0 failed | none |
| the miss hands no turn back | 5,175 passed, 1 failed |
a_request_no_worker_can_take_takes_one_turn_of_its_list|| a turn is handed back under a profile whose whole decision draws none | 5,174 passed, 2 failed |
a_picker_that_draws_no_turn_keeps_the_turn_of_its_pick,no_turn_is_handed_back_where_none_was_taken|| a turn is handed back wherever the picker takes turns | 5,175 passed, 1 failed |
a_picker_that_draws_no_turn_keeps_the_turn_of_its_pick|| a turn is handed back over a list of no worker | 5,175 passed, 1 failed |
no_turn_is_handed_back_where_none_was_taken|| a list of one worker keeps its two turns | 5,175 passed, 1 failed |
a_request_no_worker_can_take_takes_one_turn_of_its_list|| a caller of
InProcess::pickis handed its turn back too | 5,175 passed, 1 failed |a_pick_that_keeps_nobody_keeps_its_turn|| Through the gateway's selection, a fresh list each | Classic | The option on main
9e89cdc44| The option on the head ||---|---|---|---|
| Three workers, four plain requests, then one request while no worker is ready. The next four plain requests go to workers | 1, 2, 0, 1 | 2, 0, 1, 2 | 1, 2, 0, 1 |
| The same behind two such requests | 2, 0, 1, 2 | 1, 2, 0, 1 | 2, 0, 1, 2 |
| The same behind three such requests | 0, 1, 2, 0 | 0, 1, 2, 0 | 0, 1, 2, 0 |
| Four workers, with no worker ready and with every worker over its thresholds. Behind one, two and three such requests the next plain request goes | one, two and three workers further | not run | one, two and three workers further |
| 600 requests in a row whose route's rule refuses the first worker of three, by worker | 0, 300, 300 | 0, 300, 300 | 0, 300, 300 |
| 600 times two plain requests and one such ruled request: the plain ones by worker, then the ruled ones | 400, 400, 400 and 0, 300, 300 | 600, 600, 0 and 0, 0, 600 | 600, 600, 0 and 0, 0, 600 |
| Case | What it holds |
|---|---|
|
a_request_no_worker_can_take_takes_one_turn_of_its_list| under round robin, over 1, 4, 16 and 64 workers: one, two and three requests while no worker is ready, and the same while every worker is over its thresholds. The list's counter moves once a request, and the four requests behind go to the workers in turn from there ||
no_turn_is_handed_back_where_none_was_taken| underrandomandpassthrougha request that no worker can take leaves the list's counter where it stood. So does a request over a list of no worker under round robin ||
a_picker_that_draws_no_turn_keeps_the_turn_of_its_pick| a host's picker that takes turns and draws nothing first: its request that no worker can take moves the list's counter once ||
a_pick_that_keeps_nobody_keeps_its_turn|InProcess::pickover a pool no worker of which passes: the pool's counter moves by that one turn, and the pick behind it lands one worker further than the turn that kept nobody ||
a_turn_the_routes_rule_refuses_goes_to_the_rotation_of_the_workers_it_takes| under the preset, three workers, the first turn's worker refused: the places of six such requests in a row, and 600 go 300 and 300 ||
a_whole_decision_hands_a_turn_its_routes_rule_refuses_to_the_next_worker| the known fault as it stands, under a profile that scores behindround-robin: the places of six such requests in a row, and 600 go 400 and 200 |Numbers
Instructions a decision of the crate's
in_processbench, one caller, by the difference of two Callgrind runs of 20,000 and 60,000 decisions. Both sides were counted in one run of one tool, three rounds. A cell reads its lowest and its highest round.| Cell, workers | Parent
f61ec2c4d| Headc0fe07dd5| Moves beyond one side's spread ||---|---|---|---|
|
round_robin, 8 | 388.1 to 389.8 | 383.5 to 384.1 | -4.0 at the nearest runs, -4.9 by the medians ||
round_robin, 64 | 385.5 to 390.6 | 381.4 to 386.7 | within one binary's spread ||
random, 8 | 428.0 to 429.1 | 424.0 to 425.1 | -2.9 at the nearest runs, -3.0 by the medians ||
random, 64 | 426.6 to 429.0 | 425.0 to 425.1 | -1.5 at the nearest runs, -4.0 by the medians ||
passthrough, 8 | 395.0 | 389.3 to 391.9 | -3.1 at the nearest runs, -4.6 by the medians ||
passthrough, 64 | 395.0 to 396.4 | 387.5 to 391.1 | -3.9 at the nearest runs, -4.6 by the medians |By function,
single::alone, the short path, reads 87.0 instructions a decision on the parent and 83.0 on the head, in all six cells. The worker's test reads 25.0 on both sides. The rest of a cell's move is the spread of its rounds.Release note
Under the in-process option, a
round_robinrequest that no worker can take now spends one turn of its list's rotation, where it spent two. The classic policy spends one over its whole list.