Game version: master
Operating system: gentoo linux
Tiles or curses: curses
Mods active: filthy clothes, disable npc needs, craftable gun pack, bright nights
No, there's no rain or snow, i don't provide any input, and don't see any animations anywhere, so i expect it to idle, but it actively eats my battery even more than a web browser (sic!) instead.
On my system it uses about 3.4 to 4.4 percent of the CPU when sitting idle. This system is a dual core system with hyper-threading. Its pretty modest for modern systems and is from 2013
I'm OSX, curses version, currently idling on a raining screen (drizzle to be precise) and it takes between 2.8-3.7% CPU @ macbook pro early 2015.
*nix curses versions have comparatively cheap redraw. It's tiles and win-anything versions that are slow.
It seems that the game forces redraw if animations are enabled, even if there is nothing to redraw.
@Coolthulhu
Yep thats it game drops to 0% when I disable animations and nothing is going on.
Close?
This:
It seems that the game forces redraw if animations are enabled, even if
there is nothing to redraw
Is a valid issue, can stay open to cover that.
Issue is not animations? Is the game always redrawing? Is there a way we can check for snowing or smoke?
I looked into this a while back (the idle CPU usage has been driving me up a wall), and IIRC there are really multiple issues here:
First, the game redraws even when there are no animations present onscreen and even if animations are disabled. The game should probably be completely asleep unless the kernel tells it that it actually needs to do something. Right now it's got timeouts various places and is waking up to Do Things. If playing audio, IIRC it needs to do some realtime work with sound, but Cataclysm appears to have multiple threads today, and even if not, my understanding from @kevingranade's comment in #16258 is that it should have a sound thread to permit to make blocking calls without preventing the audio system from working.
Second, the game recomputes world state during redraws. That is, it recomputes world state, lighting, etc, even when the only thing it is doing is drawing rain/snow, though it is impossible for any world state to change unless the player presses a key -- Cataclysm is entirely turn-based. Now, there's something to be said for simplicity, and maybe the right fix here is really to make the world state computation cheaper and it's nice not to "mask" the costs there, but as a turn-based game, most of the world state is not changing 30 times a second or whatnot from the user hitting a key. It'd be possible, at the cost of a some complexity for the very few animations that exist today, to just "register" that an animation is occurring and have a very lightweight redraw that just draws animated rain/snow, cosmetic stuff that has nothing to do with the world state, and to never run the world state recomputation then.
Third, there's a surprisingly high amount of cost involved in the redraws themselves. This happens even out of the game world; sitting on the title screen, for example, Cataclysm uses a surprising amount of CPU time, and I was idly poking at that today (lots of string allocations/deallocations in code related to terminal display that wind up adding up to a surprising amount of CPU time).
Fourth, it might be possible to make the game world state computation cheaper. Hypothetically, if it were so cheap to compute world state that the cost was simply irrelevant, it wouldn't matter if it were happening every game frame while the game is idle. I'm less-interested in banging on this, because while it'd always be great to have fixes here, this is always a moving target; if someone adds a new feature, costs maybe show up, and it's hard to have one-off fixes permanently resolve this. Plus, @kevingranade seems to already be pretty active on this front; I see work on stuff like caching various things.
Reducing CPU usage is desirable even if a computer can "handle" the CPU hit, as for battery-powered devices (laptops, especially users running the Android build on mobile devices, where battery is always at a premium), CPU usage is equivalent to battery usage. As a turn-based game, Cataclysm can have really low potential power consumption, and be really well-suited to those platforms, but as of today, some technical limitations keep it from being that really-low-power-consumption game that it could be.
The cycling occurs in game::get_player_input
that uses quite a lot of various timeouts.
As a side note, with Mouse Edge Scroll enabled, the timeouts for get_player_input()
can be much shorter than than the usual 300ms under some circumstances. Since that setting currently defaults to enabled, it's probably going to exacerbate any of the problems here whenever edge scroll is allowed ("look around" invocations, overmap, aiming).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed due to lack of activity. This does not mean that we do not value the issue. Feel free to request that it be re-opened if you are going to actively work on it
It still does something, but much less than before.
Curiously, cataclysm stops its mindless CPU hogging routine if you Esc
ape into the menu, open an i
nventory, /
AIM or otherwise make it wait for your input at anything but the main game screen.
@l29ah Yeah, that's because when it's showing the game screen, it's constantly drawing N FPS. While those menus are up, it doesn't. What's worse, each time it draws a frame, it recomputes the game state -- lighting and so forth.
It'd be possible to change it to only redraw when a resize/repaint/keypress happens (plus a few cases where multiple redraws happen without keypress, like crafting), as long as animations aren't happening. It'd also be possible, at the cost of some complexity, to do the world state computation and record that, and just figure out where an animation needs to happen and then just have a lightweight loop that draws the animations.
I talk about that in my above comment.
Most helpful comment
I looked into this a while back (the idle CPU usage has been driving me up a wall), and IIRC there are really multiple issues here:
First, the game redraws even when there are no animations present onscreen and even if animations are disabled. The game should probably be completely asleep unless the kernel tells it that it actually needs to do something. Right now it's got timeouts various places and is waking up to Do Things. If playing audio, IIRC it needs to do some realtime work with sound, but Cataclysm appears to have multiple threads today, and even if not, my understanding from @kevingranade's comment in #16258 is that it should have a sound thread to permit to make blocking calls without preventing the audio system from working.
Second, the game recomputes world state during redraws. That is, it recomputes world state, lighting, etc, even when the only thing it is doing is drawing rain/snow, though it is impossible for any world state to change unless the player presses a key -- Cataclysm is entirely turn-based. Now, there's something to be said for simplicity, and maybe the right fix here is really to make the world state computation cheaper and it's nice not to "mask" the costs there, but as a turn-based game, most of the world state is not changing 30 times a second or whatnot from the user hitting a key. It'd be possible, at the cost of a some complexity for the very few animations that exist today, to just "register" that an animation is occurring and have a very lightweight redraw that just draws animated rain/snow, cosmetic stuff that has nothing to do with the world state, and to never run the world state recomputation then.
Third, there's a surprisingly high amount of cost involved in the redraws themselves. This happens even out of the game world; sitting on the title screen, for example, Cataclysm uses a surprising amount of CPU time, and I was idly poking at that today (lots of string allocations/deallocations in code related to terminal display that wind up adding up to a surprising amount of CPU time).
Fourth, it might be possible to make the game world state computation cheaper. Hypothetically, if it were so cheap to compute world state that the cost was simply irrelevant, it wouldn't matter if it were happening every game frame while the game is idle. I'm less-interested in banging on this, because while it'd always be great to have fixes here, this is always a moving target; if someone adds a new feature, costs maybe show up, and it's hard to have one-off fixes permanently resolve this. Plus, @kevingranade seems to already be pretty active on this front; I see work on stuff like caching various things.
Reducing CPU usage is desirable even if a computer can "handle" the CPU hit, as for battery-powered devices (laptops, especially users running the Android build on mobile devices, where battery is always at a premium), CPU usage is equivalent to battery usage. As a turn-based game, Cataclysm can have really low potential power consumption, and be really well-suited to those platforms, but as of today, some technical limitations keep it from being that really-low-power-consumption game that it could be.