hardware-counters

Analyze CPU performance with hardware counters and PMU events using perf and PAPI.

159|20|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill hardware-counters
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hardware-counters
Source: https://github.com/mohitmishra786/low-level-dev-skills/tree/main/skills/profilers/hardware-counters
Command: npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill hardware-counters

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you deeply analyze CPU performance by leveraging hardware performance counters, enabling you to pinpoint bottlenecks related to cache, branches, and memory access.

Core Features & Use Cases

  • PMU Event Collection: Gather specific hardware performance monitoring unit (PMU) events using perf stat.
  • Metric Calculation: Compute key performance indicators like IPC, cache miss rates, and branch misprediction ratios.
  • Source-Level Analysis: Correlate performance events directly to specific lines of source code using perf annotate.
  • Use Case: Identify why a critical loop in your C++ application is running slower than expected by measuring L3 cache misses and branch mispredictions per instruction.

Quick Start

Use the hardware-counters skill to measure cache miss rate with perf.

Frequently Asked Questions about hardware-counters

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I measure cache miss rates and branch mispredictions using hardware counters?

Hardware counters measure cache miss rates and branch mispredictions by collecting PMU events with tools like `perf stat`, computing key indicators, and correlating events to source code for low-level microarchitectural tuning.

What is CPU performance profiling with PMU events?

CPU performance profiling with PMU events monitors hardware performance counters to pinpoint bottlenecks related to cache, branches, and memory access, enabling detailed microarchitectural performance tuning for performance-critical applications.

How do I identify why my C++ application loop is running slower than expected?

Identify slow C++ application loops by measuring L3 cache misses and branch mispredictions per instruction using `perf annotate`, correlating hardware performance events directly to specific lines of source code.

Can I use the PAPI library to collect hardware performance monitoring unit events?

Yes, the PAPI library collects specific hardware performance monitoring unit (PMU) events alongside `perf stat`, gathering hardware counters to compute performance indicators like Instructions Per Clock (IPC) and cache miss rates.

What's the best way to analyze IPC and CPU bottlenecks in performance-critical applications?

The best way to analyze IPC and CPU bottlenecks is using hardware counters to collect PMU events, calculating Instructions Per Clock (IPC) metrics to pinpoint cache and memory access limitations for microarchitectural optimization.

When do I need hardware counters for low-level optimization?

Hardware counters are needed for low-level optimization when you must deeply analyze CPU performance to pinpoint bottlenecks related to cache, branches, and memory access that standard profiling cannot detect.