Horse breeds and hitching posts, client and server optimizations and more
Server Physics Optimization
We've been plagued by a lot of performance problems on the server. After careful analysis we found and fixed these main causes:
This all sounds very technical, but at the end of the day what matters is that the server should run a lot faster now.
- Collider batching is no longer in use, but the code to check whether or not a collider is batched was still running and was extremely slow since there are now hundreds of individual colliders in any area of the map instead of the previous handful of batched colliders
- Optimized code to get entities in a radius
- Optimized code to look up entities from game objects or colliders
- Optimized physics transform sync by batching FixedUpdate calls on identical components instead of executing them in a random order
- Optimized player server updates by only doing a single transform synchronization for all players on a server
Distance Tree Memory Optimization
I changed the way far away trees are networked to the client. Usually all entities have their own game object, but since game objects use a lot of memory and trees in the distance cannot be interacted with and therefore don't need colliders or scripts on the client we now instead network those tree with a low level message that just contains their type, position and size and then directly feed that into the tree billboard renderer. This saves 300MB of RAM on a 4k map.
Client Inventory Optimization
Alistair noticed a performance regression in the crafting UI from the engine updates that was triggered whenever the inventory was refreshed, which can happen a lot during a fight. I changed this so the crafting UI no longer refreshes in the background even when it's invisible and instead postpones this to the next time it becomes visible. The code was already written in a way that made it look like that was the case, but due to a different performance issue with Unity's UI we have to always keep the UI enabled but invisible instead of actually disabling the game objects, which caused the UI refresh to be executed no matter whether or not the crafting UI was visible.
Server Packet Optimization
When profiling the server this week I noticed that getting the current machine time appears to have gotten slower by an order of magnitude with one of the recent engine updates. This was most likely to fix a bug on their end, so we don't expect things to go back to the old way. The problem with this was that we need the machine time for essentially every packet, so we had to replace it with a faster alternative that is still highly accurate (double precision) after days of continuous uptime. This fix made server packet handling significantly faster across the board, which is particularly noticeable on high population servers.
Monument Memory Optimization
Spawning in monuments requires many large assets to be loaded and processed when loading into a server. These assets contain all of the objects that need to be placed and the terrain that they need to be placed on. However, after the map is fully loaded, they are no longer required and can be unloaded from memory. It took a few attempts to successfully unload them without causing engine crashes or other errors but we found a way to sidestep those issues. From our testing this saves about 800MB of RAM.
When I first added the lasers to the auto turrets they didn't seem to have much of an impact on client performance. But then zergs would put 87 into their base and anyone within network range would run at 30fps. I've fixed this issue so now laser updates are throttled to a small percentage of overall frame time. In the worst case example the dots themselves will look like they are updating at a lower framerate rather than your entire client. You should also notice minor fps improvements around the oil rig and compound where other groups of lasers were present.
This does speak to the fact that autoturrets need to be made to use electricity very soon, so please enjoy this last wipe of turret spam.
The horse hitching post is now ingame and is available as a default blueprint.
Dismounting your horse infront of one of these will allow it to feed itself over time so that it does not decay or disappear. One pumpkin will stop horse decay for 1 hour. You can park 2 horses at each hitching post. Oh and we've doubled the number of horses, so a 4k server will see 64. Giddy up!
Taylor Reynolds has completed a new, updated, high definition horse model and a bunch of breeds and Matt Isaac has updated the hair to be less Janky. These are now implemented and should look much, much better than the 5 year old model we used to have.
There was a bug in unity where setting the breaking amount or speed of the wheels on a vehicle would wake the vehicle up, even if the value was the same as last time, or even if it were 0. This meant that minicopters never went to sleep and were constantly eating up server performance. To make matters worse they are set to globally broadcast so that you can see them very far away. These two conditions meant that the servers was networking tonnes of data to every client for every minicopter every frame. This was extremely slow on the server and every client as well. The fix I've applied has improved server and client performance and also significantly reduced the amount of network traffic ( the minicopters were accounting for 40%!) testing indicates a framerate improvement of about 1ms or for the average user about 5fps more.
I took this opportunity to flesh out the rest of the minicopter. These elements were designed but disabled due to them being unfinished. You'll now notice that the pilot moves the pedal and the stick. But the big deal here is the fuel gauge. 100 Low Grade or above will read as full. No more alt-looking to check.
Now if I could only fix the deflated HAB collision shape...
Adjustable Player Tick Rate
I added two new optional convars for server owners:
Adjusting these values should only be done as a last resort when nothing else helps and a server is nearly unplayable. They can be adjusted at runtime without a server restart right when the server comes under pressure and then be reset once things have calmed down. Facepunch servers will continue to run the current default parameters.
- player.tickrate_cl the rate at which players send their updates to the server, a lower rate means less work for the server but increased "peeker's advantage" and network delay
- player.tickrate_sv the rate at which the server calls the player update, a lower rate means less work for the server but increased delay in some interactions and status effects
I added a number of convars for video creators. To use these you need to be an admin on your server (in which case only you can use and see them) or play on a server with server.cinematic enabled (everyone can use and see them).
There are also two new convars to disable the procedural eye animations:
- cinematic_play "point" plays a cinematic animation called "point"
- cinematic_stop stops playing a cinematic animation
- cinematic_list prints a list of available cinematic animations
Launching EU and US small servers
- eye_blinking whether or not players should blink
- eye_movement whether or not players should move their eyes
Today we're launching an additional two Facepunch EU small servers bringing the total to three. Small servers run at smaller map size which slightly benefits lower end systems.
Unfortunately, we're unable to launch US small servers today but you can expect to see these live in the coming days.
- Added cinematic animations for video creation (see devblog)
- Added player tick rate convars to the server (see devblog)
- Added Streamer mode to options menu
- Added new horse model and breeds
- Added Hitch-Trough deployable
- Added Minicopter fuel gauge
- Added Minicopter pilot IK
- Added 'hattip' gesture
- Added a bunch of secret achievements
- Fixed exploit to stack foundation steps
- Fixed swamp fog too bright at night
- Fixed water purifier disappearing after going out of network range
- Fixed misclicking accept would reject the team invite
- Fixed Rustige Egg not taking splash damage
- Fixed being able to pick up sam site when it contained ammo
- Optimized distant tree networking (client memory savings)
- Optimized physics queries by removing collider batching entirely (previously disabled)
- Optimized all entity queries
- Optimized buoyancy physics transform sync
- Optimized server player updates and transform sync
- Optimized server packet handling
- Optimized client inventory update
- Optimized monument memory use
- Optimized ocean wave foam rendering
- Optimized gpu-side wave simulation for rendering
- Optimized cpu-side wave simulation for buoyancy
- Horses require far less food