csv.MaxPerThreadStatDataSlackKB

csv.MaxPerThreadStatDataSlackKB

#Overview

name: csv.MaxPerThreadStatDataSlackKB

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of csv.MaxPerThreadStatDataSlackKB is to control the maximum amount of per-thread slack data allowed during a CSV profiling capture in Unreal Engine 5. This setting is primarily used for performance optimization in the profiling and debugging system.

This setting variable is utilized by the CSV Profiler subsystem, which is part of the Core module in Unreal Engine. It’s specifically used in the CsvProfiler.cpp file, which handles CSV (Comma-Separated Values) profiling functionality.

The value of this variable is set through a console variable (cvar) system. It’s initialized with a default value of 64 KB, but can be changed at runtime using console commands or through configuration files.

The associated variable CVarMaxPerThreadStatDataSlackKB directly interacts with csv.MaxPerThreadStatDataSlackKB. They share the same value and purpose, with CVarMaxPerThreadStatDataSlackKB being the actual console variable object used in the code.

Developers should be aware that this variable affects the trade-off between performance and memory usage during profiling. Higher values will result in better performance due to fewer allocations, but will also increase memory overhead.

Best practices when using this variable include:

  1. Monitoring memory usage when increasing the value to ensure it doesn’t cause excessive memory consumption.
  2. Adjusting the value based on the specific profiling needs of the project.
  3. Considering the target hardware capabilities when setting this value, especially for memory-constrained platforms.

Regarding the associated variable CVarMaxPerThreadStatDataSlackKB:

The purpose of CVarMaxPerThreadStatDataSlackKB is to provide a programmatic interface to the csv.MaxPerThreadStatDataSlackKB setting within the C++ code of Unreal Engine.

This console variable is defined and used within the Core module, specifically in the CSV Profiler system. It’s created using the TAutoConsoleVariable template, which allows it to be easily accessed and modified through the engine’s console system.

The value of CVarMaxPerThreadStatDataSlackKB is set initially to 64 (KB) but can be changed at runtime through console commands or configuration files.

This variable directly interacts with the CSV profiling system. It’s used in the FCsvProfilerThreadData::FlushResults function to determine the maximum amount of slack memory allowed when populating profiling data structures.

Developers should be aware that changes to this variable will directly affect the behavior of the CSV profiler. It’s important to understand the performance and memory implications when modifying this value.

Best practices for using CVarMaxPerThreadStatDataSlackKB include:

  1. Using GetValueOnAnyThread() when accessing the value, as shown in the code, to ensure thread-safe access.
  2. Considering the impact on both performance and memory usage when adjusting this value.
  3. Documenting any non-default values used in the project to maintain consistency across the development team.

#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:159

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarMaxPerThreadStatDataSlackKB(
	TEXT("csv.MaxPerThreadStatDataSlackKB"),
	64,
	TEXT("Max amount of per thread slack data to allow during a capture.\r\n")
	TEXT("Higher values result in better performance due to fewer allocations but higher memory overhead"),
	ECVF_Default
);

#Associated Variable and Callsites

This variable is associated with another variable named CVarMaxPerThreadStatDataSlackKB. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:158

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<int32> CVarMaxPerThreadStatDataSlackKB(
	TEXT("csv.MaxPerThreadStatDataSlackKB"),
	64,
	TEXT("Max amount of per thread slack data to allow during a capture.\r\n")
	TEXT("Higher values result in better performance due to fewer allocations but higher memory overhead"),
	ECVF_Default
);

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:2072

Scope (from outer to inner):

file
class        class FCsvProfilerThreadData
function     void FlushResults

Source code excerpt:

		check(IsInCsvProcessingThread());

		int64 MaxSlackMemBytes = (int64)CVarMaxPerThreadStatDataSlackKB.GetValueOnAnyThread() * 1024;

		TimingMarkers.PopAll(OutMarkers, MaxSlackMemBytes);
		CustomStats.PopAll(OutCustomStats, MaxSlackMemBytes);
		Events.PopAll(OutEvents, MaxSlackMemBytes);
	}