Re: [Warzone-dev] Add back CPU delays? +patch?
Am Mittwoch, 6. Juni 2007 schrieb [EMAIL PROTECTED]: On Tue, 05 Jun 2007 19:50:04 -0400 Giel van Schijndel [EMAIL PROTECTED] wrote: So the one and only SDL_delay call will never have ANY effect on 2nd loop. This really is the most important info you've given by now. This explains where the problem is, know if only we knew what you mean with 2nd loop, we can look at the problem ourselves. I show patch, maybe it lost. In loop.c, where I add the removed SDL_Delay(). That is 2nd loop I was talk about. Main game loop is one with the only SDL_Delay(). You are talking about gameLoop(), which, I explained last time, is no loop, but code executed inside a loop. Now guess which loop that is... Correct, mainLoop(). --Dennis signature.asc Description: This is a digitally signed message part. ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays?
Kamaze schreef: [EMAIL PROTECTED] schrieb: As is now, WZ eats all CPU time. Even when pause. Can we add the removed SDL_Delay() calls that were take out? Friends can no longer play on laptop very long because of this. This is release builds. Well, maybe make this configurable. At game start check if someone set niceCPU to 1. If on, set the function pointer shareCPUTime = SDL_Delay; Otherwise set the functionpointer to null. This should be afaik faster than another if(){} in the mainloop. Actually an if-statement usually is faster than calling a function through a pointer. Firstly this is because when calling a function the compiler needs to set up a new stackframe, and on return needs to erase it (cdecl calling convention), this is for all function calls really. Secondly when calling through a pointer the CPU cannot perform branch prediction, and as such has a high likelyhood of having a cache miss as a result of not having pre-loaded the instructions into memory. Anyway, I do think it might be nice to have an SDL_Delay call every now and then. -- Giel signature.asc Description: OpenPGP digital signature ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays?
Am Dienstag, 5. Juni 2007 schrieb Giel van Schijndel: Kamaze schreef: [EMAIL PROTECTED] schrieb: As is now, WZ eats all CPU time. Even when pause. Can we add the removed SDL_Delay() calls that were take out? Friends can no longer play on laptop very long because of this. This is release builds. Well, maybe make this configurable. At game start check if someone set niceCPU to 1. If on, set the function pointer shareCPUTime = SDL_Delay; Otherwise set the functionpointer to null. This should be afaik faster than another if(){} in the mainloop. Actually an if-statement usually is faster than calling a function through a pointer. Firstly this is because when calling a function the compiler needs to set up a new stackframe, and on return needs to erase it (cdecl calling convention), this is for all function calls really. Secondly when calling through a pointer the CPU cannot perform branch prediction, and as such has a high likelyhood of having a cache miss as a result of not having pre-loaded the instructions into memory. Anyway, I do think it might be nice to have an SDL_Delay call every now and then. Actually there IS a delay, in main.c:701 mainLoop() As long as you don't set your framerate in the config to something insane, you should get enough delays. --Dennis signature.asc Description: This is a digitally signed message part. ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays?
Dennis Schridde schreef: Actually there IS a delay, in main.c:701 mainLoop() As long as you don't set your framerate in the config to something insane, you should get enough delays. Yes, I know. As long as your PC can deliver the requested framerate there is no problem. If it can't however then WZ isn't very friendly in sharing its CPU. -- Giel signature.asc Description: OpenPGP digital signature ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays?
Am Dienstag, 5. Juni 2007 schrieb [EMAIL PROTECTED]: On Tue, 05 Jun 2007 14:26:04 -0400 Dennis Schridde [EMAIL PROTECTED] wrote: Am Dienstag, 5. Juni 2007 schrieb [EMAIL PROTECTED]: But if you wish so, you can add (exactly one and exactly there) a SDL_Delay(1); right after or before SDL_framerateDelay(). What I absolutely want to prevent is dozens of delays spreading all over the code wherever someone thinks he needs to share some time. --Dennis I no think the SDL_Delay there will help. Especially when you have pause menu up. That SDL_Delay that was in menu display code before is needed. Before there was 2 SDL_delay calls I find in menu code, and game loop. Why TH should we add 2 delays? And why should we add a delay somewhere else than in the mainloop? I really don't get the point of this. When the time is shared should be pretty much not matter. I say the delay in menu code. Hit esc, game is pause, it should not eat up same CPU cycles as when play game right? The solution for this would be the ability to set different framerates depending on whether we are paused/in a menu or not. I don't think the right solution is to sprinkle a few delays here and there. For the other, request of framerate is defaults, so this is 30? 60? Is way to tell? CPU on 2 machines is 2.4GHz dual core duo, and 2.0GHz turion. Both have same results of eating all CPU time. Even my machine 2.6GHz dual core it eats up too much CPU time compare to what it was before. I can reduce the load to 20% user-time on my AthlonXP 2GHz. How? set framerate=20 in ~/.warzone2100/config signature.asc Description: This is a digitally signed message part. ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays?
Am Dienstag, 5. Juni 2007 schrieb Dennis Schridde: Am Dienstag, 5. Juni 2007 schrieb [EMAIL PROTECTED]: On Tue, 05 Jun 2007 14:26:04 -0400 Dennis Schridde [EMAIL PROTECTED] wrote: Am Dienstag, 5. Juni 2007 schrieb [EMAIL PROTECTED]: But if you wish so, you can add (exactly one and exactly there) a SDL_Delay(1); right after or before SDL_framerateDelay(). What I absolutely want to prevent is dozens of delays spreading all over the code wherever someone thinks he needs to share some time. --Dennis I no think the SDL_Delay there will help. Especially when you have pause menu up. That SDL_Delay that was in menu display code before is needed. Before there was 2 SDL_delay calls I find in menu code, and game loop. Why TH should we add 2 delays? And why should we add a delay somewhere else than in the mainloop? I really don't get the point of this. When the time is shared should be pretty much not matter. I say the delay in menu code. Hit esc, game is pause, it should not eat up same CPU cycles as when play game right? The solution for this would be the ability to set different framerates depending on whether we are paused/in a menu or not. PS: Another, probably better idea, would be to leave out as much as possible of the gameLoop... It currently already checks for (paused), but maybe some more things can be ignored... And maybe it can even be optimized? I don't think the right solution is to sprinkle a few delays here and there. For the other, request of framerate is defaults, so this is 30? 60? Is way to tell? CPU on 2 machines is 2.4GHz dual core duo, and 2.0GHz turion. Both have same results of eating all CPU time. Even my machine 2.6GHz dual core it eats up too much CPU time compare to what it was before. I can reduce the load to 20% user-time on my AthlonXP 2GHz. How? set framerate=20 in ~/.warzone2100/config signature.asc Description: This is a digitally signed message part. ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays? +patch?
Am Dienstag, 5. Juni 2007 schrieb [EMAIL PROTECTED]: On Tue, 05 Jun 2007 14:51:36 -0400 Dennis Schridde [EMAIL PROTECTED] wrote: I say the delay in menu code. Hit esc, game is pause, it should not eat up same CPU cycles as when play game right? The solution for this would be the ability to set different framerates depending on whether we are paused/in a menu or not. PS: Another, probably better idea, would be to leave out as much as possible of the gameLoop... It currently already checks for (paused), but maybe some more things can be ignored... And maybe it can even be optimized? I don't think the right solution is to sprinkle a few delays here and there. Hmm. I like easy approach, which would be, as before. When paused, game loops through this over and over, so it is one big busy loop. So you still need a delay to fix. Why go make complex code, when add 1 call fix issue? This only hits when user paused. Index: loop.c === --- loop.c(revision 1467) +++ loop.c(working copy) @@ -508,6 +508,7 @@ } } } + SDL_Delay(20); //Added to prevent busy loop, and get CPU time back when paused!. } /* Check for quit */ For the other, request of framerate is defaults, so this is 30? 60? Is way to tell? CPU on 2 machines is 2.4GHz dual core duo, and 2.0GHz turion. Both have same results of eating all CPU time. Even my machine 2.6GHz dual core it eats up too much CPU time compare to what it was before. I can reduce the load to 20% user-time on my AthlonXP 2GHz. How? set framerate=20 in ~/.warzone2100/config ok, defaults is 60. Something no right then. If framerate = 60, and still eat all CPU time no matter how fast CPU is? The code _works_. If Windows spends all time in warzone2100.exe for no reason, I can't do anything about it. --Dennis signature.asc Description: This is a digitally signed message part. ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays? +patch?
[EMAIL PROTECTED] schreef: Hmm. I like easy approach, which would be, as before. When paused, game loops through this over and over, so it is one big busy loop. So you still need a delay to fix. Why go make complex code, when add 1 call fix issue? This only hits when user paused. The point here is: adding 1 call a thousand times (yes that number is very much exaggerated) isn't a simple solution anymore. So when you find a place where WZ hogs the CPU too much. Simply adding an SDL_Delay call, without considering why the other SDL_Delay call(s) present don't do their job in the first place, is plainly stupid (IMO). Or in other words: don't fight the symptoms but the cause of them. ok, defaults is 60. Something no right then. If framerate = 60, and still eat all CPU time no matter how fast CPU is? First and foremost: how, when and where in warzone does this happen ? The only real reason I can think of that might cause CPU hogging is through another loop than the main loop (possibly a sub-loop of the main loop). The best reason to find out is by running a profile and then find out where WZ spends most of its time when you think it eats too much CPU. -- Giel signature.asc Description: OpenPGP digital signature ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays? +patch?
On Tue, 05 Jun 2007 18:21:43 -0400 Giel van Schijndel [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schreef: Hmm. I like easy approach, which would be, as before. When paused, game loops through this over and over, so it is one big busy loop. So you still need a delay to fix. Why go make complex code, when add 1 call fix issue? This only hits when user paused. The point here is: adding 1 call a thousand times (yes that number is very much exaggerated) isn't a simple solution anymore. So when you find a place where WZ hogs the CPU too much. Simply adding an SDL_Delay call, without considering why the other SDL_Delay call(s) present don't do their job in the first place, is plainly stupid (IMO). Or in other words: don't fight the symptoms but the cause of them. I explain, and you still think it stupid? Maybe I explain this way. There is only 1 SDL_delay call now. That is in main game loop. This suppose to only run 60 (defaults) times per second. So the one and only SDL_delay call will never have ANY effect on 2nd loop. It still is calling 2nd loop 60 calls per second to a busy loop, (when pause is ACTIVE), it should free up CPU time, not run full speed. Yes, I know another way to fix this, but adding SDL_Delay() is easy way to fix this CPU HOGGING ACTION. Understand now? No reason to NOT free CPU up when pause is ACTIVE. -- Click for dental plans with huge savings, top service and coverage http://tagline.hushmail.com/fc/CAaCXv1KbKirK0FaefqE9UZlm6xAuDAD/ ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays? +patch?
Am Mittwoch, 6. Juni 2007 schrieb [EMAIL PROTECTED]: On Tue, 05 Jun 2007 18:21:43 -0400 Giel van Schijndel [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schreef: Hmm. I like easy approach, which would be, as before. When paused, game loops through this over and over, so it is one big busy loop. So you still need a delay to fix. Why go make complex code, when add 1 call fix issue? This only hits when user paused. The point here is: adding 1 call a thousand times (yes that number is very much exaggerated) isn't a simple solution anymore. So when you find a place where WZ hogs the CPU too much. Simply adding an SDL_Delay call, without considering why the other SDL_Delay call(s) present don't do their job in the first place, is plainly stupid (IMO). Or in other words: don't fight the symptoms but the cause of them. I explain, and you still think it stupid? Maybe I explain this way. In case someone is taking the pure words to seriously: Don't. There is only 1 SDL_delay call now. That is in main game loop. This suppose to only run 60 (defaults) times per second. Not gameLoop, but mainLoop. This affects all parts of the game. And: The namings are bad. Of those 2 only mainLoop() really contains a loop, while gameLoop() contains only code which is executed each iteration in a loop (the mainLoop). And if you want a bigger delay, eg. on notebooks, you can always decrease the framerate to something which requires less work by the CPU. So the one and only SDL_delay call will never have ANY effect on 2nd loop. Which one is this 2nd loop? It still is calling 2nd loop 60 calls per second to a busy loop, (when pause is ACTIVE), it should free up CPU time, not run full speed. Depends on what you mean by run full speed. The code leaves everything out which is not required in pause-mode (at least that's the intention). The rest (mainly input/output code) runs with the usual framerate. But since less work is to do, it will idle much more. It would be possible to set a different framerate when entering pause-mode, but I currently don't think this is necessary, as there are probably other ways to free up more time in general and not only in pause-mode. These ways may currently not be in the code, worked out, or even thought of, but then: This is still svn-trunk, not a release. In case we are nearing the release and there are still problems with power-consumption which were not fixed by previous (and more general) changes, I think you should raise your hand again. But for now, I think the situation is acceptable. Yes, I know another way to fix this, but adding SDL_Delay() is easy way to fix this CPU HOGGING ACTION. The easiest way is not necessarily the best way. Understand now? No reason to NOT free CPU up when pause is ACTIVE. I don't think anyone wants to not use less processing power. And neither does anyone want to not idle in pause mode. But how to achieve this, by not adding a few delays here and there, is the interesting question. --Dennis signature.asc Description: This is a digitally signed message part. ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays? +patch?
On Tue, 05 Jun 2007 19:50:04 -0400 Giel van Schijndel [EMAIL PROTECTED] wrote: So the one and only SDL_delay call will never have ANY effect on 2nd loop. This really is the most important info you've given by now. This explains where the problem is, know if only we knew what you mean with 2nd loop, we can look at the problem ourselves. I show patch, maybe it lost. In loop.c, where I add the removed SDL_Delay(). That is 2nd loop I was talk about. Main game loop is one with the only SDL_Delay(). Yes, I know another way to fix this, but ... Please elaborate on that, rather than this one call SDL_Delay solution. It most likely is more interesting. You could just do framerate=1; then on resume framerate = default. But for other reasons, this not best. Pointer will be too slow now. -- Click to get kitchen cabinets direct, wholesale prices, special offer http://tagline.hushmail.com/fc/CAaCXv1SOPpg558L60d60IsrLGI3K85h/ ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
[Warzone-dev] Add back CPU delays?
As is now, WZ eats all CPU time. Even when pause. Can we add the removed SDL_Delay() calls that were take out? Friends can no longer play on laptop very long because of this. This is release builds. -- Click to compare save $100's on medical insurance, free quote http://tagline.hushmail.com/fc/CAaCXv1QS4TPwcxJLaCjSeRxpaP5VU58/ ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Add back CPU delays?
Well, maybe make this configurable. At game start check if someone set niceCPU to 1. If on, set the function pointer shareCPUTime = SDL_Delay; Otherwise set the functionpointer to null. This should be afaik faster than another if(){} in the mainloop. - Kamaze [EMAIL PROTECTED] schrieb: As is now, WZ eats all CPU time. Even when pause. Can we add the removed SDL_Delay() calls that were take out? Friends can no longer play on laptop very long because of this. This is release builds. -- Click to compare save $100's on medical insurance, free quote http://tagline.hushmail.com/fc/CAaCXv1QS4TPwcxJLaCjSeRxpaP5VU58/ ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev