csv.WriteBufferSize
csv.WriteBufferSize
#Overview
name: csv.WriteBufferSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When non-zero, defines the size of the write buffer to use whilst writing the CSV file.\r\nA non-zero value is required for GZip compressed output.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of csv.WriteBufferSize is to define the size of the write buffer used when writing CSV files in Unreal Engine’s profiling and debugging system. This setting is particularly important for the CSV profiler, which is a part of the engine’s performance analysis tools.
The Unreal Engine subsystem that relies on this setting variable is the Core module, specifically the profiling and debugging component. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp
.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 128 KB (128 * 1024 bytes), but can be changed at runtime through console commands or configuration files.
The associated variable that interacts with csv.WriteBufferSize is CVarCsvWriteBufferSize. This is an instance of TAutoConsoleVariable
Developers must be aware of several important aspects when using this variable:
- The buffer size directly affects the performance and memory usage of the CSV profiler.
- A non-zero value is required for GZip compressed output, as stated in the variable’s description.
- The actual buffer size used is the maximum of the set value and 0, preventing negative buffer sizes.
Best practices when using this variable include:
- Only modify it if you have specific performance requirements or issues with the default value.
- Ensure a non-zero value is set if you intend to use GZip compressed output.
- Monitor performance impact when changing this value, especially on memory-constrained platforms.
- Consider the trade-off between larger buffer sizes (potentially better write performance) and memory usage.
Regarding the associated variable CVarCsvWriteBufferSize:
The purpose of CVarCsvWriteBufferSize is to provide a programmatic interface to the csv.WriteBufferSize console variable within the C++ code of the engine. It allows the code to read and potentially modify the buffer size value.
This variable is used in the FCsvProfiler::BeginFrame() function to latch the current value of the write buffer size when starting a capture. This ensures consistency in the buffer size throughout a profiling session.
Developers should be aware that changes to CVarCsvWriteBufferSize will directly affect the behavior of the CSV profiler. It’s important to access this variable using the appropriate thread-safe methods, as demonstrated by the use of GetValueOnAnyThread() in the code.
Best practices for using CVarCsvWriteBufferSize include:
- Use it for reading the current buffer size value in performance-critical code paths.
- Be cautious about modifying its value at runtime, as it could affect ongoing profiling sessions.
- Always use thread-safe access methods when reading its value, especially in multi-threaded contexts.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:137
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarCsvWriteBufferSize(
TEXT("csv.WriteBufferSize"),
128 * 1024, // 128 KB
TEXT("When non-zero, defines the size of the write buffer to use whilst writing the CSV file.\r\n")
TEXT("A non-zero value is required for GZip compressed output."),
ECVF_Default
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarCsvWriteBufferSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:136
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarCsvWriteBufferSize(
TEXT("csv.WriteBufferSize"),
128 * 1024, // 128 KB
TEXT("When non-zero, defines the size of the write buffer to use whilst writing the CSV file.\r\n")
TEXT("A non-zero value is required for GZip compressed output."),
ECVF_Default
);
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:2972
Scope (from outer to inner):
file
function void FCsvProfiler::BeginFrame
Source code excerpt:
// Latch the cvars when we start a capture
int32 BufferSize = FMath::Max(CVarCsvWriteBufferSize.GetValueOnAnyThread(), 0);
bool bContinuousWrites = IsContinuousWriteEnabled(true);
// Allow overriding of compression based on the "csv.CompressionMode" CVar
bool bCompressOutput;
switch (CVarCsvCompressionMode.GetValueOnGameThread())
{