Skip to main content

Module queue

Module queue 

Source
Expand description

The device-wide upload queue, keyed per server (transfer upload doc, §Queueing Across Servers).

A client signed in to more than one server drives one lane per server. Each lane owns its own work and its own pacing: the jobs still to send, its two in-flight windows, its shared retry budget, and the time before which it must not be served (a backoff, or a server’s Retry-After).

  • W, the sessions window: how many of the lane’s sessions may be open at once. Several sessions in flight, each on its own HTTP/1.1 connection, are what keep a high-latency or lossy link busy, because one connection’s throughput is bounded by its round trip.
  • P, the ranges window: how many ranges each session may hold in flight. A session’s P is fixed when it is granted and can only be narrowed afterwards, by the cap the server advertised for that session (UploadQueue::set_session_ranges).

Both are client-local caps (LaneWindows, at most the compiled MAX_SESSIONS_WINDOW and MAX_RANGES_WINDOW) that the server’s X-Capsule-Advice can only lower (UploadQueue::set_advice), and W never exceeds the account’s live-session cap (UploadQueue::set_session_cap). They are not the protocol window, which says which protocol dates a server accepts and bounds nothing in flight.

What the lanes share is one bounded byte budget. A session admitted to run reserves nothing; every range it sends reserves its length while in flight (UploadQueue::reserve_range), so the device never buffers more than the budget however many servers and sessions it drives, and a large blob costs no more than the windows it is sending. Ranges waiting for the budget are served first-come, so a lane sending originals cannot keep re-reserving it ahead of another lane’s T0 range.

UploadQueue::next serves the lanes round-robin, so one server’s backlog cannot starve another’s, and inside a lane it always takes the lowest UploadTier first, so the staged ladder (T0 → T1 → T2) holds per server. A lane whose transfers report no progress for the stall bound gives its sessions and their range reservations back (UploadQueue::reclaim_stalled); its jobs return to the front of their tiers and the lane waits out one stall bound before it is served again, so a dead server’s lane cannot hold the budget every other lane needs. A job that failed and may run again spends one retry from its lane’s shared budget (UploadQueue::retry), so a server that fails everything costs a bounded number of retries however many jobs are queued for it. On resume each lane is rebuilt from its own server’s truth (UploadQueue::rebuild_lane); no lane’s state is derived from another’s. Deleting an asset withdraws its jobs from every lane at once (UploadQueue::withdraw), so no further byte of it is sent to any server.

This is a pure scheduler over values: it sends nothing and reads no clock. The caller passes now, runs each Grant it is handed, and reports back with UploadQueue::progress, UploadQueue::complete, UploadQueue::requeue or UploadQueue::retry. With one lane and a sessions window of one it hands out exactly one job at a time, in tier order - the single-server sequential push.

Structs§

Grant
A job the queue admitted: run it, then report on it by its GrantId.
GrantId
The handle of one job in flight, unique for the life of the queue.
LaneWindows
A lane’s own in-flight caps, before the server’s advice lowers them.
QueuedJob
One unit of upload work queued on a lane: a session to drive, at its tier. Queuing or running it reserves none of the byte budget; only the ranges it sends do.
RangeId
The handle of one range reservation, unique for the life of the queue.
ServerKey
The key a lane is held under: the server’s canonical origin (scheme://host[:port]), so one server reached through differently written endpoints shares one lane.
UploadQueue
The per-server upload queue with one shared byte budget. See the module docs.

Enums§

RangeRefused
Why UploadQueue::reserve_range reserved nothing.
RetryAdmission
What UploadQueue::retry decided for a job that failed.

Constants§

DEFAULT_RANGES_WINDOW
The ranges a session holds in flight when nothing narrower applies.
DEFAULT_SESSIONS_WINDOW
The sessions a lane holds open at once when nothing narrower applies. Four connections keep a 600 ms, lossy path busy without opening more sessions than a small server’s live-session cap admits.
MAX_RANGES_WINDOW
The widest ranges window (P) any session holds: the protocol’s ceiling on a session’s in-flight cap.
MAX_SESSIONS_WINDOW
The widest sessions window (W) any lane holds: the most advice can ever grant.