You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[scheduler] Gate cluster feed on an awake-set scan (#2465)
The cluster feed round-robined the full cluster universe, whose size
scales with host/tag count rather than workload: a single show could fan
out to ~180 clusters (mostly hostname/manual) of which ~90% were idle,
so most passes ended in no_jobs and the round-trip p50 degraded as the
lap grew.
Add a periodic awake-gate scan that recomputes which (facility, show,
tag) tuples have plausibly-dispatchable work (JobDao::scan_active_tags),
and have the producer round-robin only that awake subset. Clusters with
no work stay out of the rotation until a later scan re-activates them;
the producer is woken immediately on an empty -> non-empty transition
via active_notify rather than waiting out the idle poll.
The scan query is a provable superset of the per-cluster dispatch query:
it keeps only a strict subset of that query's conjuncts
(PENDING/not-paused/ facility, a waiting layer carrying the tag, show
active+scheduler-managed) and drops the folder/job caps, so it can never
produce a false negative. Its subscription gate is the cheap static
`int_burst > 0` only -- the dynamic live-headroom check is deliberately
omitted to avoid an O(farm) full-`proc` aggregation every interval and
the over-count/false-exclude foot-gun that a global proc-sum would
carry. Burst enforcement stays in the per-cluster path, where an
over-burst-but-busy show backs off on cluster_saturated_sleep.
The existing per-pass sleep_map backoff is unchanged and still handles
the superset residual (clusters that are awake but turn out
capped/saturated on a real pass); the awake gate sits on top of it.
Adds config knob `active_scan_interval` (default 2s, the idle->dispatch
latency lever) and metrics scheduler_clusters_active,
scheduler_active_tags, and scheduler_active_scan_duration_seconds.
Covered by a new stress-test that asserts the scan is a superset of the
per-cluster query against live PG.
The remaining diff is rustfmt normalization.
## LLM Usage Disclosure
Some of the work of this PR was done using Claude Code Opus.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Scheduler now periodically focuses on clusters with dispatchable work,
reducing unnecessary re-checks and improving dispatch responsiveness.
* Added new monitoring for the active cluster subset and scan timing.
* Configuration now includes a new interval to control how often active
clusters are re-scanned.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
0 commit comments