[Stackless] Profiling strangeness and crash

Kristján Valur Jónsson kristjan at ccpgames.com
Fri Jan 25 16:21:04 CET 2008

Hello all.
I was recently asked to re-enable our profiler after we moved from stackless 2.3 to 2.5.  After the switch, it had stopped working.

Our profiler is a sublclass of profile.Profile, and properly deals with context switches by saving and restoring the profiling context when we move between tasklets.

Now, I have two problems.

1)      The stuff crashes in eve.  I have not been able to repro the crash in the standard 2.5 thing, but I have enclosed a demo that shows mysterious behaviour.  We never reach the "print ´b´" code at all, and get some internal error there too (myprofile.py is just profile.py with a print statement in there)

2)      It would appear that stackless now only profiles on the main tasklet, that is, turns off profiling on other tasklets.  This is a change of behaviour from the old days.

After debugging a lot, it appears to me that something is heavily wrong with task switching in this scenario.  At least in EVE.  I didn't turn on the debugger for the standalone python yet.  It also appears somehow related to point 2) above, particularly the "restore_tracing()" callback in scheduling.c.

Does anyone have a clue what is going on?

And how are the profiling (and tracing) semantics in stackless now wrt. tasklets?  Does it save and restore the tracing state in each tasklet?

If we manage to figure out what is going on here, I would like to be able to have the old profiling behaviour again.  That is, that profiling is a per-thread global state which can be turned on and off to capture profiling information about a running stackless program.  Any objections?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20080125/b2805be9/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: profile.zip
Type: application/x-zip-compressed
Size: 2474 bytes
Desc: profile.zip
URL: <http://www.stackless.com/pipermail/stackless/attachments/20080125/b2805be9/attachment.bin>

More information about the Stackless mailing list