interplane.Get Omega
Read in your language

synapse

A component of the AienOS ecosystem.

Brought by drakestapleton

branch main Branches Tags History

synapse / docs / BENCH_PMU_DIAGNOSTICS.md

175 lines · 15083 bytes Raw Blame History Source

Bench PMU Diagnostics (issue #64)

synapse-bench pmu-diag adds optional CPU performance-counter readings beside the existing physical-bound benchmarks. It is diagnostic only: seconds per operation stay the measured unit, hardware counts are supporting units, and nothing here is a qualification result or a performance claim. Energy is not measured by this path (raw.json says NOT_MEASURED); the run, floor and bounds subcommands and their SI and joule reporting are unchanged.

Diagnostics are opt-in. Nothing runs unless pmu-diag is invoked with a protocol file. The default benchmark output, the existing subcommands and CI (scripts/ci/portable.sh) are untouched. In disabled mode no perf_event_open call is made at all (test acceptance1_disabled_mode_makes_no_system_call).

1. Acceptance and Where It Is Met

Issue #64 acceptanceHow it is metProof
Portable tests: schema validityProtocol, raw and report schemas are versioned (synapse-bench/pmu-diag-*/v1) and refuse unknown fields; the protocol refuses a wrong schema, an order other than control-then-instrumented, duplicate legs, zero sizesacceptance1_schema_protocol_refuses_bad_plans
Portable tests: counter unavailableperf_event_open failing with EACCES/EPERM gives INSTRUMENT_UNAVAILABLE / PERMISSION_DENIED with the OS error text and no counts; ENOENT/ENODEV/EOPNOTSUPP give UNSUPPORTED_EVENT; ENOSYS gives UNSUPPORTED_PLATFORM; any other failure COUNTER_UNAVAILABLEacceptance1_permission_denied_is_instrument_unavailable_without_counts
Portable tests: unsupportedNo CPU PMU in sysfs (a device with events/cpu_cycles and a cpus list) gives NO_PMU; a PMU whose sysfs event encoding differs from the ARM number, or that lacks one of the four events, refuses with UNSUPPORTED_EVENT before any openacceptance1_unsupported_or_missing_pmu_refuses_before_any_open, acceptance1_discovery_verifies_encodings_and_core_classes
Portable tests: multiplexedA counter with time_running < time_enabled is labelled MULTIPLEXED (pinned to its class) or PARTIAL_RESIDENCY (unpinned: migration and multiplexing cannot be told apart); the raw count is kept unscaled. time_running = 0 with count 0 is NOT_SCHEDULEDacceptance1_multiplexed_and_partial_residency_are_labelled_not_scaled
Portable tests: disabled-mode no-opDisabled mode returns DISABLED without touching the backendacceptance1_disabled_mode_makes_no_system_call
Portable tests: malformed or mismatched PMU outputShort reads, wrong member counts, time_running > time_enabled, a count without running time are refused, never repaired. pmu-verify refuses raw evidence whose readings name an unknown PMU or event, a wrong core class, a missing or duplicated event, or a state that does not match the timesacceptance1_malformed_reads_are_refused_never_repaired, acceptance1_verify_refuses_mismatched_pmu_output
Portable tests: correct manifest attributionEvery reading carries PMU name, perf type, core class (from MIDR), ARM event number and sysfs encoding; the manifest records invocation, host, compiler, kernel, perf_event_paranoid, PMU discovery, fixture repo and commit, source and sibling revisionsacceptance1_counted_reads_are_raw_and_attributed_per_core_class, acceptance1_manifest_attribution_and_every_leg_kind_runs, acceptance1_event_attr_is_user_only_inherited_counting
Spark run of 1/4/8/32-agent write legs and query legs with matched baselines; wall-time and PMU distributions and overhead, else NOT_RUNRun on this Spark (section 2). Wall time: measured. PMU counts: NOT_RUN: the host has perf_event_paranoid = 4, so every instrumented window is INSTRUMENT_UNAVAILABLE / PERMISSION_DENIED (84 of 84). Lowering the sysctl or running privileged is an operator decision and was not doneevidence/bench-pmu-diagnostics/host-sample-2026-10-16/
Derived numbers recompute from raw evidence; digest/manifest checks passreport.json is a pure function of protocol.json and raw.json (integers only); pmu-verify recomputes it byte for byte, re-validates every PMU reading and checks SHA256SUMSacceptance3_report_recomputes_from_raw_and_digests_verify; synapse-bench pmu-verify on the host sample passes
One PR scoped to crates/synapse-bench/** and benchmark evidenceNew modules pmu.rs, pmu_diag.rs (+ tests), two subcommands in main.rs, two lines in lib.rs; no change to synapse-store, synapse-api or synapse-crumbthe diff

Also covered: a crumb leg on a fixture without .crumb files is recorded under not_run, never faked (acceptance1_crumb_leg_without_crumb_fixture_is_not_run); on whatever host runs the tests, a real open either counts or returns a typed unavailable state (acceptance1_real_host_sample_is_counted_or_typed_unavailable).

Red before green: each guard was reverted one at a time and its test failed (evidence/bench-pmu-diagnostics/red-green/red-mutations.txt: disabled-mode-opens, counts-scaled, multiplex-unlabelled, refusal-yields-counts, encoding-unchecked, class-unchecked, sums-unchecked). One mutant (fall back to the first PMU for an unknown name) survived because the coverage check still refused the edited evidence; it is recorded there. All 14 tests pass (red-green/green.txt).

Deviation from the issue text. The issue asks to consume the Omega #453 PMU contract. Omega #453 is still open and has not landed. This PR therefore carries a small native backend in synapse-bench (perf_event_open through the existing libc dependency, no new crates) and uses Omega #453's status vocabulary (COUNTER_UNAVAILABLE, PERMISSION_DENIED, MULTIPLEXED, UNSUPPORTED_EVENT) so it can switch to that contract when it lands.

2. Host Sample (diagnostic, not qualification)

Host: GB10 Spark, 20 CPUs (10 Cortex-X925, 10 Cortex-A725), kernel 7.0.0-1019-nvidia, ext4 on /dev/nvme0n1p2, perf_event_paranoid = 4. Binary built from 601b598. The protocol was committed (168fc4e, 07:54:15 UTC) before the run started (07:56:56 UTC); raw.json carries its SHA-256. The commit in between (601b598) only changed how affinity is parsed and left the protocol bytes unchanged. Whole run: 51 s wall. Three repetitions per leg and affinity; each repetition is a control window (counters never opened) followed by an instrumented window on identical input.

Discovery found both PMUs and verified every event encoding against the ARM numbers: armv8_pmuv3_0 (perf type 10, CPUs 0-4 and 10-14, MIDR part 0xD87 Cortex-A725) and armv8_pmuv3_1 (type 11, CPUs 5-9 and 15-19, part 0xD85 Cortex-X925). Every instrumented open was refused: perf_event_open(armv8_pmuv3_0 type 10 event 0x0011 cpu_cycles): Permission denied (os error 13).

Wall nanoseconds per operation, median of 3 (full min/p50/max and CPU-time distributions are in report.json). Overhead is (instrumented p50 - control p50) / control p50. Because every open was refused, the instrumented side differs from the control only by one failed system call, so these overheads measure run-to-run noise, not counter cost.

LegAffinityControl ns/opInstrumented ns/opOverhead (ppm)
floor/sha256_content_12ka7255,9475,941-998
floor/sha256_content_12kx9255,5915,591142
floor/ed25519_verifya72549,09649,116403
floor/ed25519_verifyx92523,83823,831-316
floor/envelope_validatea72555,64255,652183
floor/envelope_validatex92527,70627,705-51
floor/json_decode_submit_requesta725170,888170,810-458
floor/json_decode_submit_requestx92584,57684,599273
write/every_commit, 1 agenta72518,901,38217,563,601-70,776
write/every_commit, 1 agentx92517,340,74716,910,196-24,828
write/every_commit, 4 agentsa72515,949,64316,494,38034,153
write/every_commit, 4 agentsx92517,351,93416,127,962-70,538
write/every_commit, 8 agentsa72516,459,07515,196,846-76,688
write/every_commit, 8 agentsx92516,209,40415,523,021-42,344
write/every_commit, 32 agentsa72517,047,04216,517,166-31,083
write/every_commit, 32 agentsx92515,915,44915,999,5185,282
write/group_commit, 1 agenta7252,137,3782,239,23847,656
write/group_commit, 1 agentx9251,813,3321,657,427-85,977
write/group_commit, 4 agentsa725796,566843,48658,903
write/group_commit, 4 agentsx925659,727660,281839
write/group_commit, 8 agentsa725395,578412,82643,602
write/group_commit, 8 agentsx925323,440324,3352,768
write/group_commit, 32 agentsa725318,176306,580-36,445
write/group_commit, 32 agentsx925186,150177,818-44,759
query/read_tree_diffa725617,578615,837-2,818
query/read_tree_diffx925333,933334,4931,674
crumb/context_advisorya725252,178250,992-4,706
crumb/context_advisoryx925131,462131,023-3,343

Reading the table: the CPU-bound legs (floor, query, crumb) repeat within 0.1 to 0.5 percent. The write legs move by up to about 9 percent between back-to-back windows, because each write window is only 4 operations per agent and is dominated by storage flush time. The X925 cores run the CPU-bound legs about twice as fast as the A725 cores. None of this is a qualification figure: 3 repetitions, short windows, one host.

PMU counts, IPC and mispredict ratios: NOT_RUN (INSTRUMENT_UNAVAILABLE / PERMISSION_DENIED, 84 of 84 instrumented windows). Joules: NOT_MEASURED.

3. Method

4. Formulas (recompute by hand)

All values in raw.json are integers. Per side (control or instrumented) over windows without an error:

5. Limits

6. Reproduction

cargo build --release -p synapse-bench
synapse-bench pmu-diag --evidence <dir holding protocol.json> --work-dir <scratch dir> \
  --fixture-repo <git repo at the protocol's fixture_rev> --source-rev <commit> [--sibling name=rev]...
synapse-bench pmu-verify --evidence evidence/bench-pmu-diagnostics/host-sample-2026-10-16
cd evidence/bench-pmu-diagnostics/host-sample-2026-10-16 && sha256sum -c SHA256SUMS

The run refuses to overwrite an existing raw.json and writes report.json and SHA256SUMS when it finishes. To get counts on a Spark, an operator must permit unprivileged user-space counting (perf_event_paranoid at 2 or lower) or run with CAP_PERFMON; the tool never changes this itself.