Win32 Performance Issues

Ok,

So just to update on the original subject - it does seem that the Win32 release build runs the exact same code significantly slower than the OSX build on the same machine. My OSX build runs at 60fps while my Win32 build runs at 50fps. The OSX build has some CPU % to spare as well (it’s not running maxed out).

Does anybody know what the cause of this is? Is there a compiler optimization I need to turn on? Is it related to compiling in 32-bit mode?

Thanks

Check with @slackmoehrle @zhangxm maybe they can answer. That is strange.

Are you using windows7? Because I was checking the build on my Win8 4 year old laptop and it ran very smoothly. I was really surprised. Could you check and tell me by running the build on a Win7/Win8 machine??

Hi @siddharthshekar,
I don’t have access to a windows 7 machine right now - I’m mostly testing on a quad core Windows 8.1 machine. Are you seeing better performance on Windows 7?

@Sheado No otherway around. I have a year old first gen i5 processor laptop running win8 (not 8.1), the build seems to run fine on it, If I run the build on the win7 running 4th gen i5 it stutters.

update your graphics driver, happened for me too, fps goes down abruptly. After update its always 60fps.

Thanks for feedback everybody,

I spent some more time tinkering and realized that the compiler optimizations are all turned off on the cocos2d-x project and my generated project. I turned on /O2 and /Ot optimizations and now I’m at ~58fps.

It’s still slower than my OSX build, but this is way better.
Does anybody know if there are any other optimizations I can turn on?
Also, I’m wondering if the 64-bit build is faster on Windows - I can’t build it right now because all the prebuilt dependencies are 32-bit only…

Hi, I’ve been seeing performance issues on win32 for a while, and recently found that turning on Diagnostic Tools in VS2015 fixed my problems. Got no idea why, and obviously it’s not a viable fix, but it’s interesting so any input is much appreciated! More details in a post I made to another thread:

hey @kingchimp,
You’re probably seeing that because the debugger is probably turned off when the diagnostic tool is turned on. If you run the release build of your game, it’ll probably run fine.

Unfortunately I’ve already tried that as I said in the original post. Stuttering occurs in both debug and release builds. When diagnostic tools are on (which builds in release mode), everything is smooth. Very strange

Woops… sorry, missed the quoted part of your post.
That is really strange.

Just in case it’s related… If your machine has an NVidia card in it, what happens if you turn off Threaded Optimization in the control panel? Turning that off reduced stuttering for my game - not a good solution, but it could help you look for a workaround if it’s related to Threaded Optimization.

No probs, thanks for the recommendation :slight_smile:

I have a Geforce GTX 970 so I turned off Threaded Optimization globally in control panel, and nothing changed. Still, running it with diagnostic tools turned on in VS2015 fixes the stuttering. Running without it, still stutters. Even running the compiled binaries outside of VS has the same behaviour.

hmm, interesting.
The only other things that come to mind are:

  • Look in the desktop and windows parts of the cocos2d-x code. Is pollEvents being called multiple times? In my branch it was, so I removed one of the calls.
  • Did you add GLFW controller support for desktop? If so, that caused unpredictable jitter for my game. Removing it resulted in stable FPS for me.

So I’ve tried a few different things to nail this down, none of which have worked :frowning:

Running diagnostic tools from VS actually launches your binary using vsperf.exe, so I tried doing that manually - still stutters. I’ve also tried disabling / enabling every option I can find in nVidia control panel but it hasn’t had any effect. I guess the next step is to contact Microsoft and see if they can tell me what difference running with diagnostic tools actually makes to the environment.

Compiling and running in Linux is smooth as silk btw.

This is driving me nuts!

Just in case anyone else is encountering this problem, I still haven’t found a solution but I’ve asked MS about it now on the Visual Studio forums. Not looking promising as far as finding a solution though…

Thread on Visual Studio Forums

It sounds like running diagnostic tools is setting the windows timer to a value lower than the default 15.6 msec. Check this post for more info or possibly other solutions.

Looks like you’re onto something there, thanks for the reply. Using ClockRes to check the windows timer interval I get the following results.

Idle without the game running:
Maximum timer interval: 15.625 ms
Minimum timer interval: 0.500 ms
Current timer interval: 15.625 ms

With the game running via diagnostic tools:
Maximum timer interval: 15.625 ms
Minimum timer interval: 0.500 ms
Current timer interval: 0.500 ms

With the game running without diagnostic tools (stuttering):
As above, but current timer interval changes between 0.500 and 15.625.

EDIT: I’ve used your code from your other thread linked above to change the timer interval to 1ms and it’s made a huge difference :smile:

Thanks again!!!