Memory pressure (#202): Linux's pressure stall information (PSI) for memory, read each tick, and the admission rule built on it.
some avg10=1.53 avg60=0.87 avg300=0.24 total=1234567
full avg10=0.00 avg60=0.12 avg300=0.03 total=34567
some is the share of the last 10, 60 and 300 seconds in which at least
one task was stalled waiting for memory (reclaim, swap-in, refaults);
full the share in which every runnable task was. Meta's TMO acts on the
same signal before memory runs out (Weiner et al., ASPLOS 2022).
Which file (find_source, once per process):
ORCA_MEMORY_PRESSURE_FILE, if set: that file, whatever it is (tests
point it at a fixture);
- on Linux, the cgroup v2
memory.pressure of the nearest cgroup, from
this process's own up, whose memory.max is a limit: in a Docker
container run with --memory that's the container's own
(/sys/fs/cgroup/memory.pressure), which stalls when the container
reaches its limit even with the host at ease;
- the host's
/proc/pressure/memory. Inside a container it is the host's
(PSI isn't namespaced), which is what a container without a limit
shares;
- the own cgroup's
memory.pressure though it has no limit, for a kernel
with cgroup PSI but no readable /proc/pressure;
- none: macOS, or a kernel built or booted without PSI (
psi=0). Then
nothing is held, and the scheduler says so once.
Admission (Admission): while some avg10, less what runs held at
their own memory limits explain (the most of their cgroups' some avg10),
is over the limit
(ORCA_ADMIT_MEMORY_PRESSURE, percent, default 10; 0 turns it off), no new
run starts on this host; runs already going go on. The hold ends once
avg10 is under half the limit, or has stayed at most the limit for
RESUME_SECONDS, so a reading that hovers at the limit doesn't flap. A
hold that has lasted ORCA_ADMIT_PRESSURE_GRACE_SECONDS (600) with none of
orca's runs going on this host lets one run start at a time (escape): the
pressure isn't orca's, and orca shouldn't wait for it forever. The caller
logs and alerts once when that happens (stuck).
This module reads files and decides; it keeps nothing in a database, so a
step (memory_pressure, from ORCA_MEMORY_PRESSURE_FILE, which every run
on the local runner, the control host and a worker is given) and the
per-run cgroups of #201 can use it alone.
Aliases
comptime PRESSURE_FILE = "ORCA_MEMORY_PRESSURE_FILE"
The file a run polls for its host's memory pressure, and the scheduler's override of which file it reads.
comptime ADMIT_LIMIT = "ORCA_ADMIT_MEMORY_PRESSURE"
The some avg10 percent over which no new run starts; 0 turns it off.
comptime DEFAULT_LIMIT = SIMD(10)
comptime GRACE = "ORCA_ADMIT_PRESSURE_GRACE_SECONDS"
comptime DEFAULT_GRACE = SIMD(600)
comptime RESUME_SECONDS = SIMD(30)
How long avg10 stays at most the limit before a hold ends anyway.
comptime WAITING_PRESSURE = "waiting: memory pressure "
How a run held by memory pressure's reason starts.
comptime HOST_PSI = "/proc/pressure/memory"
comptime CGROUP_ROOT = "/sys/fs/cgroup"