Loading...
Loading...
Compare original and translation side by side
git clone https://github.com/brendangregg/FlameGraphgit clone https://github.com/brendangregg/FlameGraphundefinedundefinedundefinedundefined
One-liner:
```bash
perf record -F 999 -g ./prog && perf script | stackcollapse-perf.pl | flamegraph.pl > fg.svg
单行命令:
```bash
perf record -F 999 -g ./prog && perf script | stackcollapse-perf.pl | flamegraph.pl > fg.svgundefinedundefinedundefinedundefinedvalgrind --tool=callgrind --callgrind-out-file=cg.out ./prog
stackcollapse-callgrind.pl cg.out | flamegraph.pl > fg.svgvalgrind --tool=callgrind --callgrind-out-file=cg.out ./prog
stackcollapse-callgrind.pl cg.out | flamegraph.pl > fg.svgundefinedundefinedundefinedundefined| Pattern | Meaning | Action |
|---|---|---|
| Wide frame near bottom | Function itself is hot | Optimise that function |
| Wide frame with tall narrow towers | Calling many different callees | Hot dispatch; reduce call overhead |
| Very tall stack with wide base | Deep recursion | Check recursion depth; consider iterative approach |
| Plateau at the top | Leaf function with no callees | This leaf is the actual hotspot |
| Many narrow identical stacks | Many threads doing the same work | Consider parallelism or batching |
| 模式 | 含义 | 操作建议 |
|---|---|---|
| 底部的宽帧 | 函数本身是热点 | 优化该函数 |
| 宽帧上方有多个窄高的调用链 | 调用了大量不同的子函数 | 热点调度;减少调用开销 |
| 非常高的调用栈且底部较宽 | 深度递归 | 检查递归深度;考虑改用迭代实现 |
| 顶部的平台状帧 | 无调用子函数的叶子函数 | 该叶子函数是实际热点 |
| 大量相同的窄调用栈 | 多个线程执行相同任务 | 考虑并行化或批量处理 |
flamegraph.pl --title "My App" \
--subtitle "Release build, workload X" \
--width 1600 \
--height 16 \
--minwidth 0.5 \
--colors java \
out.folded > fg.svg| Option | Effect |
|---|---|
| SVG title |
| Width in pixels |
| Frame height in pixels |
| Omit frames < N% (reduces clutter) |
| Palette: |
| Icicle chart (roots at top) |
| Reverse stacks |
| Consistent palette (same frame = same color across SVGs) |
flamegraph.pl --title "My App" \
--subtitle "Release build, workload X" \
--width 1600 \
--height 16 \
--minwidth 0.5 \
--colors java \
out.folded > fg.svg| 选项 | 作用 |
|---|---|
| SVG标题 |
| 宽度(像素) |
| 帧高度(像素) |
| 忽略占比小于N%的帧(减少冗余) |
| 配色方案: |
| 生成冰柱图(根节点在顶部) |
| 反转调用栈 |
| 配色一致(不同SVG中同一帧使用相同颜色) |
skills/profilers/linux-perfskills/profilers/valgrindskills/compilers/clangskills/profilers/linux-perfskills/profilers/valgrindskills/compilers/clang