Skip to content

The stack #2-#7 onto main - #8

Merged
aledbf merged 8 commits into
mainfrom
json
Nov 22, 2026
Merged

aledbf merged 8 commits into
mainfrom
json

Conversation

@aledbf

@aledbf aledbf commented Nov 22, 2026

Copy link
Copy Markdown
Member

Why

#2 to #7 were stacked, and each merged into the branch below it instead of main (their base change to main did not apply). json now holds all of them, #7 included; this brings them to main as one merge, with their commits unchanged.

🤖 Generated with Claude Code

aledbf and others added 8 commits November 22, 2026 12:57
A service's process in a boot changes name and cgroup after bootchart
first sees it. systemd execs its executor through a file descriptor,
and the kernel names a task exec'd that way after the descriptor, so
journald, logind, udevd and every executor were charted as "9": the
name was read once from /proc/PID/sched and refreshed only every Hz/4
samples (250 ms at 200 Hz). The cgroup was read once too, before the
process moved from init.scope into its unit, and through cgroup-util,
which statfs'd /sys/fs/cgroup before systemd had mounted it and gave
up, so every label read "(null)".

Now the comm, the command line with -C and the cgroup are read again
on every sample in which the process ran, which is when an exec or a
move can have happened. The cgroup comes from /proc/PID/cgroup itself:
systemd's name=systemd hierarchy on v1 or hybrid, the 0:: line on v2.
A process is labelled with its unit, the cgroup path without the
slices above it, and a table lists CPU time by unit. /proc/PID/sched,
whose start time nothing drew, is no longer read, and cgroup-util goes.

--proc samples a directory laid out as /proc, which tests/identity
builds and changes under the sampler. The pids are sorted before the
tree is built, since the tree needs a parent before its children and
only /proc itself lists them in that order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/proc/PID/stat puts the comm in parentheses without quoting it, and
bootchart took the parent pid as the fourth word. A comm with a space,
such as "Web Content", moved it: the scan failed and the process was
never sampled, so it was missing from the chart. The parent pid is now
read after the last ')'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The filter dropped a process seen in one sample and one that used less
than 1 ms of CPU. In a boot of a few hundred milliseconds that is most
of systemd's work: generators, executors, (sd-close) and the like. On
spin-stack/machine's boot it dropped 62 processes.

A process is now dropped only when it used no CPU time while the chart
ran: for one already running at the first sample that saw processes,
none past that sample. A process seen in a single sample is drawn over
the interval before it, in which it started, with the CPU time it used
there; before, its bar had no width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
On one vCPU the question a boot chart has to answer is who waited to
run. The CPU wait graph sums the run queues' wait, and each process's
yellow showed its run delay only past 10% of an interval, with no
number anywhere.

Three graphs now draw /proc/pressure's cpu, io and memory: the share
of each interval in which some task (orange) or every task (red)
stalled, from the totals, which unlike the averages are exact over a
5 ms interval. A kernel without PSI draws none. Each process's label,
the CPU table and the unit table say how long it waited for a CPU.

The run delay was wrong for any process with threads: each thread's
run time was added to it in place of the thread's run delay. And the
CPU table's total left the threads out, since it was taken before
they were added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two boots are compared by numbers, and the SVG holds its numbers only
as rectangles. Beside each bootchart-DATE.svg the sampler now writes
bootchart-DATE.json: one row per sample of the system's counters as
the kernel keeps them, cumulative (schedstat run and wait summed over
the CPUs, vmstat's pgpgin and pgpgout, PSI's some and full totals),
and each process's pid, parent, name, cgroup, unit, first and last
sample, CPU and wait time, bytes read and written, and largest PSS.
Rows of numbers under named columns keep it small: 50 KB for 400
samples, against the SVG's 169 KB, sampling a container's /proc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sampler runs on the CPUs it charts, and on spin-stack/machine's one
vCPU its time is time the boot did not get: ~12 ms of CPU at 200 Hz.
The header now says what the samples cost, in total and per sample,
and the JSON carries it as sampler_cpu_ns. It is the sampler's own CPU
time up to the last sample, before drawing.

Every process's task directory was listed on every sample to add its
threads' times. procfs counts a process's threads in that directory's
link count, so a process with one thread is now skipped after a stat.
Sampling this laptop's ~600 processes, a sample's CPU went from 6.0 and
6.4 ms to 5.3 and 5.4 ms (two interleaved runs of three); a boot's
processes are mostly single-threaded, where the saving is larger.

As PID 1's child the sampler kept the name the kernel gave init, and
the chart listed it as "init" beside the systemd it forked from. It is
now "bootchart". The header's command line, a few hundred characters on
a VM, is cut to 150, and kept whole in a comment. It is read through
--proc, and a missing one leaves the line empty instead of failing the
chart. "recorded N total" counts the samples taken, not the most that
could have been. The tables of top consumers, which overlapped at
400 px apart once they carried wait and IO amounts, sit 560 px apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bootchart, svg: a quieter header that says what sampling cost
@aledbf
aledbf merged commit bfc825d into main Nov 22, 2026
2 checks passed
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