Per-session outbound lane scheduler providing:
- O(1)
:queuebuffering per lane slot with incremental byte accounting - Configurable global (
max_parked_bytes) and per-lane (max_lane_bytes) memory caps with frame-safe:reset_lane | :drop_oldest | :close_sessionoverflow policies - Strict priority-ordered / shortest-remaining-first drain (
0control first, then{urgency, pending_bytes, slot}ascending) - 3-tier slot isolation (
:control,:small,:bulk) using payload-size EMA with sticky slot pinning and idle-safe reclamation so small interactive components never collide into heavy component streams
Summary
Functions
Returns true when at least one chunk is parked across any slot.
Returns non-empty slot ids ordered for draining: control slot 0 first,
then component slots ordered by {urgency, pending_bytes, slot} ascending.
Clears all queued data for slot and decrements parked_bytes.
Enqueues an encoded frame's binary chunks onto slot with urgency.
Returns how many whole frames slot still holds. An in-flight partial_head
frame is not counted, so 0 means every frame in this slot is fully sent.
Returns parked byte counts per slot.
Builds a new scheduler from session/listener options.
Pops the next binary chunk from slot in O(1), returning
{:ok, chunk, urgency, scheduler} or :empty.
Returns a previously popped head chunk back to the front of slot's queue
in O(1) when the underlying QUIC send queue is full or congested.
Returns the current pending bytes for slot.
Assigns {slot, tier, scheduler} for lane using 3-tier isolation and
size-EMA sticky pinning.
Returns true when slot currently has parked bytes.
Types
@type overflow_action() :: :close_session | {:reset_lane, non_neg_integer()} | :dropped_new | {:frame_too_large, non_neg_integer(), non_neg_integer()}
@type overflow_policy() :: :reset_lane | :drop_oldest | :close_session
@type t() :: %PhoenixWebTransport.LaneScheduler{ bulk_threshold_bytes: non_neg_integer(), idle_reclaim_ms: non_neg_integer(), max_lane_bytes: pos_integer(), max_lanes: pos_integer(), max_outbound_frame_bytes: pos_integer() | :infinity, max_parked_bytes: pos_integer(), overflow: overflow_policy(), parked_bytes: non_neg_integer(), pins: %{ optional(pos_integer()) => %{ slot: non_neg_integer(), ema: float(), last_active_ms: integer() } }, queues: %{ optional(non_neg_integer()) => %PhoenixWebTransport.LaneScheduler.SlotQueue{ bytes: term(), frames: term(), frames_count: term(), partial_head: term(), urgency: term() } }, soft_send_queue_bytes: non_neg_integer() }
@type tier() :: :control | :small | :bulk
Functions
Returns true when at least one chunk is parked across any slot.
@spec drain_order(t()) :: [non_neg_integer()]
Returns non-empty slot ids ordered for draining: control slot 0 first,
then component slots ordered by {urgency, pending_bytes, slot} ascending.
@spec drop_slot(t(), non_neg_integer()) :: t()
Clears all queued data for slot and decrements parked_bytes.
@spec enqueue( t(), non_neg_integer(), [binary()], PhoenixWebTransport.Lanes.urgency(), keyword() ) :: {:ok, t()} | {:overflow, overflow_action(), t()}
Enqueues an encoded frame's binary chunks onto slot with urgency.
Options:
:frame_bytes- logical frame size checked againstmax_outbound_frame_bytes(defaults to the sum ofchunks, so callers adding stream/frame headers can still enforce the payload limit consistently).
Returns {:ok, scheduler} or {:overflow, action, scheduler} where action
is :close_session, {:reset_lane, slot}, :dropped_new, or
{:frame_too_large, size, max} — the last one closes the session instead of
buffering a single oversized frame whole.
@spec frames_remaining(t(), non_neg_integer()) :: non_neg_integer()
Returns how many whole frames slot still holds. An in-flight partial_head
frame is not counted, so 0 means every frame in this slot is fully sent.
@spec lane_bytes(t()) :: %{optional(non_neg_integer()) => non_neg_integer()}
Returns parked byte counts per slot.
Builds a new scheduler from session/listener options.
@spec pop_chunk(t(), non_neg_integer()) :: {:ok, binary(), PhoenixWebTransport.Lanes.urgency(), t()} | :empty
Pops the next binary chunk from slot in O(1), returning
{:ok, chunk, urgency, scheduler} or :empty.
@spec requeue_head_chunk( t(), non_neg_integer(), binary(), PhoenixWebTransport.Lanes.urgency() ) :: t()
Returns a previously popped head chunk back to the front of slot's queue
in O(1) when the underlying QUIC send queue is full or congested.
@spec slot_bytes(t(), non_neg_integer()) :: non_neg_integer()
Returns the current pending bytes for slot.
@spec slot_for(t(), non_neg_integer(), non_neg_integer(), integer()) :: {non_neg_integer(), tier(), t()}
Assigns {slot, tier, scheduler} for lane using 3-tier isolation and
size-EMA sticky pinning.
@spec slot_parked?(t(), non_neg_integer()) :: boolean()
Returns true when slot currently has parked bytes.