Skip to content

Native CPU-PMU Integration

How to build a native CPU-performance-monitoring data layer for the sparkles benchmarking harness — sparkles:test-runner --bench and the wired runtime bench. The survey grounds the Linux stack (perf_event_open and its decoder libraries — elfutils, libtraceevent, libnuma), maps it onto ARMv8+ and RISC-V, surveys the alternative acquisition APIs on Windows and macOS, and lands in a capability matrix, an audit baseline, and a milestoned backend proposal. Every page is grounded twice over: claims carry pinned repo@commit path:line locators or recorded experiments, and locally-demonstrable behavior is backed by runnable probes CI compiles and runs.

Last reviewed: July 11, 2026

This survey answers ten questions:

  1. What does perf_event_open actually provide — counting, sampling, and the contracts underneath (groups, multiplexing, the ring buffer, rdpmc)? → linux-perf-events
  2. How do the four Linux decoder libraries divide the work, and where do they stop? → elfutils, libtraceevent, libnuma
  3. How does precise memory sampling work on each vendor engine (IBS, PEBS, SPE), and how does a sampled data address become a NUMA node? → precise-sampling
  4. How does the model map onto ARMv8+/ARMv9 — PMUv3's event space, SPE, BRBE, big.LITTLE, uncore — and what is Apple Silicon really? → arm
  5. How does it map onto RISC-V, and which capabilities simply do not exist there yet? → riscv
  6. What can a Windows profiler use without a kernel driver, and what only with one? → windows
  7. What can a macOS process measure at each privilege level, and what is fenced behind root, entitlements, and the event allowlist? → macos
  8. How do human event names become hardware encodings, and which naming layer covers which ISA and OS? → event-naming
  9. Where does the sparkles harness stand today against all of the above? → sparkles-baseline + the delta table
  10. What should sparkles build? → backend-proposal

The seven concerns

Every subject in the tree is analyzed against the same seven-concern spine — where a concern does not apply, the page says so, because the absence of a capability is itself a finding:

  1. Scalar counting — groups, exactness, multiplexing.
  2. Overflow/IP sampling — periods, PMIs, ring buffers.
  3. Precise data-source/address sampling — skidless engines, latency, data addresses.
  4. Code-space decode & symbolization — address-space models, debug info, unwinding.
  5. Event-space & tracing — tracepoints/ETW/kdebug, branch records.
  6. NUMA & topology — nodes, uncore scoping, page→node oracles.
  7. Event naming & encoding — name→selector tables and their coverage boundaries.

Master catalog

SubjectWhat it isConcern focusVerification bedLink
Conceptsthe tree's shared vocabularyallconcepts.md
Linux perf_eventsthe acquisition hub (reference model)1, 2x86_64-linux hwlinux-perf-events.md
elfutilscode-space decoder (libelf/libdw/libdwfl)4x86_64-linux hwelfutils.md
libtraceeventevent-space decoder (tracefs format)5sourcelibtraceevent.md
libnumatopology/placement decoder6x86_64-linux hw (single-node)libnuma.md
Precise samplingIBS · PEBS · SPE → one ABI; address→node3, 6IBS hw; PEBS/SPE sourceprecise-sampling.md
ARMv8+PMUv3, SPE, BRBE, big.LITTLE, uncore, Apple1–7 mappingsource; Apple aarch64-darwin hwarm.md
RISC-VSBI indirection, Sscofpmf, CTR1–7 mapping (absences)source + specriscv.md
WindowsHCP, ETW, ring-0 drivers, PDB, Win32 NUMA1–7 mappingdocs + open consumerswindows.md
macOSkpc/kperf, rusage, Instruments, dyld/dSYM1–7 mappingaarch64-darwin hwmacos.md
Event naminglibpfm4, PAPI, LIKWID, vendor tables7x86_64-linux hwevent-naming.md
Comparisoncapability matrix · trade-offs · delta tablesynthesiscomparison.md
sparkles baselinetoday's counter layer, as observedaudit targetin-reposparkles-baseline.md
Backend proposalmilestoned per-OS acquisition core, in Ddesignbackend-proposal.md

