Repository navigation
fix(cli): bound gateway pull slots per kind and the pull queue - #3030
Open
alpergundogdu wants to merge 1 commit into
Open
alpergundogdu wants to merge 1 commit into
alpergundogdu wants to merge 1 commit into
Conversation
Manifest fills take at most a quarter of the gateway's 16 worker slots (4, the fills the manifest buffer budget holds at full size), counted while running or waiting, so raw-blob requests always find the other slots. The worker admits at most 64 pulls beyond those running. A pull past either bound, or a fill past the manifest buffer budget, is refused at once with 429 and Retry-After: 2, and starts no pull. A pull now allocates its 256 KiB first-chunk buffer only once the worker reports that it holds its slot, so a queued request holds no read buffer. A pull keeps no overall deadline and no byte-rate floor: large model downloads from slow holders are legitimate pulls. Closes #2894 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 2 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
This branch has not been deployed
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 #2894.
What changes
MAX_MANIFEST_PULLS = MAX_PULLS / 4(4) at once, running or waiting. That is the count of full manifest buffersMANIFEST_BUFFER_BYTESholds (now defined asMAX_MANIFEST_PULLS * MAX_MANIFEST_BYTES, same 4 as before), so raw-blob and entry requests always find the other 12 slots. A manifest request past the cap is refused at once, never queued.PullWorker::pulltakes an admission permit (MAX_PULLS + MAX_QUEUED_PULLS, withMAX_QUEUED_PULLS = 64) before it sends the job, and refuses at once (Refused::Busy) when none is free. The transport channel staysunbounded_channel: the worker drains it at once into tasks that wait on the slot semaphore, so a bound on channel depth would bound nothing. The bound sits on admitted-and-unfinished pulls instead, which is the real queue.Jobcarries aslottedoneshot the worker fires once the pull holds its slot.start_pullawaits it beforefirst_chunkallocates its 256 KiB buffer, so a queued request holds no read buffer.MAX_PULLSdoc says so.adr/appendix-gateway.md§ Pull slots, the answers table and the refused-counter row describe the bounds and the 429.Refusal status and the SDKs
A refusal answers 429 with
Retry-After: 2and a text body (the gateway is busy; retry the request). It counts underdecdn_gateway_requests_refused_total(refused before any pull), so it does not pollute the 503 funding counter.429 is not new to the gateway contract (pointer-lookup budget already answers it), and both SDKs already map it:
@decdn/client(src/http.ts:429: "RATE_LIMITED",Retry-Afterparsed intoretryAfterSecs) and thedecdnPython package (_http.py: same). No SDK PR is needed and neither SDK pin moves.Tests
worker::tests::manifest_pulls_past_their_cap_are_refused: a held manifest pull at the cap; a second manifest pull is refused at once; a blob pull still streams; the cap frees when the held pull ends.worker::tests::a_pull_past_the_queue_is_refused_at_once: slot held, queue full, the next pull is refused at once; the queued pull'sslottednotice does not fire until it holds the slot.tests::a_raw_blob_answers_while_manifest_pulls_hold_their_cap: through the HTTP handler, a held bundle index at the manifest cap, another bundle answers 429, a raw blob answers 200.tests::a_request_past_the_queue_is_refused_at_once: every slot held and the queue at its bound, a third distinct blob answers 429 at once and lists no pull.tests::a_spent_buffer_budget_fails_a_fill_fastnow expects the busy 429.cargo nextest run -p decdn-cli(1255 passed),cargo clippy --workspace --all-targets --all-featuresclean,cargo docwith warnings denied clean.Follow-up worth a look
With the manifest cap at 4 and the buffer budget at 4 full buffers, the budget only bites in the window where a fill's pull has ended (permit dropped) while it still parses its buffer. It still guards that window, so it stays.
🤖 Generated with Claude Code