When analyzing CPU performance, the first problem you face is "I can't tell where the bottleneck is." With Linux perf stat, you can obtain counts of various events:
- L1 miss
- LLC miss
- branch mispredict
- stall cycle
- TLB miss
But just looking at these numbers tells you nothing. You have to use them to work out where the real bottleneck is and what to optimize to improve performance.
An analysis method called Top-Down Microarchitecture Analysis has been proposed for this purpose. It is the method actually used in Intel VTune.
When you use Intel VTune, the General Exploration view apparently shows the following categories:
- Retiring
- Frontend Bound
- Backend Bound
- Bad Speculation
These categories are based on this Top-Down Microarchitecture Analysis.
Here, I would like to read the paper that Top-Down Analysis is based on, "A Top-Down Method for Performance Analysis and Counters Architecture" by Ahmad Yasin.
Problems with Conventional Performance Analysis
First, let me go over the problem setting the paper addresses.
In conventional performance analysis, estimates like the following were often made.
$$ \text{stall cycles} = \text{miss}\times\text{latency} $$
For example, if
- L2 miss = 100 times
- L2 latency = 20 cycles
then you estimate "stall = 2000 cycles."
However, such a simple estimate does not hold for an Out-of-Order CPU. The paper gives several reasons for this.
Stalls Overlap
In an Out-of-Order CPU, multiple instructions are in flight at the same time.
For example, an "instruction cache miss" and a "data cache miss" may occur simultaneously. In that case the stalls are not simply added together.
In other words, the model "stall = sum of miss × latency" does not hold.
Noise from Speculative Execution Creeps In
Modern CPUs perform speculative execution. That is, instructions on a "wrong control flow path" are also executed. As a result, "an event occurred" does not necessarily mean "performance was affected."
Latency Depends on the Workload
For example, the penalty of a branch misprediction is not fixed.
- distance between branches
- instruction dependencies
- pipeline state
and so on cause it to vary. Therefore the estimate "miss × fixed latency" is not accurate.
Superscalar CPUs Execute Multiple Instructions Simultaneously
In modern CPUs, "1 cycle = 1 instruction" does not hold. For example, in a 4-wide issue CPU, 1 cycle = up to 4 uops. Therefore, analysis in units of cycles alone cannot capture what is really happening in terms of performance.
The Basic Idea of Top-Down Analysis
The paper's proposal is very simple.
It classifies CPU execution time not by "where it was lost" but by "what it was spent on."
Specifically, it classifies pipeline issue slots into the following four types.
- Retiring
- Bad Speculation
- Frontend Bound
- Backend Bound
This is the top-level classification of Top-Down Analysis.
The Concept of a Pipeline Slot
What matters here is that classification is done by slot, not by cycle.
For example, in a 4-wide issue CPU, 1 cycle = 4 slots.
In other words, the CPU is considered to be consuming not cycles but "issue slots."
The basic idea of Top-Down Analysis is to classify what these slots were used for.
The Meaning of the Top-Level Classification
At the top level, pipeline slots are classified into the following four types.

Retiring
These are slots corresponding to instructions that were executed correctly. Ideally, "Retiring = 100%."
Bad Speculation
These are slots wasted because of events such as branch mispredictions. Examples include branch misprediction and machine clear.
It is important that this category is placed at the top level. When the proportion of speculation is large, the reliability of other performance metrics drops.
Frontend Bound
This is the state where the frontend could not supply uops. That is, "the backend can accept uops, but the frontend is under-supplying them."
Typical examples are "i-cache miss," "iTLB miss," and "insufficient decode bandwidth."
Backend Bound
This is the state where slots could not be used because of a lack of backend resources.
Examples include "cache miss," "execution port contention," and "dependency chain."
Why Classify at the Issue Point?
One of the paper's key design ideas is classification at the issue stage.
Classification proceeds as follows. First, uop issued ? is evaluated.
- If a uop was issued, the slot is classified as "Retiring" or "Bad Speculation."
- If it was not issued,
backend stall ?is evaluated.- If there is a stall, it is "Backend Bound."
- If there is no stall, it is classified as "Frontend Bound."
In other words, classification is done at the frontend / backend boundary.

Why Is This Classification Effective?
In conventional analysis, you looked at "which events are numerous." In Top-Down Analysis, you look at "where the CPU's resources were used."
For example, the information that "Backend Bound is dominant" points more clearly to what should be investigated next than the information that "there are many L2 misses."
This is the greatest feature of Top-Down Analysis.
This is an English translation of the original Japanese post: Top-Down Microarchitecture Analysisとは何か ― Intelの性能解析手法の基本思想を読む (1)