faster server autosaves patch
Posted: 15 Apr 2016 14:21
Download last version there (v6) -> viewtopic.php?p=1184282#p1184282
Current version features (v6):
a) The encoding part of a server savegame is now started on a different thread to minimize the impact of the stall that occurs after writting all the game state into memory, but there are some limitations:
a.1) When a client joins and the server is performing a savegame, the server stalls for the remaining duration that is still needed to finish encoding the savegame.
a.2) When a client joins and is receiving the map, and the server is not set to pause on join, no autosave (or any save) will be performed should a client still be receiving the map and the encoding part is not yet finished.
b) When a client joins, AIs and GS scripts are no longer requested to save their data. This removes yet another stall during game state copying, while reducing the size of the map that is to be compressed and then sent to the client. The client also starts downloading the map a bit earlier. As an extra benefit, this permits AIs and GS scripts that usually take too long to save to be useable while running a server, but there's a small note regarding this:
b.1) Should the server manually save the game or perform autosaves, AIs and GS scripts are still going to be requested to save their data.
c) Added 2 more configurable parameters in openttd.cfg, "sendmap_format" and "autosave_format" on top of "savegame_format". Search for these 3 lines inside openttd.cfg file, under [misc] section:
c.1) These 2 new parameters accept the same valid values as the existant one: https://wiki.openttd.org/Savegame_format
- savegame_format sets the format of manual save games.
- autosave_format sets the format of autosave save games.
- sendmap_format sets the format that is used by a server when sending a map to a client joining.
c.2) Each of these 3 formats also include 2 additional compression level defaults to complement the already existant default:
- fast
- default
- slow
As it currently stands, only lzma and zlib benefit from these added defaults.
- lzma:0 .. lzma:9 (fast: 0, default: 2, slow: 2)
- zlib:0 .. zlib:9 (fast: 1, default: 6, slow: 6)
c.3) OpenTTD resorts to these default compression levels if they're not set in the configuration parameters, and only when certain game conditions match:
- fast when the current running game is the host of a network game or if an autosave occurs when the current running game is in fast forward mode.
- slow when the current running game is the host of a network game and a client is joining in.
- default whenever the criterias above don't occur.
The video example that I used for v1, could be set with the following parameters:
In that example, savegames and sendmap formats and compression levels would resort to using openttd defaults, which is lzma for the format. The compression level would depend on those certain game conditions refered in c.3). Autosaves would use zlib format, and compression level would be 2, regardless of current game conditions.
Previous version (v1):
Video: https://onedrive.live.com/redir?resid=2 ... file%2cmp4
Current version features (v6):
a) The encoding part of a server savegame is now started on a different thread to minimize the impact of the stall that occurs after writting all the game state into memory, but there are some limitations:
a.1) When a client joins and the server is performing a savegame, the server stalls for the remaining duration that is still needed to finish encoding the savegame.
a.2) When a client joins and is receiving the map, and the server is not set to pause on join, no autosave (or any save) will be performed should a client still be receiving the map and the encoding part is not yet finished.
b) When a client joins, AIs and GS scripts are no longer requested to save their data. This removes yet another stall during game state copying, while reducing the size of the map that is to be compressed and then sent to the client. The client also starts downloading the map a bit earlier. As an extra benefit, this permits AIs and GS scripts that usually take too long to save to be useable while running a server, but there's a small note regarding this:
b.1) Should the server manually save the game or perform autosaves, AIs and GS scripts are still going to be requested to save their data.
c) Added 2 more configurable parameters in openttd.cfg, "sendmap_format" and "autosave_format" on top of "savegame_format". Search for these 3 lines inside openttd.cfg file, under [misc] section:
Code: Select all
[misc]
savegame_format =
sendmap_format =
autosave_format =
- savegame_format sets the format of manual save games.
- autosave_format sets the format of autosave save games.
- sendmap_format sets the format that is used by a server when sending a map to a client joining.
c.2) Each of these 3 formats also include 2 additional compression level defaults to complement the already existant default:
- fast
- default
- slow
As it currently stands, only lzma and zlib benefit from these added defaults.
- lzma:0 .. lzma:9 (fast: 0, default: 2, slow: 2)
- zlib:0 .. zlib:9 (fast: 1, default: 6, slow: 6)
c.3) OpenTTD resorts to these default compression levels if they're not set in the configuration parameters, and only when certain game conditions match:
- fast when the current running game is the host of a network game or if an autosave occurs when the current running game is in fast forward mode.
- slow when the current running game is the host of a network game and a client is joining in.
- default whenever the criterias above don't occur.
The video example that I used for v1, could be set with the following parameters:
Code: Select all
[misc]
savegame_format =
sendmap_format =
autosave_format = zlib:2
Previous version (v1):
Video: https://onedrive.live.com/redir?resid=2 ... file%2cmp4
- [+] Spoiler v1 r27539