Skip to main content

Module host_slots

Module host_slots 

Source
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§

CheckGuard
Installed by the dispatcher around one check’s run; clears this thread’s slot state, and releases a held slot, when dropped.
ParkScope
Held by dispatch::pre_push around 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§

BusyPolicy
What a Heavy check does when no slot frees in time (ADR-0013, hooks.busy-policy).
DeferredBy
What a deferral of this run came from, for the roll-up: only an onBusy defer slotWait is stopped by set 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 push runs 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; an Err when 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 cmd to the width this thread’s heavy check was given (see Current::jobs); a light check, or slots off, sets nothing. Called by every runner after before_spawn.
busy_policy
The busy policy in force: GREENGATE_ON_BUSY (wait, defer or now), then greengate.onBusy (git config, or set onBusy in a trusted amont.conf; wait or defer), then wait.
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, of weight, 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.hostCores and greengate.hostSlots, resolved by the slots crate from the environment and this Settings’ 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, 0 turns them off (None).
sizing_and_machine
The slot sizing and the machine it is computed for, from one resolution: greengate.hostSlots (None when 0 turns slots off) and greengate.hostCores, else the detected physical core count.
wait_bounded_for_warn
The check running on this thread is a heavy warn check of land’s pre-stage, where somebody waits for its evidence: it waits for a slot at most greengate.warnSlotWait (and never longer than greengate.timeout), under either busy policy, with no stall end, then defers (ADR-0022).
weight_of