NetSerialization: FVector is always 16 bytes

Hi,

I’m trying to optimize my networking and for one I’m using FVector_NetQuantize. I noticed when I tested by looking at the size increase of my FArchive that the size always increases by 16 bytes, when I use FVector_NetQuantize100, FVector_NetQuantize10, or even when I call something like SerializePackedVector<1, 8> manually.

I noticed that in the Quantized vector structs SerializePackedVector is called, and from there WritePackedVector, and eventually FArchive::SerializeInt. This is a virtual function, and my testing is done using a FArchiveFileWriterGeneric (which does not overwrite that method)

In WritePackedVector (in NetSerialization.h), this is called 4 times:

FArchive::SerializeInt( Value, Max);

The default implementation of FArchive::SerializeInt:

virtual void SerializeInt(uint32& Value, uint32 Max)
{
	ByteOrderSerialize(&Value, sizeof(Value));
}

Since sizeof(uint32) is being used here, that explains why the FVector is always 16 bytes. I wonder if this is intentional? Does it only actually serialize when the supplied Archive has its SerializeInt method overridden?

My main question however is: How do I test how large my struct is when it is actually NetSerialized for networking? I can identify when the NetSerialize call is being made during networking, but the Archive::TotalSize call always returns -1.

Looks like you put a lot of work into this already, which is awesome! If I get this right, you just want to see the stats of your networking bandwidth in relation to serialization on the wire during gameplay. There is a tool for that supplied by Epic Games that you can use during a run-time session of a game. It can break down actor properties for you to view. It is the Network Profiler. Here is a link to the documentation:

I hope this helps!

1 Like

Yes, this is very helpful. Thanks very much :slight_smile: