Expand description
The fork servers, agent side (see archive/PROJECT.md, How Python tasks are started: the fork
server): started with the worker, two per interpreter (one preloading the configured
libraries, a bare one), each restarted with backoff when it dies; a Python task or a parse
job asks the preloaded one to fork its runner, then the bare one, and is spawned when
neither can (a task with preload=False asks only the bare one, one with
fresh_process=True neither).
A forked runner is not the agent’s child: its shim (forked by the fork server) is its
parent and reports on a status socket the agent passes with the request,
process_started (the PID, once the process group exists) and process_exited. The shim
reaps the process only when the agent closes that socket (GroupHold), so its PID and
group can’t be reused while the agent may still signal them.
The thin operating-system layer under crate::launch, exercised by the integration tests
(tests/fork.rs); the backoff is unit-tested.
Structs§
- Fork
Backoff - How a fork server’s restarts are spaced.
- Fork
Config - An interpreter’s fork server settings (
[interpreters.<name>]withfork_server = true). - Fork
Metrics - Where the fork servers’ states and fallbacks are counted.
- Fork
Servers - An interpreter’s fork servers, preloaded first (cheap to clone; clones share them).
- Fork
Setup - How to start an interpreter’s fork servers.
- Forked
- A runner forked from a fork server, with the agent’s ends of its sockets.
- Forked
Process - A forked runner process: its group, its shim’s status socket, and its output.
- Group
Hold - A copy of the agent’s end of a forked process’s status socket: while any copy is open, the shim keeps the ended process unreaped, so its PID and group stay its own. Dropped once nothing may signal the group any more (after the memory watchdog stopped), on every path.
Enums§
- Cause
- Why a fork server came up disabled.
- Fallback
- Why a task wasn’t forked by one fork server (the metric’s
reason). - Kind
- Which of an interpreter’s two fork servers.
Constants§
- BACKOFF_
FIRST - The first wait before restarting a fork server that died or couldn’t start.
- BACKOFF_
MAX - The longest wait before a restart.
- BACKOFF_
RESET_ AFTER - How long a fork server must have been up for the backoff to start again from
BACKOFF_FIRST. - FORK_
ANSWER_ TIMEOUT - How long a fork server may take to answer a
forkrequest. - FORK_
SERVER_ DISABLED - The worker warning’s kind for a disabled fork server.
- PRELOAD_
TIMEOUT - How long a fork server may take to preload its libraries and answer.
Functions§
- retried
- Whether a fork server disabled for
cause, failing forfailing_forsince its first failure, is started again: a failing import withinwindow(long enough for what isn’t ready at a pod’s start; a failure still there after it is lasting: a missing package, a typo). - servers_
memory - The memory of the processes in
groupstogether (PSS);Nonewhen one’s can’t be read.