War2.ru Slogan
News: All hail our wise & benevolent admins!


Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Welcome to the forums! We're glad to have you here! :) You can register your account here, then feel free to introduce yourself in the Server.War2.ru board & let us know who you are on the server.

CPU saver plugin 127  4

Ogre Posts: 1472 Karma: +80/-1 *******

Lambchops

  • Ogre
  • *******
  • *
  • Posts: 1472
    • View Profile
CPU saver plugin
« on: July 10, 2019, 12:44:17 PM »
iL asked me to have a look at this so I made one.

Seems to work ok. My CPU usage shows 0 most of the time.

Have tried it in a couple of games with no lag.

Please test  :)


-- edit --

Have made this 2 plugins. There is 'C' for Channel and 'G' for Game.

You can use either one or both of them. If anyone has problems using this in-game, they can use the 'C' only and give their CPU a rest between games, although I am having no problems using it.

Note: The "Game" starts in the pre-game lobby, everything else is "Channel".



Grunt Posts: 51 Karma: +13/-0 Chicken ***

fois

  • Grunt
  • ***
  • *
  • Posts: 51
  • Chicken
    • View Profile
Re: CPU saver plugin
« Reply #1 on: July 10, 2019, 05:59:08 PM »
cnc-ddraw can do it as well :)

Not sure how you're doing it, but make sure you take advantage of timeBeginPeriod and timeEndPeriod otherwise a sleep call will take at least 15ms on the default resolution which is dangerously close to the limt. The game runs at 60 fps (giving you only 16.6ms time for a frame), that means there would only be 1.6ms left for the rendering/game logic per frame (Could cause lag in online games on lower end hardware and/or notebooks)
Ogre Posts: 1472 Karma: +80/-1 *******

Lambchops

  • Ogre
  • *******
  • *
  • Posts: 1472
    • View Profile
Re: CPU saver plugin
« Reply #2 on: July 11, 2019, 12:58:15 AM »
Not sure how you're doing it, but make sure you take advantage of timeBeginPeriod and timeEndPeriod otherwise a sleep call will take at least 15ms on the default resolution which is dangerously close to the limt. The game runs at 60 fps (giving you only 16.6ms time for a frame), that means there would only be 1.6ms left for the rendering/game logic per frame (Could cause lag in online games on lower end hardware and/or notebooks)

I have implimented it to only sleep when the message queue is empty, this mimics the normal windows multitasking behaviour. So when the process is busy it will not sleep at all, so there is no set amount of sleep calls per frame.

timeBeginPeriod and timeEndPeriod are global settings that effect the entire OS and all processes, reducing these on a struggling system would probably decrease performance overall.

So far it appears to be working correctly, although I only spent a couple of hours doing it last night, so please test on any low-end gear you have available and let me know if there are any problems.

Ogre Posts: 1472 Karma: +80/-1 *******

Lambchops

  • Ogre
  • *******
  • *
  • Posts: 1472
    • View Profile
Re: CPU saver plugin
« Reply #3 on: July 11, 2019, 03:22:18 AM »
Ok have split this into 2 plugins .... 1 for channel, 1 for game (see top post)

I have also changed it to count the number of triggers before it sleeps.

When I tried 500 ( sleeps 1 time out of 500 ) in-game CPU went up to about 40%, so I set it back at 200 and CPU usage is back at 0. Seems to work well.
Administrator Ogre Posts: 1394 Karma: +135/-9 *****

iL

  • Administrator
  • Ogre
  • *****
  • *
  • Posts: 1394
    • View Profile
*

iL

Re: CPU saver plugin
« Reply #4 on: July 11, 2019, 05:40:21 AM »
I have also changed it to count the number of triggers before it sleeps.

When I tried 500 ( sleeps 1 time out of 500 ) in-game CPU went up to about 40%, so I set it back at 200 and CPU usage is back at 0. Seems to work well.
So, can that "magic" numbers depend on the computer performance?
I don't like such way as it should be changed for very new/very old computers as i understand.

Need to test that properly before releasing...