Performance update! (Demo / GMS 2.3 source)


It's finally come to my attention what the weird performance issues have been caused by, so this update should address that. This update only affects the GMS 2.3 source file and the demo. All changes are listed below, so that you can implement them in your own projects easily.


Sleep Margin / ambient CPU use

The Windows 10 "2004" update adds more aggressive power management options, and since the game had a sleep margin of 1 ms (meaning that it would sleep if there were more than 1 millisecond to the next game frame), it would spend most of its time sleeping and was run as a background app (making it get choppy performance and overall too little CPU time). This issue supposedly applies to a lot of games, so if you've  experienced random performance issues lately, blame Microsoft.

This issue was worked around by setting the project's sleep margin to 20, which means it never sleeps (since there's 16 ms between frames if the game runs in 60fps) and spends any excess time in a busy loop. The game will now use a lot more CPU power than necessary, but run smoothly.

To get the benefits of this change in your existing project, you can just go to Game Options --> Windows --> General and set the sleep margin to an appropriate value. 10 was the old default value, but it was silently changed to 1 at some point and it's likely it is at 1 in your copy of the project.


Choppy Animations

Zombies now only update their animation every 4 frames, since the skeleton coordinate updates used a lot of CPU power. This is implemented with a simple counter which is incremented each step (and reset to zero if it's >= 4), and a check around every skelani_set_animation / skelani_update_deltas call in esm_zombie to only run these functions if the counter is zero.


Faster Player Collisions

A new function was added to do a faster, hardcoded version of the pilloid collision check (see below). slope_hit_pilloid was duplicated to a new slope_hit_pilloid_cheap that used this new cheap function, and all player logic was updated to use the cheap versions instead. (You can find all these checks if you do a project-wide search for "pilloid(". This makes player collisions a bit less refined, especially when colliding with horizontal cylinders, but it's almost 8 times faster than the loop that is used for a full pilloid collision check. (Enemies already use an even simpler terrain collision check that only checks a single point)


Files

Demo (Legacy) 5 MB
Oct 18, 2020
Source Code (GMS2.3) (version 2) 8 MB
Oct 18, 2020

Get MariaEngine 64 + Open World Edition

Buy Now$14.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.