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.
This commit is contained in:
@@ -52,6 +52,7 @@ namespace OpenRA.Network
|
||||
public readonly ReadOnlyList<ChatLine> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user