Skip to content

json: the chart's numbers beside the SVG - #6

Merged
aledbf merged 1 commit into
psifrom
json
Nov 22, 2026
Merged

aledbf merged 1 commit into
psifrom
json

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. Catching a regression means comparing two boots by numbers. The SVG holds its numbers only as rectangles and labels.

What

Beside each bootchart-DATE.svg the sampler writes bootchart-DATE.json:

  • sample_columns and samples hold one row per sample, oldest first. Each row has the sample's time on the chart's clock, /proc/schedstat run and wait time summed over the CPUs (ns), /proc/vmstat pgpgin/pgpgout (KiB), and PSI some/full totals for cpu, io and memory (us). The counters are cumulative, as the kernel keeps them, so a reader takes the differences over the intervals it chooses.
  • processes holds one object per process: pid, ppid, name, cgroup, unit, first_seen, last_seen, cpu_ns, wait_ns, read_bytes, write_bytes, pss_max_kb.
  • Header fields: version, hz, interval, overrun, relative, cpus.

The layout is documented at the top of src/json.c, and the man page points there. Rows of numbers under named columns keep the file small. 400 samples of a container's /proc came to 50 KB, against the SVG's 169 KB (measured locally).

Also in this stack, in #2: /proc/PID/stat's parent pid is read after the last ). A comm with a space ("Web Content") made the process unsampled and missing from the chart. The fixture for this PR hit that bug.

Checked

tests/json runs over a fixture /proc and reads the file back with Python's json. It checks the columns and row lengths, the sample order, the counters against the fixture's, and pid 62's name, cgroup, unit, CPU, wait and read_bytes. Pid 62's name is say "hi"\ to exercise escaping. make check passes under ASan/UBSan with gcc in an Ubuntu 24.04 container. CI covers clang.

Stacked on #5.

🤖 Generated with Claude Code

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>
@aledbf
aledbf merged commit 0c1886f into psi 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