View Full Version : opengl slow(or fps limit) until start browser
10-01-2011, 09:34 PM
Hey, i've just stumbled upon this weird bug myself, i've seen it mentioned on some board long time ago, but i can't find right keywords for google to find relative info...So...my opengl application is slow or running to fps limit of 32 until i start some browser in background. V-Sync disabled in driver and in my application too(wglSwapIntervalEXT(0);). If i shutdown browser - it's back to slow. What are the possible reasons?
10-01-2011, 09:59 PM
Ok...It certainly fps limit, not slowdown, and it's more likely some weird threading issue. If i remove "Sleep(ms);" from ThreadProc it starts to run without any limits(up to 600fps), but Sleep with any parameter makes it 32fps without browser running in the bg.
10-01-2011, 11:36 PM
Did you try no Sleep and wglSwapIntervalEXT(1); ?
Sleep is not precise, it is a rough minimum time to wait, but heavily depends on the OS scheduler and its click granularity to give you back a slice of CPU.
10-02-2011, 12:25 AM
The browser is probably increasing the rate of the systemwide timer tick. You can do it with timeBeginPeriod and timeEndPeriod - the browser or some addon in the browser is probably calling that API making the timer tick more often and making sleep more precise as a side effect. It actually bogs down your whole system by context switching much more often and seriously harms battery life on laptops.
I strongly advise *against* you using timeBeginPeriod however, as ZbuffeR said, don't use Sleep, it is specifically documented to sleep longer than requested - when you have busy other threads (on the machine) then sleep is designed to sleep longer than requested. Never use sleep for timing.
10-02-2011, 10:34 AM
yeah, i couldn't respond earlier(ISP was down for 10 hours), i tracked down myself that Sleep waits 32ms even if i pass 1ms as parameter if i'm nor running any software that makes problem disappear, so now i'll read about timeBegin\endPeriod and will replace sleep in my threading class with it(if it's not managed and doesn't require ton of ugly code). thank you, fellas, and sorry for offtopic posts, i just was unsure about source of the problem.
10-02-2011, 05:48 PM
my opengl application is slow or running to fps limit of 32 until i start some browser in background.
Sounds like you may have found it. But if not, another idea for you:
Go to your graphics driver config GUI, and disable power management.
10-02-2011, 11:10 PM
ok, i've added timeBegin\EndPeriod(2); around threads in my code and issue is fixed.
but doug65536 said that's a bad technique and Sleep is unacceptable to use? then what are alternatives?
my threads timing looks like that:
Delay = GetTickCount();
(*_fx)(); //execute function
Delay = clamp(GetTickCount() - Delay, 0, Interval); //clamp to acceptable values
Sleep(Interval - Delay); //never sleep more than frame rate requires
also, im not sure if making it like that is efficient. yes it subtracts time took by function to finish to avoid sleeping more than specified timer interval. so if interval is 16ms and function took 2ms to execute it will sleep 14ms(in perfect world), but maybe it wouldn't work so good on all hardware(on my computer it actually makes stuff a bit faster)
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.