Deployed New SG Arena Loading system!!

devcexx

Developer
Developer
Mar 5, 2019
1
14
3
Hi :D.

You won't probably know me. I'm am @devcexx, just a developer that eventually do things to BackPlay. Today I'm here to present you the new arena loading system that is now on BackPlay.

Remember the "The map is loading" message that appears every time a SG arena starts? Well, so you won't see it anymore :3. A week ago, we implemented a new arena loading system that allows us to load any arena in less than a second, without delaying the beginning of the match. This new way of loading the arenas is made by me, for my old Minecraft Server, OpenGamingMC, which is now closed, but @lllibailll and I are agree to move some technology we used there to BackPlay, to improve your experience on the server.

You probably won't see much difference between the old system and the new one, except for the few seconds that the arenas used to take to start, but it is a huge difference for us. Briefly, it allow us to improve the performance on loading maps, reduce the disk usage for storing them, reduce the memory usage of the arenas while playing them, and even share the arenas between servers, so the same could be played in different servers at once, without needing to load it more than once. All these improvements can be easily translated to a more ease to us to add new maps, and the ability to open more survival games servers, without needing more hardware resources.

Although this new system has been tested in a previous server for a while, that does not mean is free of bugs. We would appreciate you to report any bug you see regarding to this new arena loading way (chunks that are not visible for some reason, people that fall down off the map or are not teleported, etc). We are already conscious about some huge bugs on Solar Frost and Moonbase 9, and we are working for fix them.

How does it work? (just for nerds)

Minecraft is a piece of shit. I mean, internally, as how is coded. One of the more critical performance tasks in Minecraft is the world loading, and it's actually done really wrong: it is way slow. This is mainly the problem we found the server administrators for deploying minigames where worlds are loaded and unloaded dynamically, as is the case of SG. Also, the problem of the worlds is that are contained in folders that could be really big on disk, and the arena configuration (spawns, chest config, etc) are usually stored out of it, increasing the difficulty to transport them to other servers.

Our solution was to build a custom world storing format, that allows to save the minimum information required to save SG-like arenas. This format is based on a single file that contains both the details of the map (name, authors, spawn points, boundaries, etc), plus the map itself compressed using LZ4. How the map data is stored in the file is also important, because Minecraft usually saves the world data using NBT, that is * really * slow for decoding and loading into memory. We decided to use a binary format sorted in a way that chunks can be loaded and seeked really fast.

Since the LZ4 compression is powerful but fast, huge SG maps can be loaded from that files in less than a second. But could we do better? And how if the same maps are loaded in different servers at once? Does it worth to have the same data loaded into the RAM (which is quite expensive) more than once? Well the answer is no.

Thankfully, POSIX-compliant systems (such as Linux and macOS), has a feature called "shared memory". This allow as to share a memory region between two or more processes, where changes are seen among them. So, what we did is to code an utility to preload the maps from the files to this shared memory regions, decompressing them and keeping in a way where the SG servers can easily "attach" to this memory and see their content, and using a per-process cache to store the little modifications the SG maps can suffer while playing. With a little modifications on our Spigot version, we're now able to load a 500 MiB map into the memory, keep it there, and connect the servers to it when they need that map, without using more than the original size of the map. This is because the map loading is now near-instantly: because the maps are already loaded somewhere in our machine.

This might be easy at first glance, but this system took a lot of time of coding and testing, and we expect that you appreciate it and enjoy it as much as we do :D.
 
Reactions: xCamper and ImBit

Discord server

Latest resources

Latest posts

Staff online

Forum statistics

Threads
4,427
Messages
13,717
Members
3,379
Latest member
RODRINEVERDIES