Expand description
Host slots for heavy checks (ADR-0014, hooks.host-concurrency).
Several worktrees, sessions and agents on one machine each run their own
clippy, test suite and type checker, and each of those already uses every
core. A check that compiles or executes the product is therefore Heavy,
and takes a host slot before its first tool runs. The protocol (the slot
directory, the lock, the queue, admission, the holder record) is the
greengate-slots crate, the one implementation relais links too; this module
is the hook’s half: which checks are Heavy, the busy policy, deferral, and
the queue row.
The slot is taken LAZILY, at the first tool spawn of a heavy check, not when the check starts: a clippy with no Rust staged returns at once and must not wait behind somebody else’s suite to do nothing.
Structs§
- Check
Guard - Installed by the dispatcher around one check’s
run; clears this thread’s slot state, and releases a held slot, when dropped. - Park
Scope - Held by
dispatch::pre_pusharound its gate loop. While it lives, a slot a heavy gate held is handed to the next heavy gate instead of released; when the outermost one drops, on any exit, the parked slot is released.
Enums§
- Busy
Policy - What a Heavy check does when no slot frees in time (ADR-0013,
hooks.busy-policy). - Deferred
By - What a deferral of this run came from, for the roll-up: only an
onBusy deferslotWaitis stopped byset onBusy wait; a ceiling or a failed poll defers under either policy. - Reason
- Why a heavy check ran without a slot.
- Weight
- Whether a check is Heavy.
Constants§
- DIR_ENV
- A diagnostic, and the seam tests use: the slot directory.
- HEAVY
- The checks that compile or execute the product. Pinned by a registry test: every name here is a built-in.
- HELD_
ENV - Exported to the command a slot holder runs; an amont (or a wrapper) started under it does not queue again for the slot its parent holds.
- ON_
BUSY_ ENV - The environment override of
greengate.onBusy, for one run:GREENGATE_ON_BUSY=wait git pushruns a gate the file would defer.
Functions§
- before_
spawn - Called before a tool is spawned. For the first tool of a heavy check,
waits for a slot, showing the wait in the check’s row. Returns whether
this thread holds a slot, so the caller exports
HELD_ENV; anErrwhen the busy policy deferred the check, so the caller does not spawn. - behind
queued behind relais: cargo test (greengate-wt-x, 4m) · 2 waiting.- bound
- Bound
cmdto the width this thread’s heavy check was given (seeCurrent::jobs); a light check, or slots off, sets nothing. Called by every runner afterbefore_spawn. - busy_
policy - The busy policy in force:
GREENGATE_ON_BUSY(wait,deferornow), thengreengate.onBusy(git config, orset onBusyin a trustedamont.conf;waitordefer), thenwait. - current_
check - The name of the check running on this thread, without its stage
prefix (
clippy), when the dispatcher installed one. - deferred_
by - What this run’s deferrals came from.
- deferred_
here - Whether the check running on this thread was deferred by the busy policy: what it says after that is about its refused spawn.
- enter_
check - The dispatcher is about to run
name, ofweight, on this thread. The weight comes from the check (Check::weight), not the name: a declared check is Heavy by its line, which no name says. - host_
sizing - Both host sizing keys,
greengate.hostCoresandgreengate.hostSlots, resolved by the slots crate from the environment and thisSettings’ cached rows: one implementation, shared with relais, and no extra git spawn. Each warning is printed once. - never_
waits - The check running on this thread cannot block (its severity is
warn): on a busy host it takes a free slot or defers to CI at once, under either busy policy, instead of holding the commit, or the push and its open connection to the remote, while it queues for a verdict that stops nothing. Not called inside a rehearsal snapshot: there nothing is held open and land’s pre-stage needs the gate’s evidence, so the check follows the busy policy the rehearsal sets. - release_
parked - Release the slot parked between gates, if any. A gate that runs on the cluster executor takes no host slot (ADR-0016), so it calls this where it claims its Job: a slot parked for the next local gate would sit idle for the whole cluster run.
- sizing
greengate.hostSlots: unset sizes the slots from the machine (Sizing::Auto), N fixes them,0turns them off (None).- sizing_
and_ machine - The slot sizing and the machine it is computed for, from one resolution:
greengate.hostSlots(Nonewhen0turns slots off) andgreengate.hostCores, else the detected physical core count. - wait_
bounded_ for_ warn - The check running on this thread is a heavy
warncheck of land’s pre-stage, where somebody waits for its evidence: it waits for a slot at mostgreengate.warnSlotWait(and never longer thangreengate.timeout), under either busy policy, with no stall end, then defers (ADR-0022). - weight_
of