How an engine stays healthy#
Jobs differ wildly: one copies three files, the next lists two million. A job engine has to run them side by side without one starving the others. This page describes how it does that: how it counts room, how it watches memory, and what it does when memory gets short. All of it works by itself; the page is for understanding what the Engines section shows.
Room#
An engine does not take runs until it falls over. Every run is counted as a size, and the sizes of all runs in a runner must fit into the runner's room.
| Size | Counted as |
|---|---|
| Small | 32 MB |
| Medium | 256 MB |
| Large | 1 GB |
| a runner of its own | the memory given to that runner |
The size is a planning number, not a measurement. The room of the shared runner is half its memory: a quarter of the rest is for item lists and a quarter is kept free. The shared runner also takes no more than job_engine_max_runs runs at once, 200 unless you change it. A runner of its own is started only when its memory still fits under what the engine may use in all.
A job's size is Size in its Setup. Automatic counts a job as small, until it earns something else.
A run for which there is no room waits. It is listed under Waiting for an engine with the reason "no room on the engine", and starts when room is free.
What a job earns#
The engine remembers how each job behaved:
| A job that | Is |
|---|---|
| was in a runner that died, and is the likely cause | given a runner of its own from then on, so that it can only hurt itself |
| handled more than 250,000 items in one run | given a runner of its own |
| was moved out of the shared runner because memory was short | the same |
| had ten runs in a row in its own runner that each stayed under a quarter of the shared runner's room | taken back into the shared runner, with the size that fits what it used |
A job's Setup shows what it earned, for example "Runs in its own runner since 12 Nov: it was moved out of the shared runner for memory", with a way to reset it. Runner: The shared runner in the Setup overrides the engine's judgement; A runner of its own makes it permanent.
Watching memory#
Each runner reports two numbers all the time:
- Memory held: how much of its memory is in use after tidying up. This is what really cannot be given back.
- GC: the share of its time the runner spends tidying memory. A runner that tidies a third of the time is not getting work done.
From them comes a level:
| Level | When | Shown as |
|---|---|---|
| Green | all is well | |
| Yellow | more than 70 % held, or more than 15 % of the time in GC | a yellow mark on the runner's bar |
| Red | more than 85 % held, or more than 30 % in GC | a red mark |
Above 92 % held, the engine acts at once without waiting for the next reading.
What the engine does#
At Yellow it takes pressure off gently:
- The runner gets no new runs. They go to another runner or wait.
- Runs in it are told to keep less in memory: item lists move to disk sooner.
- The runs are ranked by what they hold, to know which one to move if it gets worse.
At Red it makes room:
- The heaviest run is moved to a runner of its own. It is stopped after the task it is in, started in a fresh runner, and goes on from where it was. Its job is noted as one that earns its own runner.
- If that is not enough or not possible, the shared runner is recycled: a fresh one takes the new runs, and the old one ends when its runs have finished or moved.
A run moves only between tasks, or at a saved place inside a long list, and only when the job has Save state on. A run that cannot move stays, and the engine works around it.
When a runner dies#
A runner that runs out of memory, or crashes, takes its runs with it. The engine then:
- starts a fresh runner,
- resumes the runs that have Save state on, each from its last finished task; the others end as failed,
- looks for the suspect: the run that held most or grew fastest,
- gives the suspect's job a runner of its own for the future.
A run is resumed at most twice. When it is lost a third time it ends as failed, with the list of reasons, so that it does not go round for ever.
If the shared runner dies three times within ten minutes, the engine concludes that it is not finding the cause. For the next half hour every run it resumes gets a runner of its own, as many at a time as the memory allows: the run that then dies alone is the cause.
Runner deaths on the Engines page counts these, and What happened names the suspect.
The shared runner is also replaced as a matter of routine, after 5,000 runs or 24 hours, whichever comes first. Nothing is interrupted for it: a fresh runner takes the new runs and the old one ends when it is empty.
Reading the Engines section#
| You see | It means | Do |
|---|---|---|
| Green everywhere | nothing | |
| Yellow now and then, back to Green | the engine is using its memory | nothing |
| Yellow most of the time | the engine is small for its work | raise Runner memory, or lower Limits |
| Red, and runs being moved | one job is much heavier than the rest | look at What happened for which, and at that job: Jobs with a million items |
| the same job as suspect again and again | that job needs more than it gets | give it A runner of its own with enough Memory for its own runner |
| many runs waiting for "no room" | too much at the same time | spread the schedules: the Dashboard's heat map shows the busy hours. Or add an engine. |
What to set, if anything#
Most servers never touch these. If you do:
- Runner memory of the shared runner: enough for the usual jobs together. More is not better without limit: very large runners tidy memory in longer pauses.
- A runner of its own for the one or two heavy jobs, with their own memory. This helps more than a bigger shared runner.
- Max runtime on every job: a run that hangs holds its room until it is stopped.
The machine needs the memory for all of it: the server, the shared runner, and each own runner while its job runs.