LLM.TrackPeaks
LLM.TrackPeaks
#Overview
name: LLM.TrackPeaks
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Track peak memory in each category since process start rather than current frame\'s value.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LLM.TrackPeaks is to control whether the Low Level Memory Tracker (LLM) should track peak memory usage in each category since the process start, rather than just the current frame’s value.
This setting variable is part of the Low Level Memory Tracking system in Unreal Engine 5, which is a core functionality for monitoring and analyzing memory usage across different parts of the engine and game.
The LLM.TrackPeaks variable is primarily used in the Core module of Unreal Engine, specifically within the HAL (Hardware Abstraction Layer) subsystem. It’s defined and referenced in the LowLevelMemTracker.cpp file.
The value of this variable is set through a console variable (CVarLLMTrackPeaks). It can be modified at runtime or set via command-line arguments. By default, it’s set to 0, meaning peak tracking is disabled.
This variable interacts closely with the FLowLevelMemTracker class, which is responsible for managing memory tracking. When enabled, it affects how memory statistics are reported, particularly in the PublishDataPerFrame function.
Developers should be aware that enabling this feature (by setting it to a non-zero value) may have performance implications, as it requires additional tracking and comparison operations for each memory category.
Best practices for using this variable include:
- Enable it when detailed memory profiling is needed, especially for identifying memory leaks or unexpected peaks.
- Disable it in production or when performance is critical, as it adds some overhead to memory tracking.
- Use in conjunction with other LLM tools and settings for comprehensive memory analysis.
Regarding the associated variable CVarLLMTrackPeaks:
This is the actual console variable that controls the LLM.TrackPeaks setting. It’s an integer variable that determines whether peak tracking is enabled (non-zero) or disabled (zero).
CVarLLMTrackPeaks is used directly in the code to check if peak tracking should be enabled. For example, in the PublishDataPerFrame function, the value is retrieved and used to set appropriate flags for memory size reporting.
The variable can also be set through the command line, as seen in the ProcessCommandLine function. This allows for easy configuration when launching the engine or game.
When working with CVarLLMTrackPeaks, developers should:
- Use the GetValueOnAnyThread() method to safely retrieve its value from any thread.
- Be aware that changing this value at runtime will affect memory tracking behavior immediately.
- Consider exposing this setting in debug menus or configuration files for easier tweaking during development and testing.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:942
Scope: file
Source code excerpt:
#endif
TAutoConsoleVariable<int32> CVarLLMTrackPeaks(TEXT("LLM.TrackPeaks"), 0,
TEXT("Track peak memory in each category since process start rather than current frame's value."));
TAutoConsoleVariable<int32> CVarLLMWriteInterval(
TEXT("LLM.LLMWriteInterval"),
1,
TEXT("The number of seconds between each line in the LLM csv (zero to write every frame)")
#Associated Variable and Callsites
This variable is associated with another variable named CVarLLMTrackPeaks
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:942
Scope: file
Source code excerpt:
#endif
TAutoConsoleVariable<int32> CVarLLMTrackPeaks(TEXT("LLM.TrackPeaks"), 0,
TEXT("Track peak memory in each category since process start rather than current frame's value."));
TAutoConsoleVariable<int32> CVarLLMWriteInterval(
TEXT("LLM.LLMWriteInterval"),
1,
TEXT("The number of seconds between each line in the LLM csv (zero to write every frame)")
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:2126
Scope (from outer to inner):
file
function void FLowLevelMemTracker::PublishDataPerFrame
Source code excerpt:
FLLMTracker& PlatformTracker = *GetTracker(ELLMTracker::Platform);
bool bTrackPeaks = CVarLLMTrackPeaks.GetValueOnAnyThread() != 0;
UE::LLM::ESizeParams SizeParams(UE::LLM::ESizeParams::Default);
if (bTrackPeaks)
{
EnumAddFlags(SizeParams, UE::LLM::ESizeParams::ReportPeak);
}
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:2329
Scope (from outer to inner):
file
function void FLowLevelMemTracker::ProcessCommandLine
Source code excerpt:
if (FParse::Value(CmdLine, TEXT("LLMTrackPeaks="), TrackPeaks))
{
CVarLLMTrackPeaks->Set(TrackPeaks);
}
UE_LOG(LogInit, Log, TEXT("LLM enabled CsvWriter: %s TraceWriter: %s"),
bCsvWriterEnabled ? TEXT("on") : TEXT("off"), bTraceWriterEnabled ? TEXT("on") : TEXT("off"));
// Disable hitchdetector because LLM is already slow enough.