[Twisted-Python] Two main loops
glyph at divmod.com
glyph at divmod.com
Thu Nov 15 13:40:43 EST 2007
On 14 Nov, 07:08 pm, drew.smathers at gmail.com wrote:
>>Actually, punting to another thread or process is still going to slow
>>down your rendering, but in a much less deterministic way. The OS
>>scheduler is going to be interrupting the rendering rather than the
>>long-running serialization function. Breaking down the serialization
>>work into smaller chunks will allow you to better control what's going
>>on.
>
>Holy crap! I just grew an extra brain cell! It has tingly sensation
>like
>selson blue.
Nice to hear that we're helping to increase the transistor density of
the universe.
>So let me offer some empirical evidence of this phenomenon which I was
>not
>quite understanding until reading your comment - of course, it makes
>complete sense now. I've been working on a cheesey game in my spare
>time
>called Twisted Wars (yes, the Twisted), and just to amuse myself I
>decided
>to run the reactor normally rather than threaded select and model the
>runtime loop as a cooperative iterator - the idea being that eventually
>the
>runtime loop could be many cooiterators, to allow for an actor-based
>system.
I've seen Twisted Wars. It's flattering, but I hope it's going to
evolve from beyond its, ahem, "humble" beginnings into something more
interesting :). Nice to unveil the mystery of its author, though ...
>To my surprise, after changing the core runtime to a cooiterator, my
>frame
>rate improved (albeit only about +5 - but this might be more noticeable
>if I
>had a decent frame rate to start with). I explained to a friend who's
>also
>working on the game and they refused to believe me! Ha!
Although I'm glad you've gained some insight into the exciting world of
improving performance (or not) with parallelism, I wouldn't read too
much into this. threadedselectreactor is a particularly poorly-tested
piece of code and it might have performance bugaboos of its own that
have nothing to do with concurrency. Also, as I said, I've tried
Twisted Wars; one of the things I noticed about it is that the framerate
seems to degrade slowly over time until the game becomes sluggish and
unplayable. It seems like you're leaking computation somewhere. So
you've got a lot of factors to consider when measuring your overall
framerate.
More information about the Twisted-Python
mailing list