Grid Sage Forums

Grid Sage Forums

  • April 30, 2024, 01:29:22 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

LINKS: Website | Steam | Wiki

Author Topic: High CPU Use  (Read 3931 times)

nsg21

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 48
    • View Profile
High CPU Use
« on: May 23, 2015, 03:15:15 PM »

Cogmind is eating CPU cycles like peanuts. My laptop overheats to the point that it is uncomfortable to hold on my laps and the battery lasts for less than 40 minutes. As an added bonus, I cannot see the battery meter in fullscreen mode so that when it suddenly quits on me it is a surprise.

I think it just needs an idle() call in the mainloop while waiting for keyboard to help this. What is so important that a turn-based based game just has to calculate at max processor speed in between user inputs?

Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4318
    • View Profile
    • Cogmind
Re: High CPU Use
« Reply #1 on: May 24, 2015, 03:32:54 AM »

It sounds like you have a pretty old laptop? Cogmind is not too demanding (when I play it uses literally 3% of my CPU, which is about 3 years old), but it is run entirely on your CPU (no GPU processing). The game idles as long as it's hitting 60 FPS, because the game is capped at that speed by default. If it's eating up cycles then you must be getting under 60 FPS on your machine.

Aside from the obvious running in windowed mode and/or making the view smaller by using a smaller font and/or map, one way to reduce the load is to cap the FPS at something below 60 to give your CPU a breather.

This option is available directly in /user/cogmind.cfg towards the bottom:
Code: [Select]
fpsCap=60Try some different values like 50, 40, or 30 if you it doesn't bother you,

Although Cogmind is turn-based, it still has to render the UI and anything that might be animated, and it does that at 60 FPS.

Let me know if that helps!

(I'm moving this thread to the Support board.)
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

infectedm

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 27
    • View Profile
Re: High CPU Use
« Reply #2 on: May 24, 2015, 08:03:42 AM »

I have a fairly new laptop (Samsung NP870Z5E) and even for me the CPU usage seems a little bit high.

Playing the game: 10-14% cpu usage
Game in background (windowed mode): 10-14% cpu usage
Minimized (windowed mode): 8% cpu usage
Alt-tabbed out of fullscreen mode: 8% cpu usage

Hyperthreading is disabled to get better measures.
I have also tried assigning the game to the dedicated graphics card just to be sure - no effect on cpu usage.
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4318
    • View Profile
    • Cogmind
Re: High CPU Use
« Reply #3 on: May 24, 2015, 08:29:54 AM »

10-14% for while playing isn't too bad considering it's run 100% by your CPU (both logic and software graphics)--the engine doesn't care about the video card. It will naturally be higher than pretty much any other major indie game out there because they all do their heavy lifting on the GPU.

Based on what you say I can consider the possibility of completely pausing the game while not in focus. Do you guys think that makes sense?
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

infectedm

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 27
    • View Profile
Re: High CPU Use
« Reply #4 on: May 24, 2015, 08:47:30 AM »

While I have no knowledge about the game engine, I would think that if there is nothing happening (no user input), the cpu usage should drop to near 0%. Except for the occasional flickering, the output doesn't need to be redrawn at all when the user isn't pressing any keys or moving the mouse.
Maybe there is an easy way to determine if a redraw is really necessary and simply reuse the last rendered frame if not?
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4318
    • View Profile
    • Cogmind
Re: High CPU Use
« Reply #5 on: May 24, 2015, 09:02:27 AM »

While I have no knowledge about the game engine, I would think that if there is nothing happening (no user input), the cpu usage should drop to near 0%.
I always thought it was "near zero" because it hangs around 1-3% for me when minimized ;), and I don't exactly have a new computer (dev machine is a mid-range ASUS laptop from 2012).

Except for the occasional flickering, the output doesn't need to be redrawn at all when the user isn't pressing any keys or moving the mouse.
Maybe there is an easy way to determine if a redraw is really necessary and simply reuse the last rendered frame if not?
The game does use a bit of optimization to not do excessive repeat work. I built that part literally years ago so I... can't really discuss details I don't remember ;).

It could possibly be more optimized. I'm still curious how the FPS cap works for nsg21.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

infectedm

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 27
    • View Profile
Re: High CPU Use
« Reply #6 on: May 24, 2015, 09:48:05 AM »

I tried playing around with the fps cap myself and it seems to influence the cpu usage in a very linear manner.
My previous measures were not correct because the energy saving power profile was active which lowers cpu frequency and therefore causes higher cpu usage.

Current results (now with high performance power profile):

1 FPS => 0.3%
30 FPS => 4%
60 FPS => 8%
120 FPS => 18%
240 FPS => 25% (single core maxed out)
Logged

nsg21

  • Derelict
  • **
  • Supported Cogmind Alpha Access 2015-2017 (Prime Tier)
  • Posts: 48
    • View Profile
Re: High CPU Use
« Reply #7 on: May 24, 2015, 01:11:42 PM »

Here are my results:

fpsCap=60
windowed 50%
minimized 17-20%

fpsCap=20
windowed 30%
minimized 10%

fpsCap=5
windowed 8%
minimized 4%

At fpsCAP=20 degradation in quality drop of visuals is noticeable, but not too bad, at 5 it is getting really jerky.
Both cores are occupied for 60 and 20, only one core at 5.

I will play at fps=20 and see how it feels.



Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4318
    • View Profile
    • Cogmind
Re: High CPU Use
« Reply #8 on: May 24, 2015, 09:55:17 PM »

Thanks, guys, and @nsg21: At 5 it gets "really jerky"? I would think so, that's pretty darn low! I haven't tried low capping myself, but I imagine you'd want at least 20-30 so the effects retain a minimal appeal.

You're playing on a Core2 Duo?

Window size also plays a rather large part in determining CPU use, since most of it goes to rendering (unless you're in the Factory, where moving a lot will ramp up the AI processing since the maps are so huge).
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon