Advanced · Module 9 · Lesson 2 of 13
Hardware Performance Counters: PMU Profiling with Linux perf and Flame Graphs
Sample CPU microarchitectural bottlenecks with hardware Performance Monitoring Units (PMUs), capture call stacks with perf, and visualize execution hot paths using Flame Graphs.
By the end you can
- Profile low-level CPU events (IPC, cache-misses, branch-misses) using Linux perf stat
- Sample instruction pointer distribution and call chains using perf record
- Differentiate frame pointer, DWARF, and Last Branch Record (LBR) stack unwinding
- Generate and interpret Brendan Gregg Flame Graphs to isolate on-CPU bottlenecks
Builds on CPU Cache Hierarchy: L1/L2/L3 Topologies, Cache Lines, and Data Locality.
01 · A question first
Why does gprof or manual time-instrumentation slow down your code by 50% while distorting the results, whereas hardware performance counters sample live production workloads with less than 1% overhead? The secret lies in on-chip silicon counters and APIC interrupts.
Make a guess before you read on.
02 · The idea
Members only
Unlock the full lesson
This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.
What's inside
- Start with the problem
- How the idea works
- Production Profiling Workflow
- Why it is correct
- What it costs
- Pitfalls and variations
- Where it is used
03 · Practice
Asked in interviews
Something wrong with this lesson? Report a problem