brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: /proc/pressure shows how long tasks wait for CPU, memory or disk

Linux
~/tips/tip-performance-proc-pressure-psi

cat /proc/pressure/cpu

Shows the share of time tasks stall on CPU, memory or disk, over 10, 60 and 300 seconds.

Load average and a busy CPU graph never tell me whether a slow server is actually waiting on something. The Linux kernel has a better number for that, and it sits in three plain files you can read with cat.

These files are called pressure stall information:

cat /proc/pressure/cpu
cat /proc/pressure/memory
cat /proc/pressure/io

Each prints lines like this:

some avg10=0.00 avg60=0.00 avg300=0.00 total=0
full avg10=0.00 avg60=0.00 avg300=0.00 total=0

The some line is the share of time in which at least some tasks were stalled on that resource. The full line is the share of time in which all non-idle tasks were stalled at once, which the kernel docs describe as thrashing: CPU cycles go to waste. The averages are percentages over the last 10, 60 and 300 seconds, and total is the absolute stall time in microseconds, which helps to spot short spikes that barely move an average.

I would look at io when a container host feels sluggish while the CPU is mostly idle, and at memory when swap starts to get used. If some avg60 is a few percent, that is a hint; if full climbs, tasks really are stuck.

The caveat is the CPU file. At the system level, full for CPU is undefined, and since kernel 5.13 the file reports it as zero for backward compatibility, so only read the some line there. These three files cover the whole machine. On a system with cgroup2, every cgroup also has cpu.pressure, memory.pressure and io.pressure files in the same format, which is where I would look to find out which service or container is the one that is stalling.

Further reading: PSI – Pressure Stall Information (Linux kernel docs)

Going deeper: Keep a domain pointed at your home with Cloudflare DDNS on Unraid

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link