[Stackless] stackless and multi-core

Jeff Senn senn at maya.com
Mon Apr 28 20:12:42 CEST 2008

On Apr 28, 2008, at 1:31 PM, Andrew Francis wrote:

> Hi Jeff:
> --- Jeff Senn <senn at maya.com> wrote:
>> Hm.  I don't understand your analogy with the
>> "watchdog".
> I believe the watchdog in the Stackless scheduler
> counts a given number of instructions before
> interrupting a tasklet.

Ah. I see. Yes in the python VM this is done
in the interpreter loop directly -- defining
an "interval" in which the GIL is released and
immediately reacquired. (possibly letting some
other thread run).  In fact that bit of code is
exactly what is patched in stackless to do
scheduling (possibly just at a different rate than
GIL release/acquire).

> Okay, I see your point. Now another naive question. If
> one's Stackless programme uses only one OS thread -
> why hae a GIL? How much overhead does this add?

Well.. I haven't looked lately but I seem to recall
there is code that only bothers with (releasing) the GIL
if there are multiple threads running python

> Naive question/comment two. Perhaps for coarse grained
> problems - for example, Stackless application (a game)
> uses a Twisted reactor - perhaps the better way to
> make use of multiple cores is  to have the
> applications in separate processes/processors but
> communicating through shared memory?

Yeah... you would still have to put guards around any
shared memory you were accessing from different

Read this post:


with these thoughts in your head... I don't want to
quash any imaginative thought here... (I'd be thrilled
to find an idea that hasn't been thought of!) but this is fairly
well-trodden ground and most of the twisty passages forward
wind up costing a significant development effort for questionable
gain.  I proposed in that post (and you are starting to
invent!) about the only thing I believe is interesting
(and untried) ... but it's difficult and requires pervasive
code changes... and not anything I'm going to tackle
anytime soon.


More information about the Stackless mailing list