TimeToWaitAfterInit

TimeToWaitAfterInit

#Overview

name: TimeToWaitAfterInit

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of TimeToWaitAfterInit is to control the delay before the maintenance process begins for the Unreal Engine’s Derived Data Cache (DDC) file system cache store. This setting variable is primarily used in the cache management and maintenance system.

This setting variable is primarily relied upon by the Derived Data Cache subsystem, specifically within the FileSystemCacheStore module. It’s used to manage the timing of maintenance operations for the file system-based cache store.

The value of this variable is set in multiple places:

  1. It’s initialized with a default value of 1 minute in the FFileSystemCacheStoreMaintainerParams struct.
  2. It can be overridden in the FFileSystemCacheStore constructor based on the bClean parameter.
  3. It can be parsed from the engine configuration file (GEngineIni) using the key “TimeToWaitAfterInit” in the “DDCCleanup” section.

This variable interacts with other variables and parameters in the cache store system, such as bClean and MaintenanceDelayInSeconds. When bClean is true, TimeToWaitAfterInit is set to zero, triggering immediate maintenance.

Developers must be aware that this variable affects the startup performance of the engine. A longer delay means the maintenance process starts later, which could be beneficial for initial load times but might delay necessary cache cleanup.

Best practices when using this variable include:

  1. Adjust it based on your project’s needs. For development builds, a shorter delay might be preferred for quicker iteration.
  2. For release builds, consider a longer delay to prioritize initial load times.
  3. If frequent cache maintenance is crucial, set it to a lower value or zero.
  4. Always test the impact of changes to this variable on your project’s performance and stability.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2690, section: [DDCCleanup]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Developer/DerivedDataCache/Private/FileSystemCacheStore.cpp:208

Scope (from outer to inner):

file
namespace    UE::DerivedData

Source code excerpt:

	FTimespan ScanFrequency = FTimespan::FromHours(1.0);
	/** Time to wait after initialization before maintenance begins. */
	FTimespan TimeToWaitAfterInit = FTimespan::FromMinutes(1.0);
};

class FFileSystemCacheStoreMaintainer final : public ICacheStoreMaintainer
{
public:
	FFileSystemCacheStoreMaintainer(const FFileSystemCacheStoreMaintainerParams& Params, FStringView CachePath);

#Loc: <Workspace>/Engine/Source/Developer/DerivedDataCache/Private/FileSystemCacheStore.cpp:360

Scope (from outer to inner):

file
namespace    UE::DerivedData
function     void FFileSystemCacheStoreMaintainer::Loop

Source code excerpt:

void FFileSystemCacheStoreMaintainer::Loop()
{
	WaitEvent->Wait(Params.TimeToWaitAfterInit, /*bIgnoreThreadIdleStats*/ true);

	while (!bExit)
	{
		const FDateTime ScanStart = FDateTime::Now();
		FileCount = 0;
		FolderCount = 0;

#Loc: <Workspace>/Engine/Source/Developer/DerivedDataCache/Private/FileSystemCacheStore.cpp:1213

Scope (from outer to inner):

file
function     FFileSystemCacheStore::FFileSystemCacheStore

Source code excerpt:

		if (Params.bClean)
		{
			MaintainerParams->TimeToWaitAfterInit = FTimespan::Zero();
		}
		else
		{
			MaintainerParams->TimeToWaitAfterInit = FTimespan::FromSeconds(Params.MaintenanceDelayInSeconds);
		}

		if (!bLocalDeactivatedForPerformance)
		{
			Maintainer = MakeUnique<FFileSystemCacheStoreMaintainer>(*MaintainerParams, CachePath);

#Loc: <Workspace>/Engine/Source/Developer/DerivedDataCache/Private/FileSystemCacheStore.cpp:3058

Scope (from outer to inner):

file
function     void FFileSystemCacheStoreParams::Parse

Source code excerpt:

	FParse::Value(Config, TEXT("FoldersToClean="), MaxDirectoryScanCount);

	GConfig->GetDouble(TEXT("DDCCleanup"), TEXT("TimeToWaitAfterInit"), MaintenanceDelayInSeconds, GEngineIni);

	FParse::Value(Config, TEXT("RedirectionFileName="), RedirectionFileName);
	FParse::Value(Config, TEXT("RedirectionKeyName="), RedirectionKeyName);
}

ILegacyCacheStore* CreateFileSystemCacheStore(