-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Today we are using union structs and inline arrays to compose the network input message InputMessage.
This is because, in the first version, the library would use marshaling for message serialization. This approach was dropped in favor of using our custom serialization API, but the type was kept as a union type using one single non-generic serializer.
The problem is that each ProtocolMessage message instance will have the larger union member size, being the input body of at least 512 bytes, this is a waste of stack memory and performance (on copy).
Also, this broke the Microsoft guideline for struct size, which should be of the maximum size of 16 bytes.
We could use an ArrayPool<byte> instead. But as a reference type, it would be trick to use with union-type structs.