Repository navigation
Description
Two resource gaps in the decdn gateway pull path. Both apply to raw-blob requests on main and to manifest fills since #2866 keyed the manifest fill lock per hash and namespace. They came up in review of #2866 and sit outside that PR's scope.
Slow pulls can hold every worker slot
Every pull holds one of the MAX_PULLS = 16 worker slots for its whole upstream pull (crates/cli/src/commands/gateway/worker.rs, pull). A pull for a blob nobody holds keeps its slot through discovery. A pull whose bytes trickle in keeps it for as long as each gap stays under the silent-gap limit, with no overall bound. Sixteen such requests, raw blobs or distinct manifests, block every other request on the gateway. The manifest byte budget (MANIFEST_BUFFER_BYTES) bounds buffered bytes, not slots, so it does not limit this.
Candidate fixes:
- Cap the slots each request kind can hold (for example, manifest fills) below
MAX_PULLS. Refuse a request past its cap at once rather than queueing it behind another wait. - Put an absolute deadline or a minimum byte rate on a pull, so a trickling upstream cannot hold a slot without bound.
Test: with the slots of one kind fully occupied by held pulls, a request of another kind still answers.
Queued requests allocate buffers with no bound
PullWorker::pull sends jobs on an mpsc::unbounded_channel (worker.rs), and the gateway sets no limit on connections. Each request that reaches start_pull allocates a 256 KiB first-chunk buffer in first_chunk (crates/cli/src/commands/gateway.rs, CHUNK_BYTES) before its job has a worker slot. So 1,024 pending requests hold 256 MiB of first-chunk buffers alone, outside any budget.
Candidate fixes:
- Bound outstanding jobs, refusing a request at once when the queue is full.
- Or allocate the first-chunk buffer only once the job has its worker slot.
Test: with every worker slot held and the queue at its bound, a further distinct request is refused at once and allocates no buffer.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsIn progress
Activity