CPU Profiling on Mac OS Sierra

565 views
Skip to first unread message

bob.ziu...@gmail.com

unread,
Nov 8, 2016, 11:57:42 AM11/8/16
to golang-nuts
Hi,

I am attempting to profile a Go application but keep getting empty pprof data with go 1.7.3 on Mac Sierra (package installer version from https://golang.org/dl).  The profiling output exists, but the top10 output is meaningless.  Profiling the same code on ubuntu 16.04 with go 1.7.3 returns meaningful output.

I've tried profiling several different applications and I get the same meaningless profiling data for each on Mac OS Sierra.  The simplest shareable example I've tried is that of GitHub user eapache: https://gist.github.com/eapache/580b7dbd8800fe9a3234#file-test-go.  The output of that test is below:

Output on Mac OS Sierra:

$ go tool pprof profile.out
Entering interactive mode (type "help" for commands)
(pprof) top10
31.22s of 31.22s total (  100%)
      flat  flat%   sum%        cum   cum%
    31.22s   100%   100%     31.22s   100%

Output on Ubuntu 16.04:

$ go tool pprof profile.out 
Entering interactive mode (type "help" for commands)
(pprof) top10
21320ms of 34690ms total (61.46%)
Dropped 119 nodes (cum <= 173.45ms)
Showing top 10 nodes out of 97 (cum >= 660ms)
      flat  flat%   sum%        cum   cum%
    8910ms 25.68% 25.68%     8910ms 25.68%  runtime.memclr
    4030ms 11.62% 37.30%     4030ms 11.62%  runtime.memmove
    1860ms  5.36% 42.66%     4220ms 12.16%  runtime.sweepone
    1670ms  4.81% 47.48%     1670ms  4.81%  runtime/internal/atomic.Xchg
    1080ms  3.11% 50.59%     1080ms  3.11%  runtime/internal/atomic.Xadd
     880ms  2.54% 53.13%    20890ms 60.22%  runtime.mallocgc
     790ms  2.28% 55.41%     1740ms  5.02%  runtime.writebarrierptr_nostore1
     730ms  2.10% 57.51%    27300ms 78.70%  runtime.concatstrings
     710ms  2.05% 59.56%     1770ms  5.10%  runtime.(*mheap).allocSpanLocked
     660ms  1.90% 61.46%      660ms  1.90%  runtime.procyield


Is there anyone else running Mac OS Sierra who can check/confirm correct profiling functionality on Go 1.7.3?

Thanks,

Bob


rhys.h...@gmail.com

unread,
Nov 8, 2016, 2:39:56 PM11/8/16
to golang-nuts
Try specifying the path to the binary as the second to last argument (see "go tool pprof -h").

On Linux as of Go 1.7, CPU profiles include information on what executables are mapped into memory. This allows the pprof tool to locate the binary. Raw CPU profiles taken on macOS don't include this information, so you need to specify the path to the binary by hand.

Dave Cheney

unread,
Nov 8, 2016, 4:18:33 PM11/8/16
to golang-nuts

bob.ziu...@gmail.com

unread,
Nov 8, 2016, 9:46:39 PM11/8/16
to golang-nuts
That explains it.  Thank you very much for the info.  I've confirmed that does indeed resolve the issue.

Bob
Reply all
Reply to author
Forward
0 new messages