You are here

Musings on Optimization

Nothing terribly important, but as I've been spending quite a bit of time getting very familiar with oprofile (again), and Google likes the site better when I post regularly;-) I felt like writing some things down.

Here goes:
[*]No amount of optimization in my collision detection and animation loops is too much. The latter is turning out to be the biggest headache because it needs to touch every dynamic vertex to do its thing and I'm finding very few good areas for optimization.
[*]Profile. Profile. Profile. Not new advice, but worth taking anyway. The two areas previously mentioned are not exactly surprising as hot spots, but there have been a few other parts that turned up during my profiling which were easier to optimize away and have helped the framerate as well. For instance, my vertex class has a function to get the data out in a VBO friendly format, and at one point that was taking up 15-20% of my CPU time. With a little tweaking it's down to a few percent now.
[*]Don't lookup your shaders by name. At least I think that's why a map<string, unsigned int> function call is showing up as using 10% CPU in my profiles. It's either that or my textures, but I don't think I look those up by name after the first load, so I'm pretty sure it's the shaders. More investigation is needed though.
[*]I can manage between 40 and 50 FPS on the server with 18 players (because of my 3x3 spawn areas basically a full load), but that's with bots doing no moving and no firing, so there's no extra collision detection to handle. On the other hand, most of the time you won't have 9 players on each team hanging out at the spawn all needing to be collision detected against. After some tree optimization, player models are by far the worst things to collision detect right now. I might just approximate them with bounding spheres for movement if it turns out to be a problem. Given that 30 FPS for the server is my target though, I may be okay. At some point I need to make a concerted effort to find some people to test with for real and see what breaks.
[*]40 to 50 FPS is only when the server is running dedicated. For some reason running it as a thread in the client drops that 5-10 lower. I'm not entirely sure why, although I suspect it has to do with thread scheduling.

This blog post brought to you by my disinterest in trying to squeeze a couple more FPS out of my crappy code. Enjoy!:-)