VA.LazyInitConnections

VA.LazyInitConnections

#Overview

name: VA.LazyInitConnections

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 VA.LazyInitConnections is to control the initialization behavior of virtualization backends in Unreal Engine 5. Specifically, it determines whether the virtualization system should defer creating connections to its backends until they are first used.

This setting variable is primarily used in the Virtualization subsystem of Unreal Engine 5. It is referenced in the VirtualizationManager.cpp file, which is part of the Developer/Virtualization module.

The value of this variable is set through a console variable (CVar) system. It is defined as a static TAutoConsoleVariable named CVarLazyInitConnections. By default, it is set to false, meaning that connections are initialized immediately rather than lazily.

The associated variable CVarLazyInitConnections interacts directly with VA.LazyInitConnections. They share the same value, and CVarLazyInitConnections is used to control the behavior defined by VA.LazyInitConnections.

Developers must be aware that changing this variable can affect the performance and behavior of the virtualization system. When set to true, it may reduce initial overhead by deferring connection creation, but it could potentially introduce slight delays when first accessing virtualized content.

Best practices when using this variable include:

  1. Consider enabling it in development environments to potentially improve startup times.
  2. Test thoroughly to ensure that lazy initialization doesn’t negatively impact your specific use case.
  3. Be cautious about changing this setting in production environments without proper testing.

Regarding the associated variable CVarLazyInitConnections:

The purpose of CVarLazyInitConnections is to provide a programmatic interface to control the VA.LazyInitConnections setting. It’s a console variable that allows runtime modification of the lazy initialization behavior.

This variable is used within the Virtualization Manager to apply settings dynamically. The ApplySettingsFromCVar() function checks the value of CVarLazyInitConnections and updates the internal bLazyInitConnections flag accordingly.

The value of CVarLazyInitConnections can be set through console commands or programmatically at runtime.

Developers should be aware that changes to CVarLazyInitConnections will only take effect after the ApplySettingsFromCVar() function is called. This function needs to be invoked at appropriate times to ensure the setting is updated.

Best practices for using CVarLazyInitConnections include:

  1. Use it for debugging or performance tuning in development builds.
  2. Ensure that any code relying on immediate connection initialization is adjusted if this setting is changed.
  3. Consider exposing this setting in debug menus for easier testing and optimization.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Developer/Virtualization/Private/VirtualizationManager.cpp:41

Scope (from outer to inner):

file
namespace    UE::Virtualization

Source code excerpt:

// TODO: Move to RegisterConsoleCommands
static TAutoConsoleVariable<bool> CVarLazyInitConnections(
	TEXT("VA.LazyInitConnections"),
	false,
	TEXT("When true the VA backends will defer creating their connections until first use"));

//
#define UE_USE_GLOBAL_CVAR 1

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Developer/Virtualization/Private/VirtualizationManager.cpp:40

Scope (from outer to inner):

file
namespace    UE::Virtualization

Source code excerpt:


// TODO: Move to RegisterConsoleCommands
static TAutoConsoleVariable<bool> CVarLazyInitConnections(
	TEXT("VA.LazyInitConnections"),
	false,
	TEXT("When true the VA backends will defer creating their connections until first use"));

//
#define UE_USE_GLOBAL_CVAR 1

#Loc: <Workspace>/Engine/Source/Developer/Virtualization/Private/VirtualizationManager.cpp:1296

Scope (from outer to inner):

file
namespace    UE::Virtualization
function     void FVirtualizationManager::ApplySettingsFromCVar

Source code excerpt:

void FVirtualizationManager::ApplySettingsFromCVar()
{
	if (!bLazyInitConnections && CVarLazyInitConnections.GetValueOnAnyThread())
	{
		bLazyInitConnections = true;
		UE_LOG(LogVirtualization, Display, TEXT("CVar has set the virtualization system backends to lazy init their connections"));
	}
}