Repository navigation
fix(server): answer /v1/resources during a batch instead of after it - #549
Conversation
The static/scatter driver drains commands in a loop that runs until the batch goes idle, and its catch-all pushed everything that was not a new generation onto the deferred queue. `DriverCommand::ResourceSnapshot` landed there, so `/v1/resources` did not return until every in-flight generation had finished. That inverts the endpoint's purpose: it reports batch occupancy, and it was readable only when there was no batch left to report on. Under the demo's 512-token generations the request appears to hang for the entire run, which is also what the dashboard's occupancy gauge polls. Extracts `handle_or_defer_during_batch` so the rule is named and testable: read-only observability is answered inline, and commands needing `&mut Engine` stay deferred because `ContinuousBatchManager` holds the borrow. Tested via the helper rather than over HTTP deliberately. A racing integration test was written first and discarded: the fixtures generate in under a millisecond, so no request can be landed inside the batch window, and instrumenting the loop showed it never observed the probe at all. That test passed with the bug reintroduced. The unit test fails. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #549 +/- ##
==========================================
+ Coverage 80.59% 80.60% +0.01%
==========================================
Files 315 315
Lines 123446 123528 +82
Branches 123446 123528 +82
==========================================
+ Hits 99487 99567 +80
- Misses 19908 19910 +2
Partials 4051 4051
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
🔴 Benchmark Regression DetectedComparison of criterion micro-benchmarks: PR head vs merge-base, measured on the same runner in the same job (base first → PR second).
Visual flags: Host infoWhat this cannot catch
|
There was a problem hiding this comment.
Pull request overview
Fixes /v1/resources responsiveness during continuous/static batching by answering resource snapshots immediately (instead of deferring them behind the in-flight batch), and adds targeted unit coverage to prevent regressions.
Changes:
- Route
DriverCommand::ResourceSnapshotthrough a newhandle_or_defer_during_batchhelper so it is answered during an active batch. - Keep other commands deferred until the batch drains, preserving existing driver behavior for non-observability commands.
- Add unit tests that pin the “answer resource snapshots now, defer other commands” contract without relying on timing-sensitive HTTP integration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/onnx-genai-server/src/driver.rs | Adds handle_or_defer_during_batch and uses it to answer ResourceSnapshot immediately during batch execution. |
| crates/onnx-genai-server/src/tests.rs | Adds unit tests asserting snapshots are answered immediately and other commands remain deferred. |
|
Will fix this later in a focused run instead |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Extracted from #476 so it can be reviewed on its own. Depends on nothing else in that PR.
The bug
/v1/resourcesreports on in-flight work, but it was queued behind that same work — so the endpoint answered only once the batch it was reporting on had finished. A monitoring endpoint that blocks until the thing it monitors completes cannot observe the state anyone would want to query.Verification
cargo test -p onnx-genai-server --lib→ 126 passed, 1 failed.The one failure is pre-existing on
mainand unrelated:sidecar_free_compatibility_package_builds_server_pipeline_and_preprocesses_imagefails on a missing fixture (vlm-executable/vision.onnx). Confirmed by running the same test on cleanorigin/main, where it fails identically.Original commit:
a6fefde2.Split out of #476 (bug-fix extraction). Dashboard/demo work stays in that PR.