[Stackless] [C++-sig] [Boost] Trouble optimizing Boost.Python integration for game development (it seems too slow)
sanduleac.dan at gmail.com
Wed Aug 26 15:34:15 CEST 2009
On Wed, Aug 26, 2009 at 2:40 PM, Simon Wittber <simonwittber at gmail.com>wrote:
> On Wed, Aug 26, 2009 at 5:31 PM, Dan Sanduleac<sanduleac.dan at gmail.com>
> > The testing goes like this: each "tick", 10000 objects update their
> > position, according to their velocity and timedelta since last "tick",
> > I'm measuring the average time a tick takes to complete.
> I know that I'm not answering your question, but I thought I might
> throw in some advice, if you have a need for speed.
> It would be much faster to create an Vec3Array type object, and do the
> loop iteration with the += operating inside C++. This would make your
> Python API look something like:
> positions = Vec3Array(10000)
> velocities = Vec3Array(10000)
> positions += velocities
> Also, Stackless will have little effect your benchmarks, so you may
> find more answers in a more general forum.
> :: Simon Wittber
> :: http://www.linkedin.com/in/simonwittber
> :: phone: +61.4.0135.0685
> :: jabber/msn: simonwittber at gmail.com
Thanks for the reply :D
I know, I posted on the c++-sig list first, but didn't get an answer there
so I decided to post on stackless too.
What you're suggesting would of course speed up the process dramatically,
but each of those objects lives in its own tasklet, and I wanted to simulate
10000 objects each performing some action (per game tick), say updating its
position, in its "run-loop". Because of this, I couldn't code the loop in C,
as I'm stuck with the one from stackless' scheduler.
Of course, in a real game, the position wouldn't be updated by each object
in its own thread. There would be a second stage in which a faster
(compiled) physics engine would do this. However, this was just for testing
and I couldn't think of something else.
OvermindDL1 solved my problem, letting me know that I was dealing with heavy
function call overhead, which added up because I was calling C functions
from python at a very fast rate.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Stackless