TL;DR
Create and send deltas (delta compression) to update a multiplayer save to the latest version to reduce the bandwidth and time required to join a server.What ?
Every time a new multiplayer save is created, create a delta file between the latest save and the previous save, for example, using librsync/xdelta/etc. on the uncompressed data.The delta file should only contain the data that has changed since the last save and should be tiny compared to the save as a whole.
The delta file name should include the tick from the old save file. This allows the client to request all deltas since the tick in the save it has, and the server to efficiently supply the required files or report that it no longer has the required deltas and the client needs to fetch a fresh save.
When a client connects, if it does not have an existing save or the save it has is too old, it will download the latest full save.
If the client (now) has a recent save, it will download and apply any deltas before loading the save and catching up as usual.
This should improve the experience for both returning and new players.
Old deltas can be removed when the total size of the delta files exceeds the size of the latest save, as it no longer saves bandwidth to download the deltas.
As
, using delta files allows for the possibility of requesting delta files in a torrent-like manner (in terms of impact on server bandwidth) from other clients, as unlike saves, delta files are static and long-lived.
It is also possible that, depending on bandwidth constraints, downloading more data in the form of deltas from multiple clients may be faster than downloading the latest save from the server.
To optimise save files for delta-compression,
mrudat wrote: ↑Fri Jun 14, 2024 1:56 pm It could also help to serialise by how recently an entity was last changed, as that would mean cold data could be efficiently skipped and hot data transferred in full.
Perhaps associate each entity with the last save it was changed in (which would be serialised in the save), and remove the association when it gets changed so you maintain the most recently updated order.
It might also benefit from loading 'hot' entities nearby in RAM.
Why ?
Using delta compression to transfer multiplayer saves should result in a significant reduction in bandwidth required and, thus, the time needed to join a server.---
Copied from
Edit: many many edits.