PDA

View Full Version : hyperthreading P4 slowdown



Pocus
17-03-2006, 10:39 AM
Hi,

I have 2 users (out of several hundreds) which have a slowdown in playing Birth of America (100% delphi game with Omega wrapper). They both have an hyperthread P4.

One disabled the option, and the game run at full speed.
The other has not done that yet.

Any idea why these P4 can slow a DirectX app? I have them run a test app where there is only one bitmap and some D3D text displayed with Omega (DirectX 8.1) and they run it at a very low speed too. So nothing particular to my game, but more about some DirectX call being fumbled by the 2 virtuals CPU.

??? any help appreciated on the issue. Is this a known problem that hyp P4 have issues with Dx apps? :roll:

technomage
17-03-2006, 11:46 AM
Does your game use threads at all? I have come across problems before with multi threaded applications and hyperthreading cpu's, best case you get a slow down , worst case a full on crash (with no exception raised, the app just bombs out). I have found the best option is to disable it. There is a method through task manager to force an application to use only one cpu (cpu affinity I think).

In my case the problem was down to the communication between two threads.

Huehnerschaender
17-03-2006, 12:17 PM
As far as I know, Hyperthreading is only useful for several applications running simultaniously within windows. But for games, which mostly need the full power of CPU and other ressources, hyperthreading can slow down the "application".

I remember buying a game (don't know if it was WoW or Battlefield 2) where the manual said, the user should disable Hyperthreading because of the above mentioned problem.

So I think, it's wether "your problem" nor a problem of your game.

Greetings,
Dirk

jdarling
17-03-2006, 02:35 PM
Well you have to remember that Hyperthreading makes the system appear to be a multi-processor machine even though it isn't. Essentially its the hardware simulating a multiprocessor environment w/o one actually being around. This will make multiple applications running on the same PC appear to run faster then when only windows is controlling the slicing. In games though, and other high end applications like PhotoShop, it actually slows the applications down as its taking from their usual time slice and doesn't allow them to override the default running window. So yes they will slow down.

In short, as others have said, the only fix is for your players to turn off Hyperthreading.

Pocus
17-03-2006, 02:39 PM
No, I removed the threaded timer some time ago. I now use Omega Timer, which is not in a thread (if I recall well the code).

Thanks for the tips. CPU affinity ... yes. I will ask the user to do that.

If you have some references of big companies who ask to disable HT, then I will grab them. It will makes me feel more confident when I encounter new users with the problem :)

jdarling
17-03-2006, 02:45 PM
Just do a google for hyperthreading games and problems. Here are two of the results it turns up:
http://www.tweakguides.com/SWB2_1.html
http://www.daemonology.net/hyperthreading-considered-harmful/

tpascal
17-03-2006, 03:38 PM
I think saw at gamedev forum somone talking about this problem, seem there is a problem with dual proccesors and the use of QueryPerformanceFrequency & QueryPerformanceCounter() (both functions are used for implement timers and get timing in games).

take at look at this:

http://support.microsoft.com/default.aspx?scid=kb;en-us;327809


Make a test using gettickcount() for your timing to see if that is the problem.

good luck.

tp.

Pocus
19-03-2006, 08:16 AM
I will check if all my QueryPerformanceCounter call are using 64 bits, but you surely can't replace QPF with GetTickCount, the later having only a low precision.

Thanks for the URL.

Pocus
19-03-2006, 08:20 AM
I was using extended, once, and all other call were using int64.

I seriously doubt that it will make a difference. For me it has more to do that microsoft is trying to reject the fault on coders, as usual. :roll:

tpascal
20-03-2006, 05:26 PM
actually, the 32/64 bits integers was not the problem i was talking, sorry it was my mistake.

Seem that in dual proccesors the queryperformancecounter and queryperformancefrequency when called by your program somtimes it will be executed by one procesor and somtimes it is executed by the other proccesor, the resulting value could be different depending which processor made the execution; that explain why the problem is resolved when one of the procesor is turned Off in the seting.

I got that from here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/queryperformancecounter.asp

Seem you can fix the problem forcing your program to be always executed just by one of the processors using the setthreadaffinitymask function:

http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadaffinitymask.asp


good luck.
tp

technomage
20-03-2006, 06:09 PM
Fantastic, glad you found that. That will probably solve the problem I have at work as well :D

Good Detective work there :)

Pocus
21-03-2006, 08:37 AM
good, now has anybody the magic function that let me just have an app run on one CPU (discarding the virtual one). I'm clueless about the usage of

SetThreadAffinityMask

The SetThreadAffinityMask function sets a processor affinity mask for the specified thread.

DWORD_PTR SetThreadAffinityMask(
HANDLE hThread,
DWORD_PTR dwThreadAffinityMask
);

Parameters

hThread
[in] Handle to the thread whose affinity mask is to be set.

This handle must have the THREAD_SET_INFORMATION and THREAD_QUERY_INFORMATION access rights. For more information, see Thread Security and Access Rights.
dwThreadAffinityMask
[in] Affinity mask for the thread.

Pocus
21-03-2006, 09:21 AM
an interesting page, I tweaked my executable with the utility posted there. I hope this will fix the problem.

http://www.robpol86.com/Pages/imagecfg.php

Sly
21-03-2006, 09:46 AM
SetThreadAffinityMask(GetCurrentThread(), 1);

Pocus
21-03-2006, 10:04 AM
ah, nice this GetCurrentThread call, I wondered how in the hell I could find which thread I was on.

Thank you much.