patchWarzone 2100 Project - Patches: patch #973, Fixes CPU cycle wasting on pause

Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

patch #973: Fixes CPU cycle wasting on pause

Submitted by:  Bugs Buggy <buginator>
Submitted on:  Fri Feb 8 04:41:50 2008  
Category: FixPriority: 9 - Immediate
Status: NonePrivacy: Public
Assigned to: Dennis Schridde <devurandom>Open/Closed: Open
Planned Release: 2.1

Mon Sep 22 03:46:25 2008, comment #5:

What do you think, should we add this or not?

I know laptop users are still complaining about high CPU usage when the game is paused, and adding a SDL_Delay() to the pause menu code is a fair enough compromise.

Bugs Buggy <buginator>
Project Administrator
Fri Mar 7 13:10:46 2008, comment #4:

My assumption for the different result of limiting the framerate and adding an extra delay is, that framerate limiting happens somewhere between input handling and drawing, which will probably result in the sloppy animation you mentioned.

Dennis Schridde <devurandom>
Project AdministratorIn charge of this item.
Fri Mar 7 13:08:06 2008, SVN revision 3938:

Part of patch #973: Don't update athmosphere particles when paused.

(Browse SVN revision 3938)

Dennis Schridde <devurandom>
Project AdministratorIn charge of this item.
Fri Feb 8 18:18:52 2008, comment #2:

I was trying different values to the framerate limiter, to match the gains I got by adding another SDL_Delay() call. The lower the framerate limiter is set, the more 'jerky' everything got. I had to go below 10 to achieve the same results. With it at 10, it responds very poorly.

Checking results in the profiler showed pretty much that after atmos.c, the next ones that ate up most of the CPU time was the drawing code. With that code (mostly) disabled, besides looking like crap if there is text still being displayed, and the menu issues, it still didn't achive a good result in lowering CPU time.

I will do some more tests though.

Bugs Buggy <buginator>
Project Administrator
Fri Feb 8 11:11:36 2008, comment #1:

Inserting any SDL_Delay() should have exactly the same effect as decreasing the framerate... The delay just happens in another position of the mainloop.
A delay of 30 is a FPS of ~30, so maybe we are just doing the framerate enforcement in the wrong location? Have you tried moving that, to reduce the effects it maybe has on graphics update, etc?

Dennis Schridde <devurandom>
Project AdministratorIn charge of this item.
Fri Feb 8 04:41:50 2008, original submission:

This patch is needed mostly for notebook users, since wasting CPU cycles eats up battery life for no good reason, but it also is good for everyone else.

Inline profiling results:

atmos.c is still a massive CPU hog
This is mainly because of:

When paused, it still executes that horrible loop.
When condition for paused is check, at least we don't execute that loop anymore.
This resulted in limited savings for CPU cycles though.

However, we are still executing the mainloop & gameloop @ whatever framelimiter is set to when paused.

I think it is set to 60 for default.

Even by not doing many of the drawing routines, we are still wasting CPU cycles
when paused. I pretty much stopped all drawing routines when paused, and it didn't help much either, which does make sense when you look at how this loop operates, and just what the lone
SDL_Delay() is used for.

Tried to set the framelimiter to a lower value when paused, and restore it when unpaused, that resulted in choppy menu animation, and overall was not satisfied with the results at all.

Next added a SDL_Delay(30) call when the pause menu is up. This worked nicely, and is a huge improvement.

I also modified display3d.c to not execute some routines when paused, and came across this:
/* This is done here as effects can light the terrain - pause mode problems though */

I didn't notice a problem when I did:
if ( !gamePaused() ) // Don't bother drawing/updating when paused!

Can someone shed some light on what the issue is(was?)? I did NOT include that in this patch.

Bugs Buggy <buginator>
Project Administrator


Attached Files
file #3766:  pausefix.patch added by buginator (1kB - text/x-diff)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by devurandom (Posted a comment)
  • -unavailable- added by buginator (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri Feb 8 11:11:36 2008devurandomAssigned toNone=>devurandom
      Planned ReleaseNone=>2.1
    Fri Feb 8 04:41:50 2008buginatorAttached File-=>Added pausefix.patch, #3766
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup