• Stefy Lanza (nextime / spora )'s avatar
    a cancelled page kept the pod slot it was granted (v0.4.23) · 1ccc44f8
    Stefy Lanza (nextime / spora ) authored
    `placement.choose` runs in a thread and raises `pod.inflight` the moment it
    picks a pod. If the awaiting coroutine was cancelled after the executor had
    produced the Lease but before the value was delivered, the object was dropped
    with the counter already raised -- and nothing released it, because the page
    was gone and no `finally` ran.
    
    A client that gives up on a batch cancels every page of it at once, so the leak
    arrives in thousands rather than one at a time.
    
    Measured on a live run, once `max_inflight_per_pod: 64` made it visible: the
    pool reported all 52 healthy pods at their cap -- 3,328 pages "in flight" --
    while `ss` inside the container showed 3 to 5 open sockets per pod, the cards
    sat at `GPU KV cache usage: 0.2%` with `Running: 1 reqs`, and nothing was
    preempted. Roughly 60 of every 64 pages did not exist. `_pick` then refused
    every pod, correctly, reporting "all 52 serving pod(s) are at their in-flight
    cap", and the run fell to 0.33 pages/s.
    
    It had been leaking since the pod pipeline was written. With
    `max_inflight_per_pod: 0` an inflated counter blocks nothing, so the only
    symptom was DEMAND -- the in-flight counts of 2,700 and 4,096 that earlier runs
    reported, and that the scaler dutifully rented pods to serve. The cap did not
    cause this; it converted a silent accounting error into a hard stop, which is
    how it was finally found. Three runs were spent on its consequences.
    
    `_acquire_lease` shields the acquisition, so it completes even when the page
    waiting on it is cancelled, and a done-callback hands the lease straight back.
    Orphans are counted and said once a minute, because the entire cost of this bug
    was that it was silent.
    
    Note on the analysis: the gap between `lease = await ...` and the `try` that
    releases it is NOT a window -- CancelledError is only delivered at an await
    point, and there is none in between. The acquisition itself was the only one.
    
    Proven rather than argued: the same test, same cancellation, against the
    unshielded form and the shielded one -- granted=1 released=0 LEAKED=1, against
    granted=1 released=1 LEAKED=0.
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01KnfkxBpcZ1v6ypRFFyhrVM
    1ccc44f8
Name
Last commit
Last update
codai Loading commit data...
docs Loading commit data...
packaging Loading commit data...
samples Loading commit data...
tests Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.dockerignore Loading commit data...
.gitignore Loading commit data...
AI.PROMPT Loading commit data...
CODERAI_API_DOCUMENTATION.md Loading commit data...
CoderAI.gif Loading commit data...
DISTRIBUTION.md Loading commit data...
LICENSE.md Loading commit data...
MULTIMODAL_CAPABILITIES.md Loading commit data...
MULTIMODAL_UI_EXAMPLES.md Loading commit data...
README.md Loading commit data...
REQUEST-geoclip-embeddings.md Loading commit data...
REQUEST-vpr-embeddings.md Loading commit data...
amdgpu-coredump-05000.bin Loading commit data...
build-oci.sh Loading commit data...
build.ps1 Loading commit data...
build.sh Loading commit data...
coderai Loading commit data...
coderai-broker-implementation-reference.md Loading commit data...
coderai-integration.md Loading commit data...
commands Loading commit data...
osxbuild.sh Loading commit data...
package-oci.sh Loading commit data...
package-tarball.sh Loading commit data...
requirements-crisperwhisper.txt Loading commit data...
requirements-h3.txt Loading commit data...
requirements-longcat-train.txt Loading commit data...
requirements-longcat.txt Loading commit data...
requirements-melotts.txt Loading commit data...
requirements-nemo.txt Loading commit data...
requirements-nvidia.txt Loading commit data...
requirements-ocr-paddle.txt Loading commit data...
requirements-ocr.txt Loading commit data...
requirements-pyannote.txt Loading commit data...
requirements-surya.txt Loading commit data...
requirements-vllm.txt Loading commit data...
requirements-vulkan.txt Loading commit data...
requirements.txt Loading commit data...
run-oci.sh Loading commit data...
smoke-test-oci.sh Loading commit data...
todo.md Loading commit data...