Profiling a CGO application - pprof alternatives

1,628 views
Skip to first unread message

Tal Lichtenstein

unread,
Jul 5, 2021, 7:24:41 PM7/5/21
to golang-nuts
I am trying to pinpoint a performance issue with a go package that uses a large 3rd party C++ library we interface with using CGO.

Tried these options:

1. Go profiler - doesn't see anything beyond function runtime.cgocall. This has already been discussed here and as far as I understand is not going to be supported.

2. gperftools - it seems the Go runtime is interfering with the operation of gperftools in some way: When starting the program with the CPUPROFILE variable or using explicit ProfilerStart() calls, the output file gets created but nothing is written to it until the program ends. My guess is the Go runtime is somehow preventing gperftools from receiving sampling events.

3. Linux perf - this works, but requires converting the data to pprof format (using perf_data_converter) or analyzing it using another tool like hotspot. 

Currently our best bet is to stick to perf. Anyone have other suggestions?

It would be awesome if Go supported profiling a mixed C/Go application with the built-in tools...

Ian Lance Taylor

unread,
Jul 5, 2021, 8:39:32 PM7/5/21
to Tal Lichtenstein, golang-nuts
It may work if you import github.com/ianlancetaylor/cgosymbolizer.
One of the goals of that package is to support CPU profiling for C++
code called by a Go program.

Ian
Reply all
Reply to author
Forward
0 new messages