Skip to content

The RFC 9218 incremental cursor is connection-global, so only the leading urgency bucket ever rotates #1456

Closed

Description

@FlorentinDUBOIS

Prioriser holds one connection-global incremental_cursor. apply_incremental_rotation applies it to every urgency bucket's tail, but end_pass can only commit an id from the lowest-numbered urgency bucket that had a ready incremental stream fire, because the pass order is ascending by urgency. A cursor sitting entirely below — or above — a bucket's own id range makes partition_point return a constant, so rotate_left(0) is a no-op forever.

Measured, u=0 incremental {1,3} + u=3 incremental {5,7}, all ready, 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 correctly. The u=3 tail is 5,7 in every pass — stream 7 never leads its bucket.

This is not a regression. Prioriser is byte-identical to its pre-extraction form and the original field doc always scoped it honestly as "the incremental tail of the lowest-urgency bucket that contained at least one incremental stream". What the sans-io extraction did was force someone to write the fairness argument down for the first time, which is how the gap became visible. LIFECYCLE invariant 26 is now correctly scoped to the leading bucket, and a test pins the frozen trailing bucket as observed behaviour rather than leaving it implicit.

Why it is worth fixing rather than documenting forever

Today it is positional starvation: every stream still gets its frame, just never the lead position in its bucket.

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. On a connection with several urgency levels and a constrained send window, that is a stream that makes no progress while its peers do.

RFC 9218 §4 describes round-robin within an urgency level, so the current behaviour is a partial implementation, not a deliberate policy.

What the fix costs

Enumerated while scoping invariant 26, not guessed:

  • incremental_cursor: [StreamId; 8] in place of the single id — urgency is [0, 7] and already clamped, so the array is exact rather than a cap.
  • A per-bucket leader in the census. note_fired is not currently given the urgency, so it cannot attribute the firing stream to a bucket. That signature change is the non-obvious part of the work.
  • A matching end_pass that commits each bucket's own leader rather than one connection-global id.
  • Wire-ordering changes on multi-bucket connections. This is the part that needs evidence rather than reasoning: today's order is stable in the trailing buckets, and after the fix it rotates. Any test or downstream expectation that quietly depends on that stability will change behaviour.

Asked for

Implement per-bucket rotation, with e2e evidence for the wire-ordering change rather than unit tests alone.

Delete the pinning test rather than updating its expectation. the_round_robin_cursor_is_connection_global_so_only_the_leading_bucket_rotates exists to record the current behaviour; when this lands, the scenario belongs in fairness_property with a corrected oracle. Its doc comment says this explicitly. Changing its expected value in place would convert a deliberate record into a silent rewrite.

The red test must be the multi-bucket case above: two urgency buckets each holding ≥2 ready incremental peers, asserting that both tails rotate. Today that fails; fairness_property's generator places distractors in strictly lower-priority buckets precisely so its main bucket always leads, so it cannot see this and must not be the only coverage.

Do not

Do not widen fairness_property's generator to cover this without also fixing the code — that converts a passing property into a failing one with no fix attached. And do not "fix" it by making end_pass commit the last stream that fired rather than the first: that changes the leading bucket's semantics to chase the problem elsewhere.

Activity

  1. FlorentinDUBOIS commented on Sep 23, 2026

    @FlorentinDUBOIS
    CollaboratorAuthor

    Decision: fix it, sequenced after the write_streams inversion

    The per-bucket cursor is the right shape — incremental_cursor: [StreamId; 8], exact rather than a
    cap because urgency is already clamped to [0, 7] — together with the note_fired signature change
    that lets the census attribute a firing stream to its own bucket, and an end_pass that commits each
    bucket's leader instead of one connection-global id.

    Documenting the current behaviour permanently was considered and rejected: RFC 9218 §4 specifies
    round-robin within an urgency level, so what ships today is a partial implementation rather than a
    policy, and the positional starvation becomes byte starvation as soon as a pass is cut short by a
    stalled flush.

    Sequenced after the write_streams inversion, not before. That work rewrites the code
    immediately adjacent to the scheduler this change touches, so landing the cursor first buys a
    guaranteed conflict on the same lines for no benefit.

    When it is implemented, the wire-ordering change on multi-bucket connections needs evidence rather
    than reasoning
    : today's order is stable in the trailing buckets and will rotate afterwards, so any
    test or downstream expectation quietly depending on that stability changes behaviour. Enumerate what
    depends on it before changing it.

    Invariant 26 and the test pinning the frozen trailing bucket stay as they are until then — they
    correctly describe the tree as it ships.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions