You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What operating system and processor architecture are you using?
Linux, x86-64 Intel.
What did you do?
I opened the attached profile with go tool pprof -http=: fac.pb.gz,
and navigated to the "Sources" page. Here is the output:
As you can see, it is claimed that fac took 6193% of the total time.
It is also said that it took 150 seconds, which is wrong since the
program took only a couple of seconds.
The issue also occurs with the command line version, although strangely
the output is better.
This is wrong, since the cumulative time spent in the current function
is not fns.Sum() if the function calls itself recursively. In those
cases some nodes will be counted multiple times.
Source Code
package main
import"os"import"log"import"runtime/pprof"funcfac(nuint64) uint64 {
ifn==0 {
return1
} else {
returnn*fac(n-1)
}
}
funcmain() {
f, err:=os.Create("example.pb.gz")
iferr!=nil {
log.Fatal("could not create CPU profile: ", err)
}
deferf.Close() // error handling omitted for exampleiferr:=pprof.StartCPUProfile(f); err!=nil {
log.Fatal("could not start CPU profile: ", err)
}
deferpprof.StopCPUProfile()
fori:=1; i<=1e6; i++ {
fac(1000)
}
}
The text was updated successfully, but these errors were encountered:
What version of pprof are you using?
go tool pprof
with go1.18.3.Full
go env
outputWhat operating system and processor architecture are you using?
Linux, x86-64 Intel.
What did you do?
I opened the attached profile with
go tool pprof -http=: fac.pb.gz
,and navigated to the "Sources" page. Here is the output:
As you can see, it is claimed that
fac
took 6193% of the total time.It is also said that it took 150 seconds, which is wrong since the
program took only a couple of seconds.
The issue also occurs with the command line version, although strangely
the output is better.
What did you expect to see?
cum%
should not be more than100%
.What did you see instead?
cum%
is claimed to be 6193%.Root cause(?)
I believe the root cause is this line of code:
pprof/internal/report/source.go
Line 104 in c488b8f
This is wrong, since the cumulative time spent in the current function
is not
fns.Sum()
if the function calls itself recursively. In thosecases some nodes will be counted multiple times.
Source Code
The text was updated successfully, but these errors were encountered: