NokiMo
naelstrof
naelstrof

patreon


Post-Optimization Status

After some complaints I realized pretty quickly that the game should probably run on crappy hardware, so I churned a couple days of optimizing.

I didn't keep track of hard numbers, but I'll list my major findings and roughly how much time savings there is.

I got Unity running on my Linux X220 Thinkpad to find that it runs at a molasses speed of around 2-3fps. I switched the rendering mode from Deferred to Forward, and that bumped the frame-rate up to a blazing 120fps! Here is an image with profiling history for proof.

During profiling, I realized jiggle physics weren't actually getting disabled with LOD. I also found they are fairly expensive. I set up a kobold jiggle budget, saving the CPU from getting overloaded with countless kobolds on-screen. With the current budget I never let breast physics take more than a half a millisecond per frame.

Finally to deal with stuttering, I found the culprit was the garbage collector. Often taking over 100ms to clean up code allocations. I couldn't think of any allocations I was doing to cause that, and it turns out I wasn't actually.

C# has a function for floats called Float.ToString(), and it apparently causes a series of allocations every time you call it. What's worse is if you call Float.ToString("00") which formats the float to a time-like format. I was calling it every frame to update the time text on-screen. I found out EVERY TIME I called ToString("00") it threw 1kb of allocations to the garbage collector.

Over 1 second of time it would allocate over 300kb of data! After a couple seconds it would force the GC to kick in and find references to megabytes of useless string data which would hitch the game for over 100ms.

After switching it out for some string builder functions (and also refraining from calling it every frame), the GC costs so little it doesn't even show up in profiling!

Runs at a consistent 300-ish fps on my desktop with high settings, and 120ish on my laptop with low settings.

That reminds me, would anyone be interested in a Linux build?


Comments

Sweet that's all I needed. I'll make sure there's a Linux build for the next demo.

Naelstrof


Related Creators