[howto] optimizing a Windows panda runtime

Note: This is highly experimental and I’m sharing so that it gets tested. It only applies to Windows.

I just added a setting to makepanda.py to turn off checked iterators in a Windows build of Panda. Checked iterators are a Visual Studio feature that check container operations for out of bound errors in runtime, this adds an extra layer of security at the cost of performance.

See here for Microsoft’s documentation.

Since performance is important in games and neither Mac or Linux have this feature to start with, it seems appropriate to disable this in most cases (You should do so only after understanding the security implications, though). Note that you don’t need this for Linux or Mac because those platforms don’t have implicit iterator checking to start with so there’s nothing to turn off.

Note also that this feature will get even slower in the next version of Visual Studio since they are changing it to make it more robust (source.) so turning it off will be even more important in the future.

About the kind of performance increase you could expect… For example, in my client code that generates a terrain I go from 33ms to 21ms per terrain chunk. In regards to FPS, on a very simple scene I get a 6% FPS increase, but this increase can be much higher (or lower) depending on where are the bottlenecks on your game.

The feature is still turned on by default (which is Visual Studio default) but support is now there in makepanda so that you can turn it off. To build Panda with this optimization just add an override parameter at the end of your settings like this:

makepanda\makepanda.bat --everything --optimize 3 --override "_SECURE_SCL=0"

If you try this, tell us if you get any crashes, also it would be nice to know what kind of performance increase you get with this (if any).

I’ll update from CVS, try the setting and let you know what goes…
Hopefully my ffmpeg will work this time as well :slight_smile:

Interesting feature… keep up the great work.