Skip to content

Conversation

@mlim19
Copy link
Contributor

@mlim19 mlim19 commented Feb 2, 2026

This is the initial implementation of the request filed at #1013.

Summary

Add support for hardware event-based flamegraph generation using custom perf events (PMU events). Users
can now generate flamegraphs based on specific hardware performance counters like cache misses, branch
mispredictions, and other PMU events instead of the default CPU time-based sampling.

Key Features

  • Support for any perf event (hardware, software, tracepoint, custom PMU)
  • Frequency-based (-F) and period-based (-c) sampling modes
  • Automatic PEBS precise modifier selection (:pp on bare metal, :p on VMs)
  • Platform detection (ICX, SPR, EMR, GNR) and hypervisor detection via CPUID
  • Custom PMU event definitions via JSON file
  • Sampling metadata included in collapsed file output

New CLI Options

Option Description
--perf-event Specify a perf event for profiling (e.g., cache-misses, branch-misses). Disables
all language-specific profilers.
--perf-event-period Use period-based sampling instead of frequency. Requires --perf-event.
Mutually exclusive with -f.
--hw-events-file Path to JSON file with custom PMU event definitions. Requires --perf-event.

Usage Examples

# Profile using cache-misses event with default frequency (11 Hz)
sudo ./gprofiler --perf-event cache-misses -d 60 -o /tmp

# Profile with custom frequency (99 Hz)
sudo ./gprofiler --perf-event cache-misses -f 99 -d 60 -o /tmp

# Profile with period-based sampling (every 10,000 cache misses)
sudo ./gprofiler --perf-event cache-misses --perf-event-period 10000 -d 60 -o /tmp

# Profile using custom event from JSON file
sudo ./gprofiler --perf-event my-custom-event --hw-events-file /path/to/hw_events.json -d 60 -o /tmp


Limitations

- --perf-event-period requires --perf-event
- --perf-event-period and -f/--frequency are mutually exclusive
- --hw-events-file requires --perf-event
- Uncore events are rejected (cannot be attributed to processes)

Signed-off-by: Min Lim <min.yeol.lim@intel.com>
Signed-off-by: Min Yeol Lim <min.yeol.lim@intel.com>
@mlim19 mlim19 requested a review from dkorlovs February 2, 2026 22:49
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