I recently joined an MP game hosted where the players were complaining of poor performance, and I identified some issues and fixed them.
These performance upgrades mainly effect big MP maps, but because SP runs on an internal server SP get some small benefit.
The two issues were to do with unloading chunks and autosaving. The server was checking every chunk every tick for every player. With 10k+ chunks loaded and 5 players running around this server chunk unloading was taking 200+ms every ticks! I've since changed it so that the server only checks a max 200 chunks for unloading every tick, and this number goes down if there are more players on the server. This check is effectively instant now.
The second issue was with autosaving. For whatever reason it was taking 5 seconds to save lot data on their machine. On my test-big-map (16x16km) I was getting 500ms to save lot data. I have since multithreaded lot serialisation, reducing the save time to 100ms on my 24-thread machine, and moved the writing-to-disc stuff to a dedicated thread, knocking off another 50ms for a total speedup of 10x. Lot serialisation also occurs when a player logs into a server so this should also reduce/remove that lag spike.
VERSION 1.8.1 - 04/08/2022
- [Performance] - vtserver: Lot serialisation is multithreaded. Reduces lag when autosaving, player log on and player log off.
- [Performance] - vtserver: Lot saving to disc is done in a dedicated thread. Removes ~50ms of lag when saving on an SSD.
- [Performance] - vtserver: Chunk unloading now only checks parts of the chunk array, rather than the whole array. Fixes constant lag in big MP maps.
Changed files in this update