Every job starts as a record in the store and a supervisor process of its own. The supervisor asks the scheduler where the job should run, waits for that place to have room, then runs the job there. The scheduler is a pure function, schedule(state, policy), in the fleetjobs/schedule entry. It reads the queue, this machine's state and each host's state, and returns one decision for each queued job: start in a place, or wait.
Lanes and slots
Section titled "Lanes and slots"A job waits in one of two lanes. The heavy lane is the default. The light lane, chosen with --light, is for quick commands such as lint or one test file.
| Lane | Slots on this machine | Memory free before a job starts | Time limit |
|---|---|---|---|
| heavy | 2, a third while the machine is idle | 4 GB | 1200 s |
| light | 1, a second while CPU pressure is low | 2 GB | 300 s |
The machine counts as idle for the third heavy slot while tasks wait for a CPU under 10% of the time, wait for disk under 25% of the time, and 8 GB are free. The second light slot opens while CPU pressure is under 20% and 4 GB are free. fleetjobs reads pressure stall information from /proc/pressure, because the load average counts processes that wait on disk. Without it, the extra slots stay closed.
The slot counts come from the local block of the config file. A job over its time limit gets TERM, then KILL 30 seconds later. Raise the limit with HEAVY_MAX.
Light jobs are placed before heavy ones. Within a lane the scheduler ranks each job by a score, and the lowest goes first. The score is the checkout's usage, plus the seconds its jobs hold a heavy slot now, minus the seconds this job has waited. A checkout is the nearest folder up that holds .git, and its usage is the slot seconds its heavy jobs used here lately, halved every 30 minutes. So a session that used little goes first, and waiting lowers the score. A short job, whose last runs took 30 seconds or less, starts 10 minutes ahead. A job that goes back to run here after a remote result, class confirm, goes before everything.
Which jobs may leave
Section titled "Which jobs may leave"A job may run on a host only when all of these hold:
- It is in the heavy lane.
HEAVY_LOCALis not1.- The config lists at least one host.
- Its command is a build, test, typecheck or lint, such as
pnpm test,vitest,tscorpnpm build.HEAVY_REMOTE=1lifts this for any command. A command with a word that installs, deploys, serves or drives a browser, such asinstall,dev,dockerorwrangler, stays here unlessHEAVY_REMOTE=1is set. - It runs inside a git checkout whose
originis not matched by aneverpattern in the config. - No argument names a path outside the checkout or under
/tmp. - No
.env,.env.*,.dev.varsor.pemfile is within four levels of the checkout's root, other than.example,.sampleand.templatefiles, and.npmrcholds no_authline. - The checkout has a
pnpm-lock.yamlorpackage-lock.jsonto install from. WithHEAVY_REMOTE=1, a checkout with neither is also allowed.
A job that fails any of these runs here, and heavy says why on stderr.
Where it runs
Section titled "Where it runs"The default policy lets each job, in score order, take the place where it finishes first. For a slot here, that is when the slot frees plus the job's estimate, taken from its last runs. For a slot on a host, it is when the slot frees, plus the time to copy the checkout, plus the estimate divided by the host's speed. When that place is busy, the job waits for it and holds it, so a later job cannot take it first, and a later job may still start at once somewhere else. A host that is down, short of memory or disk, or busy with other work takes no jobs.
Hosts are probed over ssh at most every 15 seconds, and every 2 minutes while one is down. A host that refuses a job rests for a minute, and the job goes back to the queue here.
The bash policy follows the rules the old bash heavy logged, and exists so heavy replay can compare the two. See replay.
Dev servers and watchers
Section titled "Dev servers and watchers"A command with dev, serve, preview, start or watch in it holds memory, not CPU, and would keep a slot for its whole life. It runs at once, outside the queue, under the same time limit.
When memory runs out
Section titled "When memory runs out"Each job runs in its own systemd scope under the slice HEAVY_SLICE, so the kernel's out-of-memory killer picks the job and not your session. A job that the kernel kills exits with 137. fleetjobs waits up to HEAVY_OOM_WAIT seconds for the job's peak memory plus 2 GB to be free, then retries it once. A second kill queues the job for the night queue.