Repository navigation
fix(mux-h2): rotate the RFC 9218 incremental tail in every urgency bucket, not just the leading one - #1492
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 24, 2026 03:15
`Prioriser` held ONE connection-global `incremental_cursor`.
`apply_incremental_rotation` applied it to every urgency bucket's
incremental tail, but `H2Scheduler::end_pass` could only ever commit an
id drawn from the lowest-numbered urgency bucket that had a ready
incremental stream fire — the pass order is ascending by urgency, so the
first stream to consume send window always came from there. Every other
bucket was rotated by a cursor from a foreign id range, and a cursor
sitting entirely below or entirely above a bucket's own ids makes
`partition_point` return a constant, so `rotate_left(0)` was a no-op
forever.
Measured, u=0 incremental {1, 3} beside u=3 incremental {5, 7}, all
ready and all consuming, six passes:
[[1,3,5,7], [3,1,5,7], [1,3,5,7], [3,1,5,7], [1,3,5,7], [3,1,5,7]]
The u=0 tail alternates as invariant 26 promised; the u=3 tail is 5, 7
in every pass and stream 7 never leads its bucket. It now reads
[[1,3,5,7], [3,1,7,5], [1,3,5,7], [3,1,7,5], [1,3,5,7], [3,1,7,5]]
Positional starvation today — every stream still gets its frame, just
never the lead position in its bucket — and byte starvation the moment a
pass is cut short, since a stalled flush leaves the same trailing
streams unwritten pass after pass.
Three changes carry it. `incremental_cursor: [StreamId; 8]`, exact
rather than a cap because RFC 9218 §4.1 urgency is [0, 7] and
`Prioriser::push_priority` already clamps into it. A per-bucket
`first_incremental_fired` in `ReadyIncrementalCensus`, with `end_pass`
committing each bucket's own leader. And
`ReadyIncrementalCensus::note_fired` now takes the urgency, matching
`note_ineligible`'s existing shape — without it the census cannot
attribute the firing stream to a bucket and can only name one leader per
connection. The leading bucket's semantics are unchanged: each bucket
still commits the FIRST stream of that bucket which consumed window,
never the last, and `consumed > 0` stays load-bearing.
This changes bytes on the wire, so it carries e2e evidence rather than
an argument. `test_h2_per_bucket_incremental_rotation` reads the
trailing bucket's leader out of the DATA frame trace: before,
`[5, 5, 5, 5, 5, 5, 5]` over seven passes; after, `[5, 7, 5, 7, 5, 7, 5]`.
Not marked breaking — `mod h2_scheduler` is private so no published API
signature moves, no configuration key, CLI flag, protobuf message or
metric name changes, and HTTP/2 offers no cross-stream ordering
guarantee a peer could have depended on. The new order is more
conformant to RFC 9218 §4, not a different contract.
`the_round_robin_cursor_is_connection_global_so_only_the_leading_bucket_rotates`
is deleted rather than re-expected, as its own doc comment asked. Its
scenario is now `every_urgency_bucket_rotates_its_own_incremental_tail`,
and `fairness_property` gained a second multi-peer incremental bucket at
strictly lower priority with a per-bucket oracle. Restoring the global
commit reds exactly three of sozu-lib's 1093 tests, all three of them
this changeset's new coverage, and leaves the other 1090 green.
Refs #1456
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/h2-per-bucket-rotation
branch
from
September 24, 2026 05:14
ab1ae41 to
2bcfc9f
Compare
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.
Closes #1456.
Prioriserheld one connection-globalincremental_cursor, so only the lowest-numbered urgency bucket with a ready incremental stream could ever commit a leader. A cursor sitting entirely below — or above — another bucket's id range makespartition_pointreturn a constant, androtate_left(0)is a no-op forever.The issue's measured case, u=0 incremental
{1,3}+ u=3 incremental{5,7}, all ready, all consuming, six passes:The u=0 tail alternated correctly all along. The u=3 tail was
5,7in every pass — stream 7 never led its bucket.Today that is positional starvation: every stream still gets its frame. It becomes byte starvation the moment a pass is cut short — a stalled flush partway through the order leaves the trailing streams unwritten, pass after pass, always the same ones, because the order never rotates. RFC 9218 §4 specifies round-robin within an urgency level without qualification, so the old behaviour was a partial implementation rather than a deliberate policy.
Wire-ordering evidence, which the issue asked for over unit tests
New
test_h2_per_bucket_incremental_rotation: four streams,u=0,ion 1/3 besideu=3,ion 5/7, 96 KiB bodies, four backends, using theINITIAL_WINDOW_SIZE=0+ bulk-WINDOW_UPDATEhandshake so one fully-populated four-stream pass is released. It splits the DATA trace into passes on the leading bucket and reads each bucket's first-of-pair.Stream 7 leads zero of seven passes before, three of seven after, on a real TLS wire.
repeat_until_error_or(3, …): 3/3 consecutive.The sharpest check in the changeset: restoring the faithful pre-fix behaviour — the lowest urgency's leader written to every cursor — reds exactly 3 of 1093
sozu-libtests, all three the new coverage, with the other 1090 green. That measures that the leading bucket's semantics are unchanged, which is the second prohibition in the issue.What changed
incremental_cursor: [StreamId; 8]replacing the single id. Urgency is[0, 7]and already clamped, so the array is exact — no bounds fallback that would imply otherwise.first_incremental_fired: [Option<StreamId>; 8]andadvance_incremental_cursor(&[Option<StreamId>; 8]).note_fired(&mut self, urgency: u8, stream_id: StreamId, is_incremental: bool, consumed: i32)— urgency first, matching the existingnote_ineligible(urgency, is_incremental). The census could not previously attribute a firing stream to a bucket; the issue named this signature change as the non-obvious part of the work.end_passcommits each bucket's own leader instead of one connection-global id.The pinning test was deleted, not edited
the_round_robin_cursor_is_connection_global_so_only_the_leading_bucket_rotatesis deleted (83 lines); its expectation was never touched. Its doc comment said explicitly that editing it in place would convert a deliberate record into a silent rewrite. The scenario moved toevery_urgency_bucket_rotates_its_own_incremental_tailwith a corrected oracle, andfairness_property's generator gained a second multi-peer incremental bucket at strictly lower priority — its oracle moved from "the main bucket's leader" to the cyclic successor of every generated bucket, built from a grouping of the plan's own entries so a distractor colliding into a bucket is covered.Blast radius the issue did not name: the citation gate fails on a backticked test name that resolves to no
fn, and two historical[Unreleased]/Changedentries describe the extraction commits by that name. Rewriting them would misstate what those commits did. Used the checker's documentedRENAMED_TESTSforwarding — the same shape as its existing sozu#1350/#1356 entries — which keeps the pointer live and requires the target itself to resolve. NotNOT_A_TEST, which would be silencing.Not BREAKING
mod h2_scheduler;is private inmux/mod.rs, soPrioriserand itspub fn advance_incremental_cursorare unreachable outsidesozu-lib— no published signature moves. No proto, config key, CLI flag or metric name changes. HTTP/2 offers no cross-stream ordering guarantee and RFC 9218 §4 is unqualified, so the new order is more conformant rather than a different contract. Filed under### 🐛 Fixed, with the observable change named: on a connection with two populated incremental buckets, the trailing bucket's DATA order was stable and now rotates.Downstream stability sweep, dispositioned:
try_h2_mixed_urgency_incremental_solo_drainsandtry_h2_customer_har_shape_drainshold exactly one incremental stream per bucket;try_h2_rfc9218_incremental_round_robinandtry_h2_mid_pass_rst_does_not_force_yieldare single-bucket. One peer leaves nothing to rotate and a lone bucket was always the leader — unaffected by construction, and all pass.Reference sweep
note_fired,incremental_cursor,advance_incremental_cursor,end_pass,first_incremental_firedand the deleted test name, repo-wide, no file-type filter.updated —
h2_scheduler.rs(all sites),h2.rscall site and its four-mechanism note,h2_transmit.rs(its fairness section asserted the frozen trailing bucket as current behaviour — now past tense),h2_write_pass.rs×2,LIFECYCLE.mdinvariant 26 (rewritten to per-bucket scope),doc/h2_mux_internals.md×8,doc/testing.md, andlib/benches/h2_scheduling.rs, which carries its ownincremental_cursor/partition_pointcopy.unaffected — six historical
CHANGELOG.mdentries (rewriting them would misstate those commits; the dead name is forwarded);h2_flow_control.rs's citation of the cursor as a design precedent, still true per-bucket;h2_write_pass.rs's references to thebegin_pass/end_passpairing, whose signature did not change;h2.rs's generic "once per" ordering claim, still accurate.Verification
No test newly ignored, no assertion loosened, no lint escape, no
#[allow]added. The one deletion is the pinning test, which the issue mandates.