Orchestration
Load control and concurrency
How many tasks, gates and tests run at once, and how Lonca slows down when the machine is busy.
Running many tasks at once on a loaded machine delivers none of them sooner. Three numbers in config.yaml say how many tasks, pre-PR gates and tests run at once. With load control switched on, an experimental setting, those numbers become ceilings: Lonca watches the machine's CPU and memory and runs fewer while it is busy, and a task's priority can be raised so it gets the machine first. Load control exists to keep work flowing: where it can either wait or let work go, it lets work go, unless memory is critical.
Tasks at once
PlansFreeStandardProTeamFree: 1. Standard: 3. Pro and Team: your config’s ceiling, with load control.concurrency is how many tasks run a stage agent at the same time. A task holds its slot only while a stage agent works for it:
- It keeps the slot across plan, implement, test and review, so unfinished work finishes first.
- It gives the slot back when it reaches the gate, publishing, the PR or done; while it waits for your answer (a stage agent stopped at a prompt in its terminal keeps it); while it is paused or frozen; and while it waits for a busy port or browser profile.
- Setting up a worktree holds no slot.
- A task with no free slot waits in the queue. The first queued task takes the next free slot, in queue order: the order set for the queue (a Workspace Lead can reorder its workspace's tasks), else first come.
The plan's limit
Free runs one task at a time and Standard three, whatever the config says. A task over the limit waits its turn and says that the plan holds it (Free runs one task at a time), so you can tell the plan from load control. A config that allows more loads all the same, and Settings → Plan says how many run. See Plans.
Gates at once
gate_concurrency (default 1, at most 4) is how many pre-PR gates run at once across all tasks. Two full suites at once are what make specs fail at random, so the default is one. A waiting gate says its place in line on the task. See Tests, the gate and jobs.
Configuration
orchestration:
concurrency: 2 # 1–8; default 2, or 5 with load control on
gate_concurrency: 1 # 1–4
test_concurrency: 4 # 1–8; load control only
resource_wait_minutes: 30 # how long a step waits for a busy port before it asksconcurrency- Tasks running a stage agent at once. Left out, it is 2 with load control off and 5 with it on; a written value is used either way.
gate_concurrency- Pre-PR gates at once, across all tasks.
test_concurrency- Load control only: tests at once across tasks (stage agents’ tests, their jobs, gate commands).
resource_wait_minutes- A step waiting for a port or browser profile another task holds asks you once after this long (1–480).
The load control switch is a setting of the app, not of config.yaml; the Configurator never touches it. Its thresholds are fixed in Lonca, not configurable.
Load control
Settings → Orchestration → Load control switches it on. It is off by default, and experimental: off, Lonca behaves exactly as with the fixed numbers above. It takes effect at once.
On, Lonca reads the machine every two seconds:
- the load average: how much work is running or waiting for a core, over the last minute, per core. Full cores are not overload (one test run fills every core on purpose); work waiting for a core is;
- the CPU use, averaged over the last few readings, so one spike changes nothing. It is shown, and decides only where the load average cannot be read;
- macOS's own memory pressure (normal, warn or critical), which already accounts for swap.
From these it decides how many tasks and tests may run now, under the ceilings. It never kills work to get there: a lower capacity only means a freed slot is not handed out again.
How capacity moves
| When | Then |
|---|---|
| The CPU not overloaded, memory normal, the pool full and work waiting, for 30 seconds | That pool’s capacity goes up, by one or enough for every waiting piece of work, up to its ceiling. |
| The CPU overloaded (a load average over 1.5 per core), or memory at warn, for 10 seconds | Capacity goes down by one, in both pools, but not below two unless memory is at warn. |
| Memory critical | Capacity drops to one task and one test at once. |
| A piece of work starts | Nothing else starts in that pool for 15 seconds, so its spike can show. |
- A busy CPU only slows work down, so it takes capacity down to two tasks and two tests, no lower. Memory at warn may take it to one, and critical memory sets one at once. However loaded the machine, one task moves on.
- Where the load average cannot be read, the CPU use decides instead: overloaded above 90 %, room below 75 %.
- Gates and E2E jobs count double in the test pool.
Test slots
With load control on, tests across tasks share a pool of test_concurrency slots. Only a step whose work is running the repository's checks waits for one: the implementer, the UI implementer and the test runner. Another step's command runs at once.
- A stage agent's test command (one the repository's
tests.matchnames) waits for a slot before it starts. The wait does not count against its time limit or as idle time. - Every job a stage agent hands to Lonca, and every gate command, takes its slot too. One gate run holds one slot between its commands and its E2E run, so its two parts never wait for each other (since 12.3.1).
- A cancelled job gives its slot back at once, and a job's slot lapses a few minutes past its time limit, so a lost process never holds one for ever.
- A test waits 25 minutes at most; then it runs without a slot, and the task's log says so, with how long it waited.
- The task says who waits, how full the pool is and who holds the slots: Waiting for a test slot · the pre-PR gate · 2 of 2 in use · held by SHOP-415's implementer's test. Another task is named by its key; the task's own work reads as this task's, as in held by this task's pre-PR gate. The task's decisions record when the wait begins, with the same holders. When more slots are in use than the pool has, the line says why: a test heavier than the whole pool runs alone when nothing else holds a slot, or the pool shrank after the tests started.
Freezing and pausing
Under CPU pressure, load control can freeze a normal-priority task in place to make room for a high-priority one, and thaw it later (see Priority); under memory pressure, where freezing frees nothing, it pauses one.
What can be frozen
- a task's headless stage agents (planner, scenario writer, final check, reviewer);
- the app the pipeline started for it, beneath its terminal.
A terminal stage agent cannot be frozen in its tmux pane; a task whose work is its terminal stage agent gives its slot up at its next stage instead.
What is never frozen
- Lonca itself: orchestration, the leads, the tmux server;
- apps you started with Run App;
- a job Lonca runs for a task, and a running test. A freeze asked while the task's test holds a slot waits until the slot is free.
Memory
After 30 seconds of critical memory, one task is paused, as a pause you make would pause it: a frozen task first, since pausing it stops nothing that moves; then a normal-priority task before a high one, the one that started last first. The last task still moving is never paused. After 60 seconds of normal memory a paused task resumes by itself. One task at a time, with 30 seconds before the next decision.
Time a task spends frozen is taken off its time limits, so a frozen task never reads as stuck.
| The task says | Meaning |
|---|---|
| Frozen: machine busy | Its processes are stopped in place until load control thaws them. |
| Paused: low memory | Paused for memory; it resumes by itself. Its row stays under In progress with a grey hourglass in its stage ring: nothing waits on you. |
| Waiting for a test slot | A test of the task waits for the pool. |
| Yielding its slot at the next stage | A high-priority task takes its slot when its current stage ends; it then continues where it was. |
Priority
While load control is on, a handed-off task's priority is set from the up arrow on the Board and from its header's ⋯ menu: Raise priority (Give this task the machine first) and Lower priority. Before the hand-off, the hand-off card offers High priority. There are two levels, normal and high. The choice is kept with the task, also across a fresh hand-off.
A high priority shows as a filled up arrow: before the stage ring in the task's row, as Priority: High in the card on hover, and beside the status in its header. While load control is off the arrow stays, grey, the card adds no effect: load control is off, and ⋯ still offers Lower priority.
- A high-priority task goes ahead of normal ones in the queue.
- When it waits for a slot and none is free, the normal task that started its slot last yields it at its next stage boundary. If the high task has waited over a minute and the CPU is overloaded, that task is frozen without waiting for the boundary.
- A waiting high-priority test takes the next free test slot.
- A high-priority task is never frozen to make room, and is paused for memory only after the normal ones.
Never stuck
Whatever load control decides, these limits hold:
| Limit | What happens |
|---|---|
| A task frozen for 10 minutes | It is thawed, the task says load control never holds a task longer, and it is not frozen again for 10 minutes. |
| A task paused for memory for 20 minutes | It is resumed even while memory is critical, and not paused for memory again for 10 minutes. The core checks this too, on its own. |
| A frozen task and a free slot | A free slot thaws the frozen task first; a normal task never takes a slot ahead of it, except while memory is critical. |
| A move or a pause of a frozen task | It is thawed first. |
| A task waiting for a dependency, or Pause all on | It does not count as waiting for a slot. |
| Load control switched off | Everything frozen is thawed, and every task it paused is resumed. |
| Lonca starts, quits or crashes | Everything frozen is thawed at the next start or on quit. |
The readout
While load control is on, the card of the Orchestration chip in the title bar (hover the chip) shows one line, for example Load 0.8 · CPU 82% · Memory normal · Agents 3/4 · Tests 1/2: the load average per core, then what is in use against what load control allows now. Hover the line for the ceilings and the last decision's reason. Every decision about a task goes into its decision log with the reason.
Pause all in the title bar pauses every task, and thaws what load control froze; Resume all lets them go on. A task load control paused for memory stays paused while Pause all is on; after Resume all, load control resumes it as memory allows (at once, if load control is off by then).