3

Is there a Linux library that can run performance profiling within a running process?

I have a rather large linux program that is heavily script-based. Depending on the scripts, the program can have wildly different behaviors (and performance problems). What would be nice is a low-overhead performance library that I can embed in the same process that monitors and provides real-time feedback to the process about it's own performance.

Oprofile would be fantastic, if I could start it within the program and keep it isolated to only that program. From the documentation I've read, it doesn't appear possible.

Does anyone know of any such library?

Thanks!
Andrew Klofas

Andrew Klofas
  • 610
  • 1
  • 7
  • 19

2 Answers2

5

Check out gprof - it should do what you want.

sholsapp
  • 15,542
  • 10
  • 50
  • 67
  • 1
    From the doc it appears that invoking the -g/-pg option will cause the program to run "slower than normal". Also, it appears that gprof can't provide real-time feedback to the process. – Andrew Klofas Feb 23 '12 at 22:13
  • 2
    Anything you add to monitor your process is going to make it run "slower than normal". Why is it that you need real-time feedback? – sholsapp Feb 23 '12 at 22:27
  • Some overhead is okay, but it would be nice to have as minimal impact as possible. The reason im looking for realtime feedback is because there are some components of the program that are "soft realtime" constrained and it would be nice to defer/kill some tasks if the cpu is overloading – Andrew Klofas Feb 23 '12 at 23:49
2

I think gperftools works well for profiling. The runtime performance penalty for CPU profile data is very small.

karunski
  • 3,980
  • 2
  • 17
  • 10