Repository navigation
bootchart, svg: a quieter header that says what sampling cost - #7
Merged
Merged
Conversation
aledbf
force-pushed
the
header-overhead
branch
from
November 22, 2026 16:17
7a72653 to
a1347c3
Compare
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>
aledbf
force-pushed
the
header-overhead
branch
from
November 22, 2026 16:17
a1347c3 to
78dc08c
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. On one vCPU the sampler's own CPU time is time the boot did not get. Ubuntu's 235 took ~12 ms at 200 Hz, and the chart never said so. The header was also mostly a command line several hundred characters wide.
What
Sampler: X ms of CPU for N samples, Y us a sample, and the JSON carriessampler_cpu_ns. It is the sampler's CPU time (getrusage) up to the last sample, before drawing.task/directory to add its threads' times. procfs counts a process's threads in that directory's link count (2 + threads), so a single-threaded process is now skipped after onefstatatinstead of about six syscalls. Sampling this laptop's ~600 processes, one sample's CPU went from 6.0 and 6.4 ms to 5.3 and 5.4 ms. That is two interleaved runs of three each, a lead and not a VM number. A boot's processes are mostly single-threaded, so the saving there should be larger. The spin-stack/machine lab run measures it.bootchart(PR_SET_NAME). spin-stack/machine finds the sampler by its executable, so that lookup does not change.--encoded. It is read through--proc, and a missing one leaves the line empty instead of failing the chart. "recorded N total" now counts the samples taken. It used to print the configured maximum.Checked
tests/headerruns over a fixture/procwith a ~300 character command line containing--. It asserts the header lineSampler: ... for 20 samples, a non-zerosampler_cpu_ns, the cut line, and the whole command line in the comment.tests/pressurestill counts a two-threaded process's thread, so the link-count skip keeps processes with threads.make checkpasses under ASan/UBSan with gcc in an Ubuntu 24.04 container. CI covers clang.Stacked on #6.
🤖 Generated with Claude Code