2

I am trying to CPU-profile a callback driven system and I'm only interested in profiling when the callback causes me to react a certain way ? Can I use gperftools to accomplish this ?

ProfilerEnable()/ProfilerDisable() seems promising but the header says these are deprecated. I'm not even sure if these would work.

ByteNudger
  • 1,545
  • 5
  • 29
  • 37
nisah
  • 2,478
  • 3
  • 22
  • 20

1 Answers1

1

Indeed ProfilerEnable/Disable is not working anymore.

There is already request for pausing/unpausing profiling https://github.com/gperftools/gperftools/issues/597. But note that doing this pausing/unpausing frequently is likely to have performance impact.

I think you should profile all of your app and then use --focus feature of pprof to filter out uninteresting parts.

  • Aliaksei Kandratsenka, how it (ProfilerEnable/Disable) was implemented and how it was broken? – osgx Jun 26 '16 at 02:46
  • Apparently it used to block profiling signal for current thread. But since SIGPROF delivery is per-process since long time ago, they are now empty functions instead and do nothing as noted in the comment. – Aliaksei Kandratsenka Jul 02 '16 at 16:10
  • "SIGPROF delivery is per-process since long time ago" - is it (in modern linux)? Is there any other interval timer which can be used to profile programs? – osgx Jul 02 '16 at 16:58
  • yes it is. It used to be per-thread (every thread used to have it's own itimers) in old days. – Aliaksei Kandratsenka Jul 07 '16 at 09:40
  • 1
    And yes you can use posix real-time timers for profiling individual thread. We even support it with CPUPROFILE_PER_THREAD_TIMERS but this mode is not free from drawbacks. – Aliaksei Kandratsenka Jul 07 '16 at 09:42