LLM.LLMWriteInterval

LLM.LLMWriteInterval

#Overview

name: LLM.LLMWriteInterval

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of LLM.LLMWriteInterval is to control the frequency of writing Low-Level Memory (LLM) tracking data to a CSV file. It sets the number of seconds between each line written to the LLM CSV file.

This setting variable is primarily used by the Low-Level Memory Tracking system, which is part of Unreal Engine’s core memory management and profiling subsystem. It’s specifically utilized in the HAL (Hardware Abstraction Layer) module, as evidenced by its implementation in the LowLevelMemTracker.cpp file.

The value of this variable is set through the console variable system (CVar) in Unreal Engine. It’s initialized with a default value of 1 second, but can be modified at runtime through console commands or configuration files.

The associated variable CVarLLMWriteInterval directly interacts with LLM.LLMWriteInterval. They share the same value and purpose, with CVarLLMWriteInterval being the actual CVar object used in the code to access the setting.

Developers should be aware that:

  1. Setting this value to zero will cause the system to write data every frame, which could impact performance and create large log files quickly.
  2. The value is read on any thread (GetValueOnAnyThread()), which means it’s designed for multi-threaded access.

Best practices when using this variable include:

  1. Balancing between data granularity and performance. A lower value provides more detailed tracking but at the cost of increased I/O operations and potential performance impact.
  2. For production builds, consider setting a higher value to minimize performance impact.
  3. For debugging memory issues, a lower value might be preferable to catch short-lived allocations.

Regarding the associated variable CVarLLMWriteInterval:

The purpose of CVarLLMWriteInterval is to provide a programmatic interface to the LLM.LLMWriteInterval setting. It’s the actual ConsoleVariable object that the engine uses to store and retrieve the value of LLM.LLMWriteInterval.

This variable is part of the core engine’s console variable system, which allows for runtime configuration of various engine parameters. It’s used directly in the Low-Level Memory Tracking system’s implementation.

The value of CVarLLMWriteInterval is set when the engine initializes its console variables, but can be modified at runtime through console commands or configuration files.

CVarLLMWriteInterval interacts directly with the LLM CSV writing logic. It’s used to determine when to write new lines to the CSV file and when to log information about the writing process.

Developers should be aware that changes to CVarLLMWriteInterval will immediately affect the behavior of the LLM tracking system. It’s thread-safe and can be accessed from any thread.

Best practices for CVarLLMWriteInterval are the same as for LLM.LLMWriteInterval, as they represent the same setting. Developers should use the appropriate CVar functions to read or modify this value in C++ code, rather than trying to access LLM.LLMWriteInterval directly.

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarLLMWriteInterval(
	TEXT("LLM.LLMWriteInterval"),
	1,
	TEXT("The number of seconds between each line in the LLM csv (zero to write every frame)")
);

TAutoConsoleVariable<int32> CVarLLMHeaderMaxSize(
	TEXT("LLM.LLMHeaderMaxSize"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:945

Scope: file

Source code excerpt:

	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)")
);

TAutoConsoleVariable<int32> CVarLLMHeaderMaxSize(

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:6004

Scope (from outer to inner):

file
function     void FLLMCsvWriter::Publish

Source code excerpt:


	if ((FLowLevelMemTracker::Get().bPublishSingleFrame == false) && 
		(Now - LastWriteTime < (double)CVarLLMWriteInterval.GetValueOnAnyThread()))
	{
		return;
	}

	LastWriteTime = Now;

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:6190

Scope (from outer to inner):

file
function     void FLLMCsvWriter::AddRow

Source code excerpt:

	WriteCount++;

	if (CVarLLMWriteInterval.GetValueOnAnyThread())
	{
		UE_LOG(LogHAL, Log, TEXT("Wrote LLM csv line %d"), WriteCount);
	}

	Archive->Flush();
}