MaxPartCount
MaxPartCount
#Overview
name: MaxPartCount
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 9
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MaxPartCount is to define the maximum number of parts a NetBlob can be split into when using partial network blob handling in Unreal Engine 5’s replication system. This setting is crucial for managing large data transfers over the network in a controlled manner.
MaxPartCount is primarily used in the Iris Core module, which is part of Unreal Engine 5’s experimental replication system. Specifically, it is used in the NetBlob subsystem, which handles the serialization and transmission of large data blobs across the network.
The value of this variable is typically set in the USequentialPartialNetBlobHandlerConfig class, which is a configuration object for the SequentialPartialNetBlobHandler. It can be overridden in derived classes, as seen in the UMockSequentialPartialNetBlobHandlerConfig constructor.
MaxPartCount interacts closely with MaxPartBitCount, another configuration variable. Together, these two variables determine the maximum total payload size that can be handled by the partial NetBlob system.
Developers must be aware that:
- MaxPartCount cannot exceed 65535, as it’s used in contexts where it needs to fit within a 16-bit unsigned integer.
- The total maximum payload size is calculated as MaxPartBitCount * MaxPartCount, so these values should be chosen carefully to balance between allowing large data transfers and preventing excessive memory usage or network congestion.
Best practices when using this variable include:
- Setting it to a value that accommodates your largest expected NetBlobs while keeping network performance in mind.
- Ensuring that the product of MaxPartCount and MaxPartBitCount doesn’t exceed the maximum desired total payload size for your application.
- Consider the target platforms and network conditions when choosing this value, as it can significantly impact network performance and memory usage.
- Use the default value (1024) as a starting point and adjust based on your specific needs and performance testing results.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:1295, section: [/Script/IrisCore.PartialNetObjectAttachmentHandlerConfig]
- INI Section:
/Script/IrisCore.PartialNetObjectAttachmentHandlerConfig
- Raw value:
4096
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/ReplicationSystemTestPlugin/Source/Private/Tests/ReplicationSystem/NetBlob/MockNetBlob.cpp:87
Scope (from outer to inner):
file
function UMockSequentialPartialNetBlobHandlerConfig::UMockSequentialPartialNetBlobHandlerConfig
Source code excerpt:
UMockSequentialPartialNetBlobHandlerConfig::UMockSequentialPartialNetBlobHandlerConfig()
{
// Overriding MaxPartCount
MaxPartCount = 32768U;
}
// UMockNetBlobHandler
UMockNetBlobHandler::UMockNetBlobHandler()
: CallCounts({})
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Private/Iris/ReplicationSystem/NetBlob/PartialNetBlob.cpp:158
Scope (from outer to inner):
file
namespace UE::Net
function bool FPartialNetBlob::SplitNetBlob
Source code excerpt:
bool FPartialNetBlob::SplitNetBlob(const FNetSerializationContext& Context, const FNetBlobCreationInfo& CreationInfo, const FPartialNetBlob::FSplitParams& SplitParams, const TRefCountPtr<FNetBlob>& Blob, TArray<TRefCountPtr<FNetBlob>>& OutPartialBlobs)
{
check(SplitParams.MaxPartBitCount > 31U && SplitParams.MaxPartBitCount < 65536U && SplitParams.MaxPartCount > 0 && SplitParams.MaxPartCount < 65536U);
if (!Blob.IsValid())
{
return false;
}
// We have no idea what the internals of the FNetBlob look like. We must serialize it to a temporary buffer.
const uint32 MaxTotalBitCount = (SplitParams.MaxPartBitCount*SplitParams.MaxPartCount) & ~31U;
// Want the part bit count to be a multiple of 32 so we can safely memcpy.
const uint32 MaxPartBitCount = SplitParams.MaxPartBitCount & ~31U;
// Allocate a temporary buffer that is 128KB to begin with.
TArray<uint32> Payload;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Private/Iris/ReplicationSystem/NetBlob/PartialNetBlob.cpp:241
Scope (from outer to inner):
file
namespace UE::Net
function bool FPartialNetBlob::SplitNetBlob
Source code excerpt:
bool FPartialNetBlob::SplitNetBlob(const FNetBlobCreationInfo& CreationInfo, const FSplitParams& SplitParams, const TRefCountPtr<FRawDataNetBlob>& Blob, TArray<TRefCountPtr<FNetBlob>>& OutPartialBlobs)
{
check(SplitParams.MaxPartBitCount > 31U && SplitParams.MaxPartBitCount < 65536U && SplitParams.MaxPartCount > 0 && SplitParams.MaxPartCount < 65536U);
if (!Blob.IsValid())
{
return false;
}
FPayloadSplitParams PayloadSplitParams;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Private/Iris/ReplicationSystem/NetBlob/PartialNetObjectAttachmentHandler.cpp:105
Scope (from outer to inner):
file
function bool UPartialNetObjectAttachmentHandler::SplitRawDataNetBlob
Source code excerpt:
FPartialNetBlob::FSplitParams SplitParams = {};
SplitParams.MaxPartBitCount = ThisConfig->GetMaxPartBitCount();
SplitParams.MaxPartCount = ThisConfig->GetMaxPartCount();
SplitParams.bSerializeWithObject = false;
if (InDebugName != nullptr)
{
SplitParams.DebugName = *InDebugName;
}
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Private/Iris/ReplicationSystem/NetBlob/SequentialPartialNetBlobHandler.cpp:34
Scope (from outer to inner):
file
function bool USequentialPartialNetBlobHandler::SplitNetBlob
Source code excerpt:
FPartialNetBlob::FSplitParams SplitParams = {};
SplitParams.MaxPartBitCount = Config->GetMaxPartBitCount();
SplitParams.MaxPartCount = Config->GetMaxPartCount();
if (InDebugName == nullptr)
{
if (const FReplicationStateDescriptor* Descriptor = Blob->GetReplicationStateDescriptor())
{
InDebugName = Descriptor->DebugName;
}
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Private/Iris/ReplicationSystem/NetBlob/SequentialPartialNetBlobHandler.cpp:65
Scope (from outer to inner):
file
function bool USequentialPartialNetBlobHandler::SplitNetBlob
Source code excerpt:
FPartialNetBlob::FSplitParams SplitParams = {};
SplitParams.MaxPartBitCount = Config->GetMaxPartBitCount();
SplitParams.MaxPartCount = Config->GetMaxPartCount();
SplitParams.NetObjectReference = NetObjectReference;
SplitParams.bSerializeWithObject = true;
if (InDebugName == nullptr)
{
if (const FReplicationStateDescriptor* Descriptor = Blob->GetReplicationStateDescriptor())
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Public/Iris/ReplicationSystem/NetBlob/PartialNetBlob.h:15
Scope (from outer to inner):
file
namespace UE::Net
class class FPartialNetBlob final : public FNetBlob
Source code excerpt:
{
uint32 MaxPartBitCount;
uint32 MaxPartCount;
FNetObjectReference NetObjectReference;
FNetDebugName DebugName;
bool bSerializeWithObject;
};
// Split a NetBlob into multiple PartialNetBlobs. The blob will be split even if the original one didn't need it.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Public/Iris/ReplicationSystem/NetBlob/SequentialPartialNetBlobHandler.h:26
Scope (from outer to inner):
file
class class USequentialPartialNetBlobHandlerConfig : public UObject
function uint32 GetMaxPartCount
Source code excerpt:
public:
uint32 GetMaxPartBitCount() const { return MaxPartBitCount; }
uint32 GetMaxPartCount() const { return MaxPartCount; }
uint64 GetTotalMaxPayloadBitCount() const { return GetMaxPartBitCount()*uint64(GetMaxPartCount()); }
protected:
/** How many bits a PartialNetBlob payload can hold at most. Cannot exceed 65535, but anything near the max packet size is discouraged as it is unlikely to fit. Keep it a power of two. */
UPROPERTY(Config)
uint32 MaxPartBitCount = 128*8;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Public/Iris/ReplicationSystem/NetBlob/SequentialPartialNetBlobHandler.h:36
Scope (from outer to inner):
file
class class USequentialPartialNetBlobHandlerConfig : public UObject
Source code excerpt:
/** How many parts a NetBlob can be split into at most. If more parts are required the splitting will fail. Cannot exceed 65535. */
UPROPERTY(Config)
uint32 MaxPartCount = 1024;
};
UCLASS(abstract, MinimalApi, transient)
class USequentialPartialNetBlobHandler : public UNetBlobHandler
{
GENERATED_BODY()