Skip to content

Record who else was on the machine, and say the platform out loud - #8

Merged
PhillThomas merged 1 commit into
mainfrom
interference-and-platform
Nov 9, 2026
Merged

PhillThomas merged 1 commit into
mainfrom
interference-and-platform

Conversation

@PhillThomas

Copy link
Copy Markdown
Owner

Three things came out of the 7800X3D thread and they are in one branch because they came out of one conversation.

1. interference in the exported document

Kernel pressure numbers, load average, and the runnable processes at the start and end of a run:

"interference": {
  "start": {
    "at": "2026-11-09T13:26:02.459755Z",
    "cpu_some_avg10": 0.0, "memory_some_avg10": 0.0, "io_some_avg10": 0.0,
    "loadavg": [0.76, 1.57, 1.01],
    "runnable_total": 0, "uninterruptible": 0,
    "running": [],
    "source": "psi + loadavg + /proc/<pid>/stat"
  },
  "end": { "..." : "..." },
  "warning": null
}

It exists because of a specific mistake I made: I cleared a run of interference on the strength of a load average of 1.15, taken while the benchmark was producing that load itself. The L3 cell uses eight threads, and eight threads for two and a half seconds out of every twenty-nine accounts for most of the 1.15. A load average taken during a run is a poor instrument for "was anything else here", so the document now carries the kernel's own answer (PSI some avg10) alongside it rather than leaving the reader with only the number I got wrong.

This would not have caught the thing that motivated it, and the README says so. Two yes processes spinning on this twelve-core box leave cpu some at 0.0 — measured, not reasoned — because nothing is waiting for a core. The warning fires on stalls, not on how many things are awake, because as far as the kernel is concerned a machine with spare cores is not contended. So the field is an instrument, not a verdict: the list of runnable processes is there for a human to weigh, and the thresholds deliberately do not pretend to have judged it.

Two samples, at either end of the run, before and after the last measurement. It cannot see a process that arrived between two cells and left, and PSI is a rolling ten-second average, so "coarse" is the right word for it.

The CPU number in /proc/<pid>/stat took me three attempts and belongs in the record. It is the thirty-seventh field after the comm, and the one before it is exit_signal, which is 17 for every ordinary process on Linux, so both my wrong attempts printed a plausible CPU number on a twelve-CPU machine instead of failing. What settled it was taskset: a process pinned to CPU 5 reports 5 there and pinned to 9 reports 9. The test that pins a thread and waits for the kernel to catch up is not in this branch — it passed on its own and failed inside a full-suite run, which is a red light that depends on what ran before it, and I am not adding one of those.

schema_version stays at 2. The field is #[serde(default)], so a document written before it existed loads with None and the old runs stay comparable; a version bump would have thrown away exactly the comparisons this is for.

Cost, measured against the binary from before this change, five identical --level l1 --only read --trials 1 --duration-ms 20 runs on a box with 115 processes: 680 ms before, 667 ms after. That is the two /proc walks disappearing into noise, not a speed-up claim.

2. Platform: Linux, said once

cargo check --target aarch64-apple-darwin fails with fourteen unresolved names — sched_setaffinity, cpu_set_t, sched_getcpu, sched_setscheduler, MAP_HUGETLB, MADV_HUGEPAGE and friends. They are all the same three decisions: detection reads /proc and /sys, threads are pinned with sched_setaffinity, buffers ask the kernel for huge pages. The measured loops are not the platform-specific part; a port is an operating-system project. So there is now a compile_error! that says that in one sentence, and a Platform note at the top of Build.

3. CI now lints the AArch64 tests

scripts/ci.sh gained cargo clippy --target aarch64-unknown-linux-gnu --workspace --all-targets -- -D warnings ahead of the existing cross build. That step is what found two dead-code warnings on the previous branch — cfg drift in code that only exists on one architecture, and #[cfg(test)] blocks the host gates never compile, because there is no ARM runner and there isn't going to be one for this. The cross build stays: clippy stops short of codegen, and codegen is the only thing that parses inline asm.


scripts/ci.sh is green end to end including the new step: 116 core + 23 binary tests, both debug and release. The report-only external comparison still reports its five cells over the gate, unchanged, on a loaded host.

Three things that came out of the 7800X3D investigation, in one commit
because they came out of one conversation.

`interference` in the document: kernel pressure numbers, the load average,
and the runnable processes at the start and the end of a run. A cell moved by
a factor of three on one machine, and I cleared the run of interference on the
strength of a load average that the benchmark was producing itself — the cell
used eight threads, and eight threads for two and a half seconds every
twenty-nine accounts for most of the 1.15 I logged as "flat". A load average
taken during a run is a poor instrument for "was anything else here"; PSI is
the kernel's answer to that question and costs two reads. It samples at the
two ends of a run, so it cannot see a process that arrived between two cells
and left, and the README says that rather than implying more.

The CPU index in `/proc/<pid>/stat` took three attempts to get right and
deserves its place in the commit message: field 37 is the processor, and the
field before it is `exit_signal`, which is 17 on every ordinary process on
Linux. My first two attempts both read a plausible CPU number. Verified by
hand with `taskset -c 5` and `taskset -c 9`, which report 5 and 9, and pinned
afterwards by a test. The test that pins the thread and waits for the kernel
to catch up is not in here: it passed alone and failed in a full-suite run,
which is a red light that depends on what ran before it.

`compile_error!` for anything that is not Linux, and a Platform section in the
README. membench does not build for macOS, and `cargo check
--target aarch64-apple-darwin` explains that as fourteen unresolved `libc`
names — `sched_setaffinity`, `cpu_set_t`, `MAP_HUGETLB` — which all point back
to three decisions about where detection reads and how buffers are asked for.
One sentence says it better.

CI gains an AArch64 clippy pass over `--all-targets` before the existing cross
build. That is what noticed the two dead-code warnings on the previous branch;
without it, cfg drift in AArch64 test code and dead code that only exists on
one architecture both pass review.
@PhillThomas
PhillThomas merged commit a3e1b03 into main Nov 9, 2026
4 checks passed
@PhillThomas
PhillThomas deleted the interference-and-platform branch November 9, 2026 13:53
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.

2 participants