tcmts.cli.budget

test/
13 definitions

Types

SlotHolder type
What holds a slot, or waits in line for one: its process, what it is (`tcm test of <dir>`), since when, and its own token (a process holding several slots tells them apart).
SlotPool type
Slots taken from a slotPool: `release` gives them back.
SlotWait type
What a take of slots waits on, as it looked: who holds the slots, how many are in line ahead of it, and how many it wants of how many.
SlotWaits type
What says a run's waits for slots (`take`, for each take from a slotPool), and how long it waited.

Server

alive (pid: number) => boolean
Whether process `pid` is running (one of another user's counts).
inSuiteSlot () => boolean
Whether this process runs inside a slot another holds for it (TCM_SUITE_SLOT, which `runSuite` sets for a suite, and withSlot's `env` for what it starts): what it runs takes no more of them, and runs one at a time.
machineSlots () => number
How many slots the machine has: how much work (a suite, a Vitest project of test definitions, checking, a build) every tcm on it runs at once, together. TCM_SLOTS (or TCM_SUITE_SLOTS, its name before), or defaultSlots for this machine.
slotPool (dir: string, size: number) => SlotPool
Slots shared by every process using `dir`: `size` files there (`slot-<i>`), each held by the process that made it (its pid in it), and a line of those waiting (`line-<time>-…`), served first come first served. A slot or a place in line whose process is gone is nobody's: taken over by the next to look. What a process holds is given back when it exits, too.
slotWaits (say: (line: string) => void, clock?: () => number) => SlotWaits
Says a run's waits for slots, quietly: once when it starts waiting (with what sets how many there are), again only when who holds them changes or how many are ahead of it changes much (a minute after the last at the soonest), or after five minutes of the same, and how long it waited once it has them. Its takes waiting at once (a worker each) are one wait. Other work is named by its kind and branch (`tcm test`s by branch alone), with its codebase if it's another and its pid if two have the same name; this one's own slots are "this run".
slotsDir () => string
Where the machine's slots are: TCM_SLOTS_DIR, or a directory of the user's in the temporary directory (`tcm-suite-slots-<uid>`, named when only suites took them), the same for every tcm they run.
withSlot <T>(what: string, work: (env: Record<string, string>) => Promise<T>, options?: { say?: ((line: stri…
Run `work` in a slot of the machine's: one taken for it (as `what`: `<kind> of <root> on <branch>`), waiting its turn with every other tcm's work, and given back when it ends. Work that's already in one runs at once, taking no more: inside a suite's slot (inSuiteSlot), or inside another `withSlot`'s work in this process (so nested work never waits behind itself). What the work starts as a process of its own runs in its slot too when started with `env` (TCM_SUITE_SLOT). A wait is said by `say` (stderr's, unless given), as slotWaits says it. `pool` is the machine's (slotPool in slotsDir, machineSlots of them) unless given.

Shared

SLOT_WAIT_LINE RegExp
A line slotWaits says (or a tcm from before it: `waiting for a suite slot: …`), as a run's output has it.
defaultSlots (cpus: number, performance: number, memory: number) => number
How many slots a machine with `cpus` logical cores, `performance` of them performance cores (on a chip with two kinds; else all are) and `memory` bytes has. What takes one (a suite: tcm, the TypeScript checker, Vite, a browser; checking; a build) keeps about a core busy as it goes, so a slot for each performance core and one for every three efficiency cores, and 2 GB of memory each; never fewer than 2.
waitTime (ms: number) => string
A wait's length, briefly: 0.4s, 12s, 2m10s, 1h5m.