GC language optimization, any ideas?

I am a very big newbie when it comes to optimization. In the current game I'm working on, I was able to optimize the function and shave off about 0.5% of the processor load, and this is about as “amazing” as I am.

My situation is this: I developed a physical heavy game in MonoTouch using an XNA cover library called ExEn, and I think it’s very difficult for me to get the game to reach the reproduced frame rate on iPhone4 (I don’t even want to think about iPhone3GS at this stage).

A decrease in performance almost certainly occurs in physics calculations, if I turn off physics, the frame rate drops sharply, if I turn off everything, rendering, input, sound and just leave physics at work at a speed of about 15 frames per second in conditions of intensive physics.

I used performance profiling tools, and this is what I got: http://i.imgur.com/FX25h.png The functions that deplete the most performance are either from the physics engine (Farseer) or the ExEn XNA shell functions that they called (especially Vector2.Max, Vector2.Min).

I looked at these functions, and I know wherever Farseer could pass values ​​by reference to these functions, and not at the cost, so that this covers (and this is literally the only way I can think of. In the amount of operations like

return new Vector2(Max(v1.x, v2.x), Max(v1.y, v2.y)) 

Basically, I feel stuck in my limited ability and understand the code optimization. I’m not sure what options I have or if I have any options (maybe I just need to get into the fetal position and cry?). With LLVM enabled and embedded release, I get maybe 15 feet per second at best. I managed to bring the game to 30 frames per second, lowering physical accuracy, but this makes many levels simply unplayable, because the bodies intersect with each other and collapse onto themselves.

So my question is: is this a lost cause or is there something I can do to increase productivity?

+7
source share
2 answers

First of all, love your game on Windows Phone 7!

Secondly, I do not see anything unusual in your profiler. I did a quick and dirty analysis of the Farseer engine performance once (works in .net) and came up with similar results. It almost seems like you have a slowdown proportional in all directions, and may be due to mono itself.

+3
source

I believe that you are already following the performance tips at http://farseerphysics.codeplex.com/documentation :-)

  • Most importantly, it seems to reduce the complexity of collision detection calculations, that is, not a visual, but an oncoming form. In Unijty3D they are called colliders, and you can cube as a collider for a complex person’s body. I don't know anything about Feuer, but they probably have similar ones (is this called a body?).

    If possible, try replacing the main character or other complex Light Cubes objects and see if the fps rises.

  • Compilers sometimes use performance. Be sure that debugging settings are activated (I got up to 30x slower code in the C ++ library project). Make sure armv7 optimization is enabled and -O3 or -Os

  • Beware of logging applications as they are extremely expensive on iPhone

[Update:]

  • Try reducing the number of actively computed AABBs to find out which part of the physical engine is causing problems. If it's a pure number, follow the advice of FFox.

  • What are other platforms? Where did you conduct testing at the development stage, on the simulator? Which one of? Is there any chance to run it on Android or Android simulator or Windows Phone? This will give you a hint if this is a specific iPhone problem.

  • Ah, I just saw that ExEn is still in pre-release, and the final will be launched on July 21 as an OS. IMO this makes a difference: if your application runs fine on some other comparable platform, just wait for the release and give it a new try. Most likely, in the preliminary release you are working on, there is still debugging code.

+3
source

All Articles