[Python-Dev] cProfile and threads

Antoine Pitrou solipsis at pitrou.net
Tue Aug 17 12:31:30 CEST 2010


On Tue, 17 Aug 2010 09:22:15 +0000
Kristján Valur Jónsson <kristjan at ccpgames.com> wrote:
> Hello there.
> I'd like to draw your attention to two feature requests / patches that I've subbmitted:
> http://bugs.python.org/issue9609
> http://bugs.python.org/issue9622
> 
> These patches are the result of work that we have done in profiling Stackless Python server applications at runtime, but they apply just as well to C Python.
> The first patch makes _lsprof, the engine behind cProfile, multi-stack aware.  This allows the same cProfiler.Profile() instance to be active on multiple python threads and still meaningful information is gathered.

Does that mean you're proposing code for inclusion in CPython that can
only be tested with Stackless?
Can't Stackless use its own patches instead?

> The second patch allows to set the trace/profile function in python globally, so that all threads are affected.  This is essential if you want to take a profililng snapshot of a running application.

I've often heard that cProfile didn't give correct profiling
information with multiple threads. Is it true?

Thanks

Antoine.




More information about the Python-Dev mailing list