flat and cum
Assuming there is a function foo, which is composed of 3 functions and a direct operation.
func foo(){
a() step1
b() step2
do something directly. step3
c() step4
}
Imagine when you call function foo
, it takes 6 seconds, and the time distribution are following.
func foo(){
a() // step1 takes 1s
b() // step2 takes 1s
do something directly. // step3 takes 3s
c() // step4 takes 1s
}
flat
would be the time spent on step3.
cum
would be the total execution time of foo, which contains sub-function call and direct operations. (cum = step1+ step2+ step3+ step4)
sum%
when you run top
in pprof console, each line of output stands for the time spent on specific function. Sum%
means how much time/memory has been spent by previous lines.
To explain this metric, I pick another example which contains more lines. the value of sum%
for forth line is 45.17%. it's the calculated in this way:
line1 19.33%
line2 13.27%
line3 6.60%
line4 5.97%
-----------
sum% 45.17%

Application of sum%
sum%
could help you to identify the big rocks quickly. The following is another example of memory allocation report.
You can see that the first four functions consume 91.06% memory. If I want to do some performance tuning, I should focus on first four functions. All the functions below fourth could be ignored.

Reference
Reddit: What is the meaning of "flat" and "cum" in golang pprof output