You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 this will break the union-type rules.
The text was updated successfully, but these errors were encountered:
lucasteles
changed the title
Reduce size of the [InputMessage](https://github.com/lucasteles/Backdash/blob/master/src/Backdash/Network/Messages/InputMessage.cs)
Reduce size of the InputMessageMar 25, 2024
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 least512
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 of16
bytes.We could use an
ArrayPool<byte>
instead. But this will break the union-type rules.The text was updated successfully, but these errors were encountered: