From 8533aa8d26e57377159130416fdcaed09d501e73 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 7 Sep 2018 17:10:26 +0000 Subject: [PATCH] Disable sync reports when we know we won't need them. Generating the sync report takes ~twice as long as a normal tick, and occurs once every 3 ticks. These reports record of all of the synced state (separate to the sync hash, which is still calculated) in order to generate the syncreport.log of the game desyncs. This perf overhead is completely unnecessary when we know that we won't have other syncreports to compare against (singleplayer, replays). Disabling report generation in these cases gives us an easy 40% average tick-time win. --- OpenRA.Game/Network/OrderManager.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index a8e4cfbae4..a49537b13f 100644 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -52,6 +52,7 @@ namespace OpenRA.Network public readonly ReadOnlyList ChatCache; bool disposed; + bool generateSyncReport = false; void OutOfSync(int frame) { @@ -61,7 +62,12 @@ namespace OpenRA.Network public void StartGame() { - if (GameStarted) return; + if (GameStarted) + return; + + // Generating sync reports is expensive, so only do it if we have + // other players to compare against if a desync did occur + generateSyncReport = !(Connection is ReplayConnection) && LobbyInfo.NonBotClients.Count() > 1; NetFrameNumber = 1; for (var i = NetFrameNumber; i <= FramesAhead; i++) @@ -180,7 +186,8 @@ namespace OpenRA.Network Connection.SendSync(NetFrameNumber, OrderIO.SerializeSync(World.SyncHash())); - syncReport.UpdateSyncReport(); + if (generateSyncReport) + syncReport.UpdateSyncReport(); ++NetFrameNumber; }