net.RcvThreadSleepTimeForWaitableErrorsInSeconds

net.RcvThreadSleepTimeForWaitableErrorsInSeconds

#Overview

name: net.RcvThreadSleepTimeForWaitableErrorsInSeconds

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 net.RcvThreadSleepTimeForWaitableErrorsInSeconds is to control the sleep time of the receive thread when a waitable error is returned by a socket operation in the networking system of Unreal Engine.

This setting variable is primarily used in the networking subsystem, specifically within the OnlineSubsystemUtils plugin. It’s part of the IpNetDriver, which handles network communication in Unreal Engine.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0.0f, but can be changed at runtime through console commands or configuration files.

The associated variable CVarRcvThreadSleepTimeForWaitableErrorsInSeconds directly interacts with net.RcvThreadSleepTimeForWaitableErrorsInSeconds. They share the same value and purpose.

Developers must be aware that:

  1. When the value is greater than 0, the receive thread will sleep for the specified number of seconds.
  2. When the value is exactly 0, the thread will yield if the platform supports it.
  3. When the value is less than 0, this functionality is disabled.

Best practices when using this variable include:

  1. Use it cautiously, as sleep times can affect network responsiveness.
  2. Monitor network performance when adjusting this value to find the optimal setting for your specific use case.
  3. Consider platform-specific behaviors, especially regarding thread yielding.

Regarding the associated variable CVarRcvThreadSleepTimeForWaitableErrorsInSeconds:

When working with this variable, developers should consider its impact on network performance and adjust it based on specific network conditions and requirements of their game or application.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:89

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarRcvThreadSleepTimeForWaitableErrorsInSeconds(
	TEXT("net.RcvThreadSleepTimeForWaitableErrorsInSeconds"),
	0.0f, // When > 0 => sleep. When == 0 => yield (if platform supports it). When < 0 => disabled
	TEXT("Time the receive thread will sleep when a waitable error is returned by a socket operation."));

TAutoConsoleVariable<int32> CVarRcvThreadShouldSleepForLongRecvErrors(
	TEXT("net.RcvThreadShouldSleepForLongRecvErrors"),
	0,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:88

Scope: file

Source code excerpt:

		TEXT("the kernel timestamp will be retrieved for each packet received, providing more accurate ping calculations."));

TAutoConsoleVariable<float> CVarRcvThreadSleepTimeForWaitableErrorsInSeconds(
	TEXT("net.RcvThreadSleepTimeForWaitableErrorsInSeconds"),
	0.0f, // When > 0 => sleep. When == 0 => yield (if platform supports it). When < 0 => disabled
	TEXT("Time the receive thread will sleep when a waitable error is returned by a socket operation."));

TAutoConsoleVariable<int32> CVarRcvThreadShouldSleepForLongRecvErrors(
	TEXT("net.RcvThreadShouldSleepForLongRecvErrors"),

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:2027

Scope (from outer to inner):

file
function     uint32 UIpNetDriver::FReceiveThreadRunnable::Run

Source code excerpt:

	const int32 PollTimeMS = CVarNetIpNetDriverReceiveThreadPollTimeMS.GetValueOnAnyThread();
	const FTimespan Timeout = FTimespan::FromMilliseconds(PollTimeMS);
	const float SleepTimeForWaitableErrorsInSec = CVarRcvThreadSleepTimeForWaitableErrorsInSeconds.GetValueOnAnyThread();
	const int32 ActionForLongRecvErrors = CVarRcvThreadShouldSleepForLongRecvErrors.GetValueOnAnyThread();

	UE_LOG(LogNet, Log, TEXT("UIpNetDriver::FReceiveThreadRunnable::Run starting up."));

	// Wait for the Socket to be set
	while (bIsRunning && !Socket.IsValid())