We're tired of endless grinding, mini-maps and predetermined fun. That's why we intend to redefine MMOs and empower our players to find their own destiny, write their own stories, and leave a lasting impression on the world they helped us create. How will you impact it and what will your legacy be?
[img]https://steamcdn-a.akamaihd.net/steamcommunity/public/images/clans/10223679/39ef2384a3e4af51ef1ac004b7d1e498d3be685a.png[/img]
Greetings Travellers,
For my last Tech Tuesday, I described how we are going to save all of the offline ships in the world and then delete them all in a subsequent update.
Well, it turns out that as of late the PvE deployment, in particular, has been really struggling with the sheer amount of ships in the world so strange bugs such as ships not appearing have started to happen much more frequently.
Due to this, we've decided to bring forward the work of deleting all of the offline ships and respawning them when registered players login. I completed the work to delete offline ships today and the results are even better than we expected, so here are some graphs!
First, here's the graph showing the number of entities in the world:
[img]https://www.worldsadrift.com/wp-content/uploads/2019/04/1-1024x436.png[/img]
It peaks at 3 million entities as it takes a while for SpatialOS to load the massive snapshot. Over the course of an hour, we save all of the ships and then delete them hence the linear drop in the number of entities. We end up at just 43 thousand entities, an absolutely massive reduction.
This has had a huge impact on the CPU usages of our servers!
[img]https://www.worldsadrift.com/wp-content/uploads/2019/04/2-1024x434.png[/img]
Firstly, the resting CPU has decreased pretty much linearly with the reduction in the number of entities. This is surprising to us because profiling showed that the offline ships weren't directly doing a lot of work. What we think is happening is that they were indirectly causing everything to be more expensive just by being in lists of things to process as well as making garbage collection more expensive.
The other thing to note is that the CPU spikes from taking snapshots are effectively gone. We suspected that these spikes may have been translating to large in-game lag spikes, so fingers crossed there will be a big improvement there.
There is something quite mysterious going on here though. About 10 minutes after the last ship is destroyed, CPU usage shoots up temporarily. We think this may be explained by the next graph - memory usage:
[img]https://www.worldsadrift.com/wp-content/uploads/2019/04/3-1024x436.png[/img]
Strangely, memory usage initially falls, but then begins to increase again as more and more ships get deleted. Then, once it reaches its previous peak we get the huge CPU spike and the memory usage drops. My theory is that the heap is massively fragmented at that point and it reaches a threshold at which the Java Virtual Machine decides to defragment the memory. I would expect to see garbage collection CPU usage increase at that point, but it doesn't, however, that could just be due to profiling only measuring the sweep phase but not the defrag phase of garbage collection.
[img]https://www.worldsadrift.com/wp-content/uploads/2019/04/4-1024x440.png[/img]
So what does this mean for latency? Here's a graph of the current PvE deployment:
[img]https://www.worldsadrift.com/wp-content/uploads/2019/04/5-1024x401.png[/img]
You can ignore the green line, which is player latency, but the next line below shows the latency of the worst server. It's 180ms which is pretty crazy considering the machines are located in the same data center! Here's the new deployment with ships being removed:
[img]https://www.worldsadrift.com/wp-content/uploads/2019/04/6-1024x404.png[/img]
Granted there are no actual players on this deployment, but you can actually see the physics server latency dropping all the way down to 50ms as the ships are removed, and no sign of that enormous CPU spike! It's going to be really interesting to see how this change impacts player latency.
Overall we expect this should fix a lot of technical issues with the game, as well as having other cool benefits in terms of the new features based on the ship saving (blueprints) and other random things like it only takes 2 minutes to clean the world snapshot now so maintenance should also be much faster!
Fly safe!
Dave
(Screenshot by Spacebar Jazz on the Worlds Adrift Discord (https://discord.gg/worldsadrift))