AnalyticsET.PayloadFlushTimeSecForWarning

AnalyticsET.PayloadFlushTimeSecForWarning

#Overview

name: AnalyticsET.PayloadFlushTimeSecForWarning

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 AnalyticsET.PayloadFlushTimeSecForWarning is to set a threshold for the time it takes to flush an EventCache payload in the Unreal Engine’s analytics system. It is used to trigger warning messages when the flush operation takes longer than expected, helping developers investigate and optimize slow or spammy telemetry.

This setting variable is primarily used in the Analytics subsystem of Unreal Engine, specifically within the AnalyticsET module. The AnalyticsProviderETEventCache class relies on this variable to determine when to log warnings about slow payload flushes.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. Its default value is 0.001 seconds (1 millisecond).

The associated variable PayloadFlushTimeSecForWarning interacts directly with AnalyticsET.PayloadFlushTimeSecForWarning. They share the same value, with the console variable acting as an interface to modify the static variable used in the code.

Developers should be aware that this variable affects the logging behavior of the analytics system. Setting it too low might result in excessive warnings, while setting it too high might cause slow flushes to go unnoticed.

Best practices when using this variable include:

  1. Adjusting the value based on the specific needs of your project and the expected performance of your analytics system.
  2. Monitoring the warnings generated and using them to identify and fix performance issues in your analytics events.
  3. Considering the target platform’s performance characteristics when setting this value.

Regarding the associated variable PayloadFlushTimeSecForWarning:

The purpose of PayloadFlushTimeSecForWarning is to store the actual threshold value used in the code for determining when to log warnings about slow payload flushes.

This variable is used directly in the FAnalyticsProviderETEventCache::QueueFlush() function to compare against the actual time taken to flush the payload. If the flush time exceeds this threshold, a warning message is logged with details about the payload size and the events it contains.

The value of PayloadFlushTimeSecForWarning is set through the AnalyticsET.PayloadFlushTimeSecForWarning console variable, allowing for runtime modification.

Developers should be aware that changing this variable will directly affect the sensitivity of the warning system for slow payload flushes in the analytics system.

Best practices for using PayloadFlushTimeSecForWarning include:

  1. Adjusting it in conjunction with AnalyticsET.PayloadFlushTimeSecForWarning to fine-tune the warning system.
  2. Using the warnings generated to identify potential performance bottlenecks in your analytics event processing.
  3. Considering the impact of frequent warnings on overall performance and adjusting the value accordingly.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Analytics/AnalyticsET/Private/AnalyticsProviderETEventCache.cpp:24

Scope (from outer to inner):

file
namespace    EventCacheStatic

Source code excerpt:

	static float PayloadFlushTimeSecForWarning = 0.001f;
	FAutoConsoleVariableRef CvarPayloadFlushTimeSecForWarning(
		TEXT("AnalyticsET.PayloadFlushTimeSecForWarning"),
		PayloadFlushTimeSecForWarning,
		TEXT("Time in seconds that flushing an EventCache payload can take before it will trigger a warning message, listing the events in the payload. This is intended to be used to investigate spammy or slow telemetry.")
	);

	/** Used for testing below to ensure stable output */
	bool bUseZeroDateOffset = false;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Analytics/AnalyticsET/Private/AnalyticsProviderETEventCache.cpp:22

Scope (from outer to inner):

file
namespace    EventCacheStatic

Source code excerpt:

	);

	static float PayloadFlushTimeSecForWarning = 0.001f;
	FAutoConsoleVariableRef CvarPayloadFlushTimeSecForWarning(
		TEXT("AnalyticsET.PayloadFlushTimeSecForWarning"),
		PayloadFlushTimeSecForWarning,
		TEXT("Time in seconds that flushing an EventCache payload can take before it will trigger a warning message, listing the events in the payload. This is intended to be used to investigate spammy or slow telemetry.")
	);

	/** Used for testing below to ensure stable output */
	bool bUseZeroDateOffset = false;

#Loc: <Workspace>/Engine/Source/Runtime/Analytics/AnalyticsET/Private/AnalyticsProviderETEventCache.cpp:390

Scope (from outer to inner):

file
function     void FAnalyticsProviderETEventCache::QueueFlush

Source code excerpt:

	const double EndTime = FPlatformTime::Seconds();
	const bool bPlayloadTooLarge = CachedEventUTF8Stream.Num() > (int32)((float)MaximumPayloadSize * EventCacheStatic::PayloadPercentageOfMaxForWarning);
	const bool bTookTooLongToFlush = (EndTime - StartTime) > EventCacheStatic::PayloadFlushTimeSecForWarning;
	if (bPlayloadTooLarge)
	{
		
		UE_LOG(LogAnalytics, Warning, TEXT("EventCache payload exceeded the maximum allowed size (%.3f KB > %.3f KB), containing %d events. Listing events in the payload for investigation:"),
			(float)CachedEventUTF8Stream.Num() / 1024.f,
			((float)MaximumPayloadSize * EventCacheStatic::PayloadPercentageOfMaxForWarning) / 1024.f,

#Loc: <Workspace>/Engine/Source/Runtime/Analytics/AnalyticsET/Private/AnalyticsProviderETEventCache.cpp:410

Scope (from outer to inner):

file
function     void FAnalyticsProviderETEventCache::QueueFlush

Source code excerpt:

	{
		UE_LOG(LogAnalytics, Display, TEXT("EventCache took too long to flush (%.3f ms > %.3f ms). Payload size: %.3f KB, %d events. Listing events in the payload for investigation:"),
			(EndTime - StartTime) * 1000, EventCacheStatic::PayloadFlushTimeSecForWarning * 1000,
			(float)CachedEventUTF8Stream.Num() / 1024.f, CachedEventEntries.Num());
		for (const FAnalyticsEventEntry& Entry : CachedEventEntries)
		{
			UE_LOG(LogAnalytics, Display, TEXT("    %s,%d"), *Entry.EventName, Entry.EventSizeChars);
		}
	}