Skip to content

store, svg: what each process read from and wrote to disk - #4

Merged
aledbf merged 1 commit into
keep-short-livedfrom
per-process-io
Nov 22, 2026
Merged

aledbf merged 1 commit into
keep-short-livedfrom
per-process-io

Conversation

@aledbf

@aledbf aledbf commented Nov 22, 2026

Copy link
Copy Markdown
Member

Why

spin-stack/machine draws its boot with this fork to see how systemd starts inside a ~300-400 ms VM boot on one vCPU, and to catch regressions release to release. Its chart shows a 230 MB/s read burst from 0.1 to 0.14 s and a write burst from 0.1 to 0.22 s, while the vCPU is nearly idle. Nothing in the chart says whose reads and writes they were, so the lead "the disk holds systemd's first ~40 ms" (spin-stack/machine#521) could not be followed to a process or a unit.

What

  • Each sample reads read_bytes and write_bytes from /proc/PID/io for every process that ran since the last sample. A process submits a read or dirties a page only while it runs, so a sample in which it did not run keeps the last values and costs no read. A kernel without CONFIG_TASK_IO_ACCOUNTING has no /proc/PID/io, and the values stay zero.
  • Each process's label adds what it read and wrote, for example 3.0ms, 12.0MB read, 2.5MB written.
  • An orange strip under a process's bar marks the intervals in which it read or wrote.
  • A "Top disk I/O" table lists the processes that read and wrote the most.
  • The unit table (-c) sums both by unit.

read_bytes counts what the block layer read for the process, so page-cache hits do not count. write_bytes counts the bytes it dirtied, which writeback writes later and possibly from a kworker.

Checked

tests/io runs over a fixture /proc where journald reads 12 MB and writes 2.5 MB while it runs. Its counters then jump to 99 MB without any CPU time, which a real process cannot do. The test asserts the label, both tables and the strip. It also asserts that the chart keeps 12 MB, which shows io is read only on samples in which the process ran. make check passes under ASan/UBSan with gcc in an Ubuntu 24.04 container. CI covers clang.

Stacked on #3.

🤖 Generated with Claude Code

The IO graphs show a boot's bursts, 230 MB/s of reads from 0.1 to
0.14 s on spin-stack/machine's, and nothing said whose they were.

read_bytes and write_bytes come from /proc/PID/io on every sample in
which the process ran: a process submits a read or dirties a page only
while it runs, so a sample in which it did not keeps the last values,
and costs no read. Each process's label says what it read and wrote,
an orange strip under its bar marks the intervals in which it did, a
"Top disk I/O" table lists who did the most, and the unit table sums
both by unit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aledbf
aledbf merged commit ba5d385 into keep-short-lived Nov 22, 2026
2 checks passed
@aledbf aledbf mentioned this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant