Skip to content

Commit c2db217

Browse files
authored
tweak(recorder): Improve performance of Replay playback slightly by increasing the Replay file read buffer to 8192 bytes (#1389)
Replay playback was measured to be about 3% faster
1 parent 10121fc commit c2db217

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Generals/Code/GameEngine/Source/Common/Recorder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "Common/version.h"
4949

5050
CONSTEXPR const char s_genrep[] = "GENREP";
51+
CONSTEXPR const UnsignedInt replayBufferBytes = 8192;
5152

5253
Int REPLAY_CRC_INTERVAL = 100;
5354

@@ -845,7 +846,9 @@ Bool RecorderClass::readReplayHeader(ReplayHeader& header)
845846
AsciiString filepath = getReplayDir();
846847
filepath.concat(header.filename.str());
847848

848-
m_file = TheFileSystem->openFile(filepath.str(), File::READ | File::BINARY );
849+
// TheSuperHackers @performance More buffered data reduces disk overhead and will improve fast forward playback
850+
const UnsignedInt buffersize = header.forPlayback ? replayBufferBytes : File::BUFFERSIZE;
851+
m_file = TheFileSystem->openFile(filepath.str(), File::READ | File::BINARY, buffersize);
849852

850853
if (m_file == NULL)
851854
{

GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "Common/version.h"
4949

5050
CONSTEXPR const char s_genrep[] = "GENREP";
51+
CONSTEXPR const UnsignedInt replayBufferBytes = 8192;
5152

5253
Int REPLAY_CRC_INTERVAL = 100;
5354

@@ -847,7 +848,9 @@ Bool RecorderClass::readReplayHeader(ReplayHeader& header)
847848
AsciiString filepath = getReplayDir();
848849
filepath.concat(header.filename.str());
849850

850-
m_file = TheFileSystem->openFile(filepath.str(), File::READ | File::BINARY );
851+
// TheSuperHackers @performance More buffered data reduces disk overhead and will improve fast forward playback
852+
const UnsignedInt buffersize = header.forPlayback ? replayBufferBytes : File::BUFFERSIZE;
853+
m_file = TheFileSystem->openFile(filepath.str(), File::READ | File::BINARY, buffersize);
851854

852855
if (m_file == NULL)
853856
{

0 commit comments

Comments
 (0)