csv.FramesToBuffer
csv.FramesToBuffer
#Overview
name: csv.FramesToBuffer
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Defines the minimum amount of frames to keep in memory before flushing them.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of csv.FramesToBuffer is to define the minimum number of frames to keep in memory before flushing them during CSV profiling in Unreal Engine 5. This setting is primarily used for the profiling and debugging system, specifically the CSV profiler.
The Unreal Engine subsystem that relies on this setting variable is the Core module, particularly the CSV profiler component within the ProfilingDebugging namespace. 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 as a console variable using TAutoConsoleVariable. It has a default value of 128 frames, but can be changed at runtime through the console or configuration files.
The associated variable CVarCsvStreamFramesToBuffer interacts directly with csv.FramesToBuffer. This is an internal representation of the console variable, allowing for easy access to the value within the C++ code.
Developers should be aware that this variable affects the memory usage and performance of the CSV profiler. A higher value will keep more frames in memory before writing them to disk, which can be useful for capturing longer sequences but may consume more memory. Conversely, a lower value will flush data to disk more frequently, reducing memory usage but potentially increasing I/O operations.
Best practices when using this variable include:
- Adjusting the value based on the specific profiling needs and available system resources.
- Monitoring memory usage when increasing this value, especially on memory-constrained platforms.
- Considering the trade-off between memory usage and I/O operations when setting this value.
Regarding the associated variable CVarCsvStreamFramesToBuffer:
The purpose of CVarCsvStreamFramesToBuffer is to provide a programmatic interface to the csv.FramesToBuffer console variable within the C++ code of the CSV profiler.
This variable is used directly in the FCsvProfiler::BeginFrame function to determine the number of frames to buffer when initializing the FCsvStreamWriter. It allows the profiler to dynamically adjust its behavior based on the current console variable setting.
The value of CVarCsvStreamFramesToBuffer is set automatically by the TAutoConsoleVariable system, which links it to the csv.FramesToBuffer console variable.
Developers should be aware that changes to the csv.FramesToBuffer console variable will be reflected in CVarCsvStreamFramesToBuffer, and these changes can affect the behavior of the CSV profiler at runtime.
Best practices for using CVarCsvStreamFramesToBuffer include:
- Using GetValueOnAnyThread() when accessing the value, as shown in the provided code snippet, to ensure thread-safe access.
- Being cautious about caching the value, as it can change at runtime. Instead, query the value when needed.
- Consider the performance implications of frequently querying this value in performance-critical code paths.
#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:145
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarCsvStreamFramesToBuffer(
TEXT("csv.FramesToBuffer"),
128,
TEXT("Defines the minimum amount of frames to keep in memory before flushing them."),
ECVF_Default
);
TAutoConsoleVariable<int32> CVarCsvPauseProcessingThread(
#Associated Variable and Callsites
This variable is associated with another variable named CVarCsvStreamFramesToBuffer
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:144
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarCsvStreamFramesToBuffer(
TEXT("csv.FramesToBuffer"),
128,
TEXT("Defines the minimum amount of frames to keep in memory before flushing them."),
ECVF_Default
);
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:3006
Scope (from outer to inner):
file
function void FCsvProfiler::BeginFrame
Source code excerpt:
else
{
int64 NumFramesToBuffer = CVarCsvStreamFramesToBuffer.GetValueOnAnyThread();
CsvWriter = new FCsvStreamWriter(OutputFile.ToSharedRef(), bContinuousWrites, BufferSize, NumFramesToBuffer, bCompressOutput, RenderThreadId, RHIThreadId);
NumFramesToCapture = CurrentCommand.Value;
GCsvRepeatFrameCount = NumFramesToCapture;
CaptureFrameNumber = 0;
CaptureFrameNumberRT = 0;