cboe icon indicating copy to clipboard operation
cboe copied to clipboard

dialogxml is too slow/cpu-hungry

Open x-qq opened this issue 6 years ago • 6 comments

Currently, simply having a dialogxml-backed window on screen consumes almost 100% of a powerful CPU core.

dialogxml_too_slow

For reference, this is Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz.

This is not a reasonable CPU load for some static text and pictures, so I think dialogxml requires some optimization.

x-qq avatar Jan 08 '20 15:01 x-qq

Hmm. I can guess that maybe part of the cause is that it's redoing the text layout (wrapping) every frame? (I don't know whether it is doing that though.)

CelticMinstrel avatar Jan 09 '20 13:01 CelticMinstrel

callgrind shows this

out

x-qq avatar Jan 09 '20 14:01 x-qq

Can we change OpenBoE to only use CPU when user input is received? Just stop the process and children until mouse or keyboard event goes to it?

clort81 avatar Jan 09 '20 18:01 clort81

callgrind shows this

Not quite certain but it seems like that might support my theory, as there seems to be a lot of green around the win_draw_string area.

Can we change OpenBoE to only use CPU when user input is received? Just stop the process and children until mouse or keyboard event goes to it?

I think it might be possible, since the game is turn-based. The only possible complication would be the animations that should continue to work even while time isn't passing.

CelticMinstrel avatar Jan 11 '20 01:01 CelticMinstrel

CPU load was reduced in 1fcbd8e922c59a8f4a58e4c16a4c5b966a87091d. But we still need some form of caching, because currently widgets do too much during redraw.

x-qq avatar Jan 21 '20 13:01 x-qq

Updated callgrind:

out svg

x-qq avatar Jan 21 '20 17:01 x-qq