[Stackless] On greenlets

Christian Tismer tismer at stackless.com
Tue Mar 30 04:49:55 CEST 2004


Tristan Seligmann wrote:

> On Tue, Mar 16, 2004 at 02:36:28 +0100, Christian Tismer wrote:
> 
>>If you want to know more, check out the sprint trunk and read
>>sprint/Greenlet. There is a copy of my/our hard switching
>>platform stuff, and a tiny extension module named greenlet.c,
>>which is able to do hardware switching as an extension module
>>to standard Python!!!
> 
> 
> I wasn't sure if I had completely understood what was said here, so I'll
> ask directly:
> 
> Does this mean that Stackless Python will now be implemented entirely as
> an extension module?

Probably not. While I'm interested in ways to see how Stackless
can be done without actually patching Python, I have a tendency
towards efficient code. Others are trying to get the best out
of code that does not  need any patching at all.
I do appreciate this very much. At least, these solutions
give a chance to newbies to try stackless features without
installing Stackless at all. I really really like this attempt.

To be more concrete:
The Greenlet stuff and what we said about it leads to a way
towards completely python-independant green threads.
This gives Stackless an opportunity to do stack switching
using this external module.

But things are intermingled. There is hard switching, which possibly
could be done almost without any interpreter support, and there is
soft switching, which hardly can be done without lots of interpreter
support. Or, in other words, you can do it, but you will be missing
most chances of being efficient.

Stackless will try to stay as efficient as possible, while supporting
less-efficient approaches as well. If we can isolate certain ideas
like Greenlets, they will exist on their own. For integration with
stackless, there will always be an optimized version which tries
to deliver as much freedom as possible from one world, while keeping
as much as possible from the benefits of the other world.

I really want to migrate to Greenlets.
There are a lot of issues which have not been adressed, yet, and as
always they appear soon after the people have dropped off the sprint.
There will be lots of discussion, and I will implement a lot of
efficient things which make sense both with tasklets and greenlets.
There is just no general direction which is able to answer all
questions at the same time, now.

Unless I get major complaints, the most probable changes to stackless
for the near future are:
- refining tasklets to be able to act as a CFrame.
   This can avoid most of CFrame creations, and also provide
   the tasklet end frame.
- since tasklets are frames, then, adopt a way to dynamically chain
   them up, avoiding to have a single main() as a controller.
- save extra frames for tasklets being blocked in channels, since
   tasklets have the baseframe structure.
- save creating an extra channel field to make itpossible to rip
   tasklets out of their frame.
- create a new scheduling scheme that prevends the main tasklet
   from doing channel operations at all, by making the parentof a
   frame responsible to provide the methods which handle scheduling
   after a tasklet is blocked/unblocked on a channel.

Real Greenlet stuff has to wait for quite some time.
This is really turning things upside-down, and the consequences
aren't all that clear to me.

I have a lot of ideas for that, but this takes time for
negotiations. Was already about to do huge changes, again,
but some ambiguities stopped me doing that, and this is just good.
The current scheme may be considered bad, but it has some dirt
simplicity in it, which we should try to retain or improve.

cheers - chris

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/


_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list