Need Psyco profiling help...

KefX keflimarcusx at aol.comNOSPAM
Fri Oct 24 21:49:40 EDT 2003


Hey...as for what I'm doing with Python, look at my post "Strange Hotshot
problem". To make a long story short, I'm embedding Python in order to write a
plugin to a freeware music program; the plugin interfaces to the program with
C++, but the plugin calls Python routines to do much (but not all) of the work.

Which brings me to the problem. It's SLOW! Well, that's hardly surprising, but
anyway...I'm using Psyco, and it's definitely at least twice as fast with it
than it is without it. However this is not enough: my program produces crackles
and such as a result of hogging the CPU so much that there's latency. So
obviously I need to optimize.

But to optimize, I need to find a bottleneck, using a profiler. An obvious way
to do this with Psyco is to just use psyco.log('somefile.log') and then
psyco.profile()...however most of the time seems to be spent in Psyco's
active_start function! I decided the profiler may well be screwy so I tries
Hotshot. Well, Hotshot and Psyco don't work well together, I found out. But my
buddy CyanPhase suggested I write a do-nothing function in place of my Work
function, bind it with Psyco, and see how much CPU it takes. This function
simply filled an array of floats with zeroes and returned it (because the
caller needed some data to copy to another buffer). This only took 2.5% of the
CPU! Therefore the overhead of using Psyco certainly can't be eating up the
unaccounted-for 97.5% of the CPU, it has to be my code. But Psyco's profiler
says it isn't.

What's going on here? How can I find where the real bottleneck is so I can fix
it?

- Kef





More information about the Python-list mailing list