r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs

r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs

#Overview

name: r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs

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 r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs is to control the maximum time the FASTBuild job processor will wait before starting a build, even if the minimum number of pending jobs has not been reached.

This setting variable is used within the FastBuildController plugin, specifically in the job processing subsystem of Unreal Engine 5. It’s primarily utilized in the FFastBuildJobProcessor class, which is responsible for managing and executing build jobs.

The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 10 seconds but can be modified at runtime or through configuration files.

The associated variable MaxTimeWithPendingJobs directly interacts with r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs. They share the same value, with MaxTimeWithPendingJobs being the actual variable used in the code logic.

Developers must be aware that this variable affects the build process timing. If set too low, it might cause builds to start prematurely, potentially not taking advantage of optimal parallelization. If set too high, it could introduce unnecessary delays in the build process.

Best practices when using this variable include:

  1. Adjust it based on the specific project’s build characteristics and available hardware resources.
  2. Monitor build times and job distribution to find an optimal value.
  3. Consider the trade-off between waiting for more jobs and starting the build process promptly.

Regarding the associated variable MaxTimeWithPendingJobs:

The purpose of MaxTimeWithPendingJobs is to store the actual value used in the FastBuildJobProcessor logic to determine when to start a build regardless of the number of pending jobs.

This variable is used within the FastBuildController plugin, specifically in the FFastBuildJobProcessor::Run function.

Its value is set by the console variable r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs, allowing for runtime configuration.

MaxTimeWithPendingJobs directly interacts with the ElapsedSeconds calculation to determine if jobs should be kicked off anyway, even if the minimum job threshold hasn’t been met.

Developers should be aware that modifying r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs will directly affect the behavior controlled by MaxTimeWithPendingJobs.

Best practices include:

  1. Use the console variable r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs to adjust the value rather than modifying the code directly.
  2. Consider the impact on build performance and adjust based on project-specific needs and hardware capabilities.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/FastBuildController/Source/Private/FastBuildJobProcessor.cpp:28

Scope (from outer to inner):

file
namespace    FastBuildJobProcessorOptions

Source code excerpt:

	int32 MaxTimeWithPendingJobs = 10;
	FAutoConsoleVariableRef CVarFASTBuildShaderMaxTimeWithPendingJobs(
        TEXT("r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs"),
        MaxTimeWithPendingJobs,
        TEXT("Specifies how much time in seconds we will wait to have the min amount of pending jobs. Past this time, the build will start anyways.\n")
        TEXT("Default = 10\n"),
        ECVF_Default);
}

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/FastBuildController/Source/Private/FastBuildJobProcessor.cpp:26

Scope (from outer to inner):

file
namespace    FastBuildJobProcessorOptions

Source code excerpt:

        ECVF_Default);

	int32 MaxTimeWithPendingJobs = 10;
	FAutoConsoleVariableRef CVarFASTBuildShaderMaxTimeWithPendingJobs(
        TEXT("r.FASTBuild.JobProcessor.MaxTimeWithPendingJobs"),
        MaxTimeWithPendingJobs,
        TEXT("Specifies how much time in seconds we will wait to have the min amount of pending jobs. Past this time, the build will start anyways.\n")
        TEXT("Default = 10\n"),
        ECVF_Default);
}

#Loc: <Workspace>/Engine/Plugins/FastBuildController/Source/Private/FastBuildJobProcessor.cpp:74

Scope (from outer to inner):

file
function     uint32 FFastBuildJobProcessor::Run

Source code excerpt:

	{
		const float ElapsedSeconds = (FPlatformTime::Cycles() - LastTimeKickedOffJobs) * FPlatformTime::GetSecondsPerCycle();
		const bool bShouldKickoffJobsAnyway = ElapsedSeconds > FastBuildJobProcessorOptions::MaxTimeWithPendingJobs && ControllerModule.GetPendingTasksAmount() > 0;

		
		if (bShouldKickoffJobsAnyway || ControllerModule.GetPendingTasksAmount() > FastBuildJobProcessorOptions::MinJobsToKickOff)
		{
			LastTimeKickedOffJobs = FPlatformTime::Cycles();
			SubmitPendingJobs();