Skip to content

Reduce InputMessage type size #40

Description

@lucasteles

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions