feat(monitoring): add fairness query param to pending-request-counts#1042
Open
pjb157 wants to merge 2 commits into
Open
feat(monitoring): add fairness query param to pending-request-counts#1042pjb157 wants to merge 2 commits into
pjb157 wants to merge 2 commits into
Conversation
Adds an opt-in '?fairness=true' query parameter that switches the endpoint to a per-user fair-share-capped depth signal. When set, each user's contribution to a (model, window) bucket is capped at the bucket's average pending count, so a single dominant user cannot inflate the reported depth beyond what a fair scheduler will drain. Default behaviour (flag absent) is unchanged. Depends on fusillade trait method get_effective_pending_request_counts_by_model_and_window (doublewordai/fusillade#251).
Describes the per-user fair-share cap formula, its properties, and the contract with claim_requests in fusillade — both call sites must move together when the policy changes.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in fairness mode to the monitoring endpoint that reports pending request depth, so downstream consumers can request a per-user-capped view of queue depth instead of the existing raw counts. In the dwctl codebase, this extends the backend monitoring surface and updates the accompanying SCOUTER documentation for operators.
Changes:
- Add a
fairnessquery parameter toGET /admin/api/v1/monitoring/pending-request-counts. - Route fair-mode requests to a new fusillade storage method and include a new handler test for dominant-user capping.
- Expand
docs/SCOUTER.mdwith the fairness policy and its intended contract with fusillade scheduling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
dwctl/src/api/handlers/queue.rs |
Adds query parsing, fair/non-fair branching in the monitoring handler, tracing, and a new integration-style test. |
docs/SCOUTER.md |
Documents the new fairness-aware mode, policy details, and maintenance guidance tied to fusillade behavior. |
Comment on lines
+24
to
+25
| - `GET /admin/api/v1/monitoring/pending-request-counts` — raw pending counts (default). | ||
| - `GET /admin/api/v1/monitoring/pending-request-counts?fairness=true` — counts with each user's contribution capped at the bucket's average. |
Comment on lines
+84
to
+87
| let counts = if q.fairness { | ||
| state | ||
| .request_manager | ||
| .get_effective_pending_request_counts_by_model_and_window(&windows, &states, &model_filter, &service_tier_filter, false) |
Comment on lines
+84
to
98
| let counts = if q.fairness { | ||
| state | ||
| .request_manager | ||
| .get_effective_pending_request_counts_by_model_and_window(&windows, &states, &model_filter, &service_tier_filter, false) | ||
| .await | ||
| } else { | ||
| state | ||
| .request_manager | ||
| .get_pending_request_counts_by_model_and_window(&windows, &states, &model_filter, &service_tier_filter, false) | ||
| .await | ||
| } | ||
| .map_err(|e| Error::Internal { | ||
| operation: format!("get pending request counts: {}", e), | ||
| })?; | ||
|
|
| - Caps a single dominant user's contribution at the bucket average so the | ||
| reported depth does not over-state demand a per-user fair scheduler will | ||
| throttle. | ||
| - Stateless wrt in-flight counts — pure function of pending rows. |
Comment on lines
+56
to
+57
| 1. Update the SQL in both `claim_requests` and | ||
| `get_effective_pending_request_counts_by_model_and_window`. |
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.
Summary
Adds an opt-in
?fairness=truequery parameter toGET /admin/api/v1/monitoring/pending-request-counts.When set, each user's contribution to a
(model, completion_window)bucket is capped at the bucket's average pending count, so a single dominant user cannot inflate the reported depth beyond what a per-user fair scheduler will actually drain. Default behaviour (flag absent) is unchanged.Policy
For each
(model, window)bucket:p_u= pending count for useru(only users withp_u > 0)U= number of such usersT=sum(p_u)fair_share=max(1, ceil(T / U))effective(u)=min(p_u, fair_share)effective_count=sum(effective(u))Reduces to
Twhen demand is balanced; caps a dominant user's contribution at the bucket average otherwise.Dependencies
Depends on the upstream fusillade trait method
get_effective_pending_request_counts_by_model_and_window:👉 doublewordai/fusillade#251
CI will fail until that PR ships and
dwctl/Cargo.tomlis bumped to the new fusillade release. The new dependency was verified locally against the fusillade branch via[patch.crates-io].Test plan
test_pending_request_counts_fairness_caps_dominant_userpasses locallyqueue::tests(4 tests including the new one) all passjust lint rustpasses (with local fusillade patch)