Skip to content

feat: add weighted fair queuing scheduler#245

Draft
alecthomas wants to merge 1 commit intomainfrom
aat/weighted-fair-scheduler
Draft

feat: add weighted fair queuing scheduler#245
alecthomas wants to merge 1 commit intomainfrom
aat/weighted-fair-scheduler

Conversation

@alecthomas
Copy link
Copy Markdown
Collaborator

@alecthomas alecthomas commented Apr 2, 2026

Summary

Adds a weighted fair queuing scheduler with conflict exclusion. All work (foreground and background) flows through a single scheduler that controls admission via four layered constraints:

  • Total concurrency: hard global cap on all running jobs (Config.TotalConcurrency)
  • Priority tiers: each tier gets a weighted share of total concurrency (Priority.Weight / sum(weights) * total). Higher-level tiers dispatch first, preventing background from starving foreground
  • Per-type limits: each job type uses at most a fraction of its tier's slots (JobTypeConfig.MaxConcurrency, 0-1)
  • Conflict groups: jobs sharing a conflict group and job ID are mutually exclusive

Within a tier, jobs are ordered by accumulated cost per fairness key (lowest first, then arrival time). Cost is estimated via an exponential moving average of observed wall time.

Includes design doc (README.md), flow diagram (scheduler.svg), unit tests, and a soak test.

@alecthomas alecthomas force-pushed the aat/weighted-fair-scheduler branch 4 times, most recently from a0f5e26 to 7109576 Compare April 3, 2026 07:26
Introduces a scheduler with four layered admission constraints:

- Total concurrency: hard global cap on running jobs
- Priority tiers: weighted share of total concurrency per tier
  (Priority struct with Level + Weight)
- Per-type limits: fraction of tier slots per job type
- Conflict groups: mutual exclusion by group + job ID

Within a tier, jobs are ordered by accumulated cost per fairness
key (lowest first), with cost estimated via EMA of wall time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alecthomas alecthomas force-pushed the aat/weighted-fair-scheduler branch from 7109576 to 98127fc Compare April 3, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant