transport: per-stream send priority API + priority-aware drain#243
Merged
Conversation
quinn SendStream::set_priority equivalent. The pending-send drain now serves strictly descending priority tiers; within a tier the walk keeps arrival order and emits one chunk per entry per pass, so equal-priority streams round-robin exactly as before. - ConnState: `priority_stream_ids` (binary void-set from #236) becomes `stream_priorities: AutoHashMapUnmanaged(u64, i32)`. New helpers: `streamPriority(sid)` (0 default) and `nextPriorityTierBelow(bound)` (the tier selector — O(entries) per tier, O(entries × distinct priorities) per drain call; libp2p uses two classes in practice). - Public API: `Server.setStreamPriority(conn, sid, i32)` / `Client.setStreamPriority(sid, i32)`. Priority 0 clears the entry. Existing `markStreamPriority` / `unmarkStreamPriority` become shims (set 1 / clear) — embedder-compatible, and the #236 byte-budget headroom now keys on `priority > 0`, preserving its semantics (negative priority orders below default WITHOUT the headroom). - drainPendingStreamSends (server + client): outer tier loop wraps the existing walk with a tier filter. All existing gates unchanged — per-drive send budget and per-call cap are shared across tiers (`break :outer`), CC/pacer block still aborts the whole drain, FC-blocked entries in a higher tier are skipped on lower passes by the filter (no double-send). With no priorities set there is exactly one tier (0) and the walk order is identical to before. Tests: priority set/clear + budget headroom (positive vs negative), tier-selector descending walk, and a loopback proof that a one-send-budget drain picks the high-priority entry over an earlier-arrived low-priority one, then shim-clear restores default. 299/300 pass (1 pre-existing skip). Local interop: handshake green; transfer/multiplexing flake locally on clean master too (NS3-on-macOS environment, not this change) — CI interop gate is authoritative.
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 #191. Last open implementation item from the #138 gap tracker (with #192/BBR deferred as backlog).
Summary
quinn
SendStream::set_priority(i32)equivalent:Server.setStreamPriority(conn, stream_id, priority)/Client.setStreamPriority(stream_id, priority)— default 0, higher drains first, 0 clears.drainPendingStreamSends(both sides) serves strictly descending priority tiers. Within a tier the walk keeps arrival order, one chunk per entry per pass — equal-priority streams round-robin exactly as today. With no priorities set there is exactly one tier and the order is byte-identical to the current FIFO.priority_stream_idsset becomes an i32 map;markStreamPriority/unmarkStreamPrioritystay as shims (set 1 / clear). The pending-send byte-budget headroom keys onpriority > 0— same semantics as before; negative priorities order below default without claiming the gossip headroom.Semantics notes
priority DESC, recency ASC); a persistently-full high tier can starve lower tiers — that is the documented quinn behavior too, and the per-drive send budget bounds it.Tests
nextPriorityTierBelowdescending tier walk (5 → 0 → −2 → null).Local interop: handshake green;
transfer/multiplexingflake locally on clean master too (NS3-on-macOS environment) — the CI interop gate is authoritative here.