[Stackless] Context Switching and Queues
Andrew Francis
andrewfr_ice at yahoo.com
Sun Sep 2 17:55:24 CEST 2007
Hello Colleagues:
I benchmarked my Solution.py (minus the getPage()
call) against a more conventional Stackless/Twisted
programme. Although Solution.py is crudely written and
does more, it is roughly three times slower. Although
performance is not a big issue for me, I have started
to wonder about some things:
1) What are the fundamentals of designing a "reactor"
that inter-operates with Stackless.
2) How to speed up my current implementation.
Examining my code, I noticed the following pattern:
def producer():
# produce some output ...
for channel in channels:
channel.send(someThing)
# the producer does not want a response from the
consumer
stackless.schedule()
Both my reactor and scheduler/timer routines have this
pattern. In the case of the reactor, the
stackless.schedule() is necessary to give other
tasklets that can run, a chance to run. The important
point is each time, a channel.send occurs, the
producer is re-scheduled. I felt there was needless
context switching.
I did a simple test. One involving using channels. The
other involving queues (note - I know uthread has a
Queue class). The queue example was on average, 66%
faster. I am assuming the overhead comes from the
needless context switching. It would be nice if folks
could look at the code and see if there are any
mistakes in the thinking.
I figure that the test provides insights into how to
support "producer" tasklets and "broadcasting." .
Any thoughts?
Cheers,
Andrew
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
http://searchmarketing.yahoo.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Arrays2.py
Type: text/x-python
Size: 832 bytes
Desc: 3551988622-Arrays2.py
Url : http://www.stackless.com/pipermail/stackless/attachments/20070902/18329ded/attachment.py
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Channels2.py
Type: text/x-python
Size: 778 bytes
Desc: 2497593491-Channels2.py
Url : http://www.stackless.com/pipermail/stackless/attachments/20070902/18329ded/attachment-0001.py
More information about the Stackless
mailing list