perf_event metric source
Performance counter source for joule-profiler. using the Linux perf_event subsystem.
This crate implements MetricSource from joule-profiler-core and collects hardware and software performance counters (CPU cycles, instructions, cache misses, branch mispredictions…) via the perf_event_open(2) syscall, per phase.
Requirements
| Requirement | Details |
|---|---|
| OS | Linux kernel 2.6.31+ |
| CPU | Any architecture with PMU support (x86, ARM, RISC-V…) |
| Permissions | Root, or kernel.perf_event_paranoid ≤ 1 |
Adjusting perf_event_paranoid
# Check current value
# Allow per-process counters for unprivileged users (temporary)
# Persistent
|
Scope
By default, Joule Profiler attaches perf_event counters to the monitored process only (per-process mode, via the pid), following it and any children it spawns across every CPU it runs on.
Alternatively, counters can be scoped to a cgroup v2 instead of the process's pid, by setting cgroup_name in the source configuration:
[]
= "my-cgroup" # use "parent/child" for a nested cgroup
#cgroup_root = "/my/cgroup/hierarchy" # default is /sys/fs/cgroup
This tracks every process inside the cgroup rather than a single pid and its children, it can be useful for containers profiling, and lets counters be opened before the profiled process is spawned (the cgroup must already exist).