Taxonomies

By ISA

ISACounting modelPrecise engineBranch recordsPages
x86_64 (AMD)perf_event_open, 6 PMCsIBS (skid 0)LBRlinux, precise
x86_64 (Intel)perf_event_open, fixed+GPPEBS (precise_ip 1–3)LBRprecise, naming
ARMv8+/v9PMUv3 (PMCEID-probed), per-cluster PMUsSPE (AUX)BRBEarm
RISC-VSBI-mediated mhpmcounternoneCTR (ratified, no consumer)riscv
Apple Siliconproprietary CPMU, 2 fixed + 8none exposednone exposedarm §Apple, macos

By OS

OSAcquisition surfaceEvent policyDecode stackPage
Linuxone syscall, all modesopen selectors, paranoid-gatedMMAP2 + DWARF (elfutils)linux
WindowsHCP + ETW + closed ring-0 driverscurated + global registrationimage-load events + PDB (DbgHelp)windows
macOSkpc/kperf (root) · rusage (unpriv) · Instrumentskernel allowlist, even for rootdyld map + dSYM (CoreSymbolication)macos

By verification level

LevelWhat carries it
[hw-verified: x86_64-linux]Linux counting/sampling/unwinding, IBS, libpfm4 round trip, NUMA round trip — the five probes below
[hw-verified: aarch64-darwin]kpep catalogs, kpc EPERM matrix, rusage counting, xctrace, dyld/atos — mac-bsn transcripts in macos/arm
[source-verified]ARM-Linux drivers, RISC-V kernel/SBI/firmware, PEBS, xnu/dtrace, krabsetw, all pinned repos
[literature]vendor docs (saved), gated specs cited by section

Milestones

When the key capabilities landed. Coarse dates are [literature]; entries verified in this survey's sources are tagged.

WhenWhat
~2000Intel PEBS ships with NetBurst (Pentium 4) [literature]
2007AMD IBS ships with Family 10h (Barcelona) [literature]
2009Linux 2.6.31 merges perf_event_open [literature]; Windows 7 ships HCP thread profiling (min-version per the API docs) [source-verified]
2016Armv8.2 defines SPE [literature]
2019Win10 1903 allows raw ProfileSource registration; 19H1 makes ETW LBR public [source-verified] (docs); Armv8.5/PMUv3p5 makes event counters 64-bit [source-verified]
2021RISC-V Sscofpmf ratified; SBI 0.3 adds the PMU extension [literature]; Armv9.2 defines BRBE [source-verified]
2024-11-22RISC-V CTR (Smctr/Ssctr) v1.0 ratified [source-verified] — still no Linux consumer at v7.1-rc6
2024Apple M4 remaps its common PMU events onto PMUv3 architected numbers [hw-verified: aarch64-darwin]

The runnable probes

Standalone dub single-file programs under examples/; CI compiles and runs each (they SKIP cleanly on hosts lacking a capability). Environment: Linux 6.18.26, AMD Ryzen 9 7940HX, LDC 1.41.

ProbeDemonstratesBacks
counting-group.dgrouped IPC (exact) + forced multiplex scalinglinux concern 1
sampling-symbolize.dring-buffer IP sampling → libdwfl symbolizationlinux concern 2/4
unwind-stack-user.dDWARF-CFI unwind of a frame-pointer-less buildlinux/elfutils
mem-latency-numa.dIBS data-source/latency sampling + page→node oraclesprecise
pfm4-name-roundtrip.dlibpfm4 name→perf_event_attr→open→countnaming

Quick navigation

Sources

Per-page Sources sections carry the primary references; repos are pinned by SHA and papers archived locally (see each deep-dive). The five probes and the mac-bsn transcripts are the survey's own experimental evidence; experiment environments are recorded alongside every quoted output.