Performance issue on Xbox

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Fax3D
Posts: 22
Joined: Mon Sep 29, 2008 7:42 am

Performance issue on Xbox

Post by Fax3D »

Hi Norbo,

i've a strange problem with my engine. I create a simple scene with 15/20 convex hull entities (40/50 vertex each other) falling on the ground. All works great on windows, even if i increase the numer of object to 100/150. When i deploy the same code on Xbox, until each entity falls to sleep, the simulation is very very slow! Only if i set each entity as nondynamic kinematic object the performance is good.

I try setting space.UseMultithreadedUpdate on true and then on false.
I try setting space.SimulationSettings.CollisionDetection.CollisionDetectionType to all allowed values.
I try using space.SimulationSettings.TimeStep.UseInternalTimeStepping = true.

Each scenario has a poor performance. But only on Xbox! Consider that the physics loop runs on the third core second thread. On the same core but on the first thread, there's some low processing routines. But even with physics looping on another available thread gave me not good results.

What's wrong? where could be my fault?
If you need some portion of code just ask me.

Thanks in advance!

Fax3D
Danthekilla
Posts: 136
Joined: Sun Jan 17, 2010 11:35 am

Re: Performance issue on Xbox

Post by Danthekilla »

20 objects with 50 vertices each will run very badly on the xbox 360, your pc's cpu is anywhere between 3 and 25 times faster nowdays...

Things i would suggest would be:

1. Find out wether its the broadphase or narrowphase that is slowing it down (i would assume narrowphase because of the 50 vert objects) and try to tune the simulation to suit it.
2. are many of these objects colliding at once? if so move them further away from each other this will help.
3. lower the iteration count in the simulation settings (default is 15, i would try 8) with this code
space.SimulationSettings.CollisionResponse.Iterations = 20;

4. enable multithreading with this code
space.ThreadManager.AddThread(delegate(object information) { Thread.CurrentThread.SetProcessorAffinity(new int[] { 1 }); }, null);
space.ThreadManager.AddThread(delegate(object information) { Thread.CurrentThread.SetProcessorAffinity(new int[] { 3 }); }, null);
space.ThreadManager.AddThread(delegate(object information) { Thread.CurrentThread.SetProcessorAffinity(new int[] { 5 }); }, null);
space.UseMultithreadedUpdate = true;

Try all this and let us know if this makes it any better...
Fax3D
Posts: 22
Joined: Mon Sep 29, 2008 7:42 am

Re: Performance issue on Xbox

Post by Fax3D »

Yes the objects are colliding many times each other... but it's only a performance test so in real situation this is not common.

my space.SimulationSettings.CollisionResponse.Iterations is set to 8 and i've tried yet to enable multithreading , but the performance issue is still present. The only thing which improves a little the performance is to use DiscreteMPR (but is still slow compared to pc).
My pc cpu is an amd athlon single core @2.0ghz... not a monster, and is capable of ~90 FPS (with 50/60 convex hull) :D
Possibily there's a problem managing the power of the Xbox cpu...

If i consider to use Box and Sphere entities instead of convex hull the performance gain could be considerable on pc?
If yes, i'll limit the use of convex hull only for real necessary objects.

Thanks very much :)

Fax3D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Performance issue on Xbox

Post by Norbo »

The Xbox360 won't be able to come close to even an 'old' CPU by todays standards. The VMX processor features are inaccessible from managed code, cutting out a good chunk of floating point performance. There's other architectural issues (in order vs out of order and others) and the simple old age of the system that factor in as well.

The engine is always getting faster on the Xbox360 due to optimizations, but those optimizations also speed up the PC version ;)

That said, to maximize performance regardless of platform, there's some things you can do (some of which have already been mentioned).
-Use whatever shape is appropriate. If it's a box, use a Box shape. If it's a sphere, use a Sphere shape. The simpler the better. Sphere-sphere collision is one or two orders of magnitude faster than a ConvexHull collision due to its speedy special case.
-When using a ConvexHull, minimize the number of points in the hull. The cost of its collision detection is roughly proportional to the complexity of the hull.
-Reduce the iteration count as much as possible to the point where the simulation runs just well enough.
-Use the DiscreteMPRGJK collision detection type. Its behavior is usually a bit better than the pure-MPR version, and should run faster in many cases.
-If possible, reduce your game's update rate to 30 FPS and use a 1/30f timestep with internal time stepping enabled. This does less work overall than a 60 fps update rate. Stability will suffer, though many simulations work just fine.
Fax3D
Posts: 22
Joined: Mon Sep 29, 2008 7:42 am

Re: Performance issue on Xbox

Post by Fax3D »

Thanks very much for the explanation guys! These info are very useful...

Fax3D
Post Reply