csv.ForceExit

csv.ForceExit

#Overview

name: csv.ForceExit

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 csv.ForceExit is to control the behavior of the CSV (Comma-Separated Values) profiler when it’s set to exit on completion. It’s primarily used for profiling and debugging purposes within Unreal Engine.

This setting variable is primarily used in the Core module of Unreal Engine, specifically within the profiling and debugging subsystem. The CSV profiler is a performance analysis tool that captures and logs various metrics during runtime.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with an initial value of 0, which can be changed at runtime.

The primary variable that interacts with csv.ForceExit is GCsvExitOnCompletion. When GCsvExitOnCompletion is true or the “ExitAfterCsvProfiling” command line parameter is set, the profiler will attempt to exit after completing its capture. The csv.ForceExit variable determines whether this exit should be forced or not.

Developers must be aware that setting this variable to 1 will cause the engine to perform a forced exit when the CSV profiler completes its capture and is set to exit on completion. This can be useful for automated testing or benchmarking scenarios, but it should be used with caution in development environments as it can lead to unexpected application termination.

Best practices when using this variable include:

  1. Only enable it in controlled environments, such as automated testing pipelines.
  2. Ensure all necessary data is saved before the profiler completes its capture when this variable is set to 1.
  3. Use it in conjunction with other CSV profiler settings to create comprehensive profiling scenarios.

Regarding the associated variable CVarCsvForceExit:

The purpose of CVarCsvForceExit is to provide programmatic access to the csv.ForceExit console variable within the C++ code. It’s an internal representation of the console variable that allows the engine to retrieve and use its value in the code.

CVarCsvForceExit is used directly in the FCsvProfiler::EndFrame function to determine whether a forced exit should be performed. The value is retrieved using the GetValueOnGameThread() method, which ensures thread-safe access to the variable’s current value.

When working with CVarCsvForceExit, developers should be aware that changes to this variable will directly affect the behavior of the CSV profiler’s exit process. It’s important to use this variable consistently with its corresponding console variable (csv.ForceExit) to maintain clear and predictable behavior.

Best practices for using CVarCsvForceExit include:

  1. Access its value using GetValueOnGameThread() to ensure thread safety.
  2. Avoid directly modifying this variable; instead, use the console variable system to change its value.
  3. Consider the implications of forcing an exit in your specific use case before relying on this variable in your code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:97

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarCsvForceExit(
	TEXT("csv.ForceExit"),
	0,
	TEXT("If 1, do a forced exit when if exitOnCompletion is enabled"),
	ECVF_Default
);

TAutoConsoleVariable<int32> CVarCsvTargetFrameRateOverride(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:96

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<int32> CVarCsvForceExit(
	TEXT("csv.ForceExit"),
	0,
	TEXT("If 1, do a forced exit when if exitOnCompletion is enabled"),
	ECVF_Default
);

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:3270

Scope (from outer to inner):

file
function     void FCsvProfiler::EndFrame

Source code excerpt:

			if (bCaptureEnded && (GCsvExitOnCompletion || FParse::Param(FCommandLine::Get(), TEXT("ExitAfterCsvProfiling"))))
			{
				bool bForceExit = !!CVarCsvForceExit.GetValueOnGameThread();
				FPlatformMisc::RequestExit(bForceExit, TEXT("CsvProfiler.ExitAfterCsvProfiling"));
			}
		}
	}

	GCsvProfilerFrameNumber++;