[Stackless] GIL issues? Re: Stackless Twisted Integration Example

Andrew Francis andrewfr_ice at yahoo.com
Tue Feb 27 03:20:25 CET 2007

Hello Carlos :

--- Carlos Eduardo de Paula <cedepaula at yahoo.com.br>

> Its a very nice approach the integration you made of
> stackless and twisted. 

Thanks. However I think the strength of this approach
is concurrency, not necessarily performance. I noticed
something funny. When I remove the Tick() and compare
the threaded to the non-threaded solution, the later
is almost ten times faster! Also when I replaced the
channel, with uThread queue or a deque, the
performance climbed about 18%. See what you get?

> My current computer is a Pentium 4 2.8Ghz, the only
> changes I made to your code is adding the sleep call
> in tick. For testing, I wrote a small bit like this:


> Whats interesting is that I always get around 60-65
> TPS but my CPU usage is extremely low.. the server
> process uses less then 1%, I think there´s something
> limiting inside the server.

I believe the global interpreter lock (GIL) is coming
into play. I believe time.sleep() causes the GIL to
release. I have a slower computer (1.4GHz). Using your
test driver, I initially got a TPS of 22. When I use
time.sleep(.0001), the TPS is nearly the same as the
non-threaded solution! I have to read up more on the
GIL to see how to tweak this. I also have to do more
methodical tests.

> I will try to read some documentation on twisted
> side also...

It would help if I understand what callInThread() and
callFromThread really do under the hood.

> may we could get better performance
> having the server spawn a new tasklet handler for
> each incoming connection, then it would open a CGI
> tasklet also and the server would perform better. I
> will give it a try... need to study some more
> twisted...

I have servers where each requestHandler has its own
"reply" channel. However a useful server has to do
> As I do more tests, I keep you informed, any
> suggestion is welcome.

Thanks alot for the research!!!


Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list