google / pprof

pprof is a tool for visualization and analysis of profiling data
Apache License 2.0
8.02k stars 607 forks source link

Speed-up flame graph generation by skipping unneeded work. #881

Closed ghemawat closed 4 months ago

ghemawat commented 4 months ago

Previously, we used to call report.TextItems() during flame graph generation just so we could get a hand on the legend to print in the profile details box. All the work done by TextItems() to produce a trimmed graph was discarded.

This change separates out the legend generation into a separate routine so that we can avoid doing the unnecessary work.

Benchmark result:

name      old time/op  new time/op  delta
Flame-12   6.10s ± 3%   0.39s ± 4%  -93.59%  (p=0.000 n=10+10)
codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.02%. Comparing base (0ed6a68) to head (a99a299). Report is 30 commits behind head on main.

Files Patch % Lines
internal/report/report.go 90.90% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #881 +/- ## ========================================== + Coverage 66.86% 67.02% +0.16% ========================================== Files 44 44 Lines 9824 9796 -28 ========================================== - Hits 6569 6566 -3 + Misses 2794 2778 -16 + Partials 461 452 -9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.