The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: ceeac on November 06, 2021, 09:41:37 AM

Title: New desync debugging tool: Heavy Mode
Post by: ceeac on November 06, 2021, 09:41:37 AM
This patch adds a new network desync debugging tool: Heavy Mode (the name is inspired from here (https://www.factorio.com/blog/post/fff-63), although the implementation is silghtly different). In a nutshell, this allows comparing the game state of the client and server for every sync_step. There are now three modes which can be selected via -DSIMUTRANS_HEAVY_MODE=<number> in CMake or HEAVY_MODE:=<number> in config.default:

Simply compiling server and client in Heavy Mode and connecting with no user interaction should work, but there are still two cases of "desyncs" (i.e. desyncs in Heavy Mode that do not occur with Heavy Mode disabled as far as I know):
Title: Re: New desync debugging tool: Heavy Mode
Post by: Dwachs on November 06, 2021, 10:10:38 AM
Nice idea! would it be possible to also record all commands in a savegame, to allow a full replay of the game?

Quotezeiger_t's and dummy grounds for elevated way previews and such are saved in the save game which causes a desync. I'm not sure if we can get away with not saving them since zeiger_t's are not only used for UI purposes but also as markers for the old C++ AI. Not sure yet how to solve this properly...

This should not happen: they are deleted by calls to cleanup, see simworld.cc:4775.

I also wrote a desync debug tool some years ago: it logged calls to simrand, and allowed to find the call that got wrong. However it was not very helpful, as looking for the cause was an entire different story :/
Title: Re: New desync debugging tool: Heavy Mode
Post by: ceeac on November 22, 2021, 07:29:45 AM
Quote from: Dwachs on November 06, 2021, 10:10:38 AMwould it be possible to also record all commands in a savegame
Yes, but that is orthogonal to this patch. Also this will not work with variable sync_step sizeof single player mode, unless the step size is saved or one uses the fixed step size to record a replay.

Quote from: Dwachs on November 06, 2021, 10:10:38 AMthey are deleted by calls to cleanup
I explicitly don't want to do that because that might hide desyncs (for example, hovering over a full sea tile with the mouse when a ship enters the tile).
Title: Re: New desync debugging tool: Heavy Mode
Post by: Dwachs on December 18, 2021, 11:56:59 AM
Could you please commit this patch?

Edit: The comparison of two savegames could be done by a derived class from loadsave_t: it takes two (original) loadsave_t objects and throws an error if the result of byte-reading differs between the two.
Title: Re: New desync debugging tool: Heavy Mode
Post by: ceeac on December 19, 2021, 09:00:00 AM
Patch submitted in r10297.

Save file comparison is a good idea - maybe using a hidden command line parameter -compare a b or similar.
Title: Re: New desync debugging tool: Heavy Mode
Post by: Dwachs on December 19, 2021, 12:01:26 PM
I would like to turn the heavy-mode setting into a command-line parameter. Then I do not have to recompile to switch between modes 1 and 2.
Title: Re: New desync debugging tool: Heavy Mode
Post by: ceeac on December 19, 2021, 02:55:23 PM
I am fine with this. :)
Title: Re: New desync debugging tool: Heavy Mode
Post by: Dwachs on December 20, 2021, 08:30:25 PM
Submitted: heavy mode and comparing savegames from command line