As a developer who doesn't use mathematical notation very often, I've had some difficulty reading it.
From my understanding, the paper goes as follows:<p>2.1 Define FlameGraph<p><pre><code> Frame = something that identifies function/location in the code
Stack = Vec<Frame>
FlameGraph = Map<Stack, Real>
FlameGraphPositive = Map<Stack, RealPositive>
</code></pre>
2.2 Define FlameChart<p><pre><code> FlameChart = Vec<{ start: Real, flame_graph: FlameGraphPositive }>
# such that the start values are strictly ordered
fn to_flamegraph(flame_chart: FlameChart) -> FlameGraphPositive {
flame_chart
.map(|{ start, flame_graph }| flame_graph)
.sum()
}
</code></pre>
Personally, I think a better definition of FlameChart is:<p><pre><code> FlameChart = Vec<{ end_time: RealPositive, stack: Stack }>
# such that sampling starts at 0 and Vec is strictly ordered by end_time
fn to_flamegraph(flame_chart: FlameChart) -> FlameGraphPositive {
let mut start = 0.0;
flame_chart.map(|{ end_time, stack }| {
let elapsed = end_time - start;
start = end_time;
FlameGraphPositive::from_stack(stack, elapsed)
}).sum()
}
</code></pre>
3.1 Define diff<p><pre><code> # a,b: FlameGraphPositive
fn diff(a, b) -> FlameGraph;
# such that a + diff = b
# diff: FlameGraph
# add, sub: FlameGraphPositive
fn to_positive(diff) -> { add, sub };
# such that diff = add - sub
</code></pre>
3.2 Define a naive diff metric<p><pre><code> # a,b: FlameGraphPositive
fn diff_metric(a, b) -> RealPositive {
diff(a, b).size() / (a.size() + b.size())
}
# diff_metric(a, b) \in [0, 1]^Real
</code></pre>
3.3 Define a more sophisticated diff metric<p>Using Hotelling T^2 Test, the author defines a metric, which takes sampling variance into account, and allows to detect performance regression, even when the sampling profile is noisy. (you'd have to read the paper for the exact method)<p>The code for this test is here:
<a href="https://github.com/P403n1x87/flamegraph-experiment/blob/04db2aa/flamegraph.py#L65-L89">https://github.com/P403n1x87/flamegraph-experiment/blob/04db...</a>
<a href="https://github.com/P403n1x87/flamegraph-experiment/blob/04db2aa/stats.py#L7">https://github.com/P403n1x87/flamegraph-experiment/blob/04db...</a>