Profiling GOLANG applications using kcachegrind and SVG

One of the things I missed when starting to use golang was departing from profiling tools like visualvm and yourkit for the JVM. Golang has a few options and one of them I’ll be documenting here is profiling your running application and outputting a callgrind file that you can use to understand your running golang app.


Screenshot 2014-10-15 12.45.02


or via SVG!

Screenshot 2014-10-15 13.01.24


To enable  this kind of profiling, follow the instructions for adding pprof to your application:

Once your app is back up and running with pprof and you’re putting some stress on it then it’s time to check out a profile.

Installing kcachegrind on ubuntu:

 sudo apt-get install kcachegrind

launch it:


start debugging an application

jim@localhost: ~
➺ go tool pprof
Gathering CPU profile from for 30 seconds to
Be patient...
Wrote profile to /var/folders/mg/x8pzmrlj6msgkkvvcbpybd580000gn/T/TjhdgALH3Z
Welcome to pprof! For help, type 'help'.
(pprof) callgrind my-cool-grindfile

now just click OPEN on kcachegrind and you should be able to visualize your running application from it’s snapshot.

If you want to view the SVG version then just type in “web” from the pprof interactive shell instead of “callgrind my-cool-grindfile”


If you get the error:
Failed to POST to

edit the following file:
jim@ubuntu:~$ vim /usr/local/go/pkg/tool/linux_amd64/pprof

and change:
if ($@) {
if (1) {

Accumulating multiple host results back from fabric

Handy snippet of Python Fabric code to accumulate results  over multiple hosts and combine the output and collect the totals

The example below is a toy example that demonstrates how to do a fan out-in with fabric to collect the results into a single method for aggregation of stats or information on a series of remote machines.

The example connects to multiple remote servers and returns back the number of ESTABLISHED connections on the target servers via lsof.


© 2021 Jim Plush: Blog

Theme by Anders NorenUp ↑