The flamegraph is lying to you about width
Width is not work. A short note on self time.
A wide frame means the function was on the stack a lot. It does not mean it was doing work. I have optimised the wrong one more than once.
Width is total time — the frame plus everything it called. What belongs to the function itself is the strip not covered by its children: self time. A frame taking 60% of the graph with one child covering 59% is a pass-through.
So, in order:
- Sort by self time, not width.
- Find the widest frame whose children are narrow. That is the real leaf cost.
- Only then look at call counts.
Rule two is the one worth keeping: you want the deepest wide frame, not the first one you notice.
end 2026.08.14
← back to index