How to run CPU profile of a specific function using pprof?

1.2k Views Asked by At

This blog details how to run CPU profile using pprof. When profiling, a function like main may disappear from the sample because pprof truncates the sample to the bottom 100 stack frames. This is documented:

In fact the total for main.FindLoops and main.main should have been 100%, but each stack sample only includes the bottom 100 stack frames; during about a quarter of the samples, the recursive main.DFS function was more than 100 frames deeper than main.main so the complete trace was truncated.

The issue with is that I have a particular function I want to profile. The sampler reports it appearing something like 5% of the time but I know that's not accurate. Its frame on the stack must have been lost due to the truncation.

Is there a way I can profile a particular function and never truncate it from the stack frame sample? I want to know its true CPU profile out of 100%.

0

There are 0 best solutions below