Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce size of the InputMessage #40

Open
lucasteles opened this issue Mar 25, 2024 · 0 comments · Fixed by #41
Open

Reduce size of the InputMessage #40

lucasteles opened this issue Mar 25, 2024 · 0 comments · Fixed by #41

Comments

@lucasteles
Copy link
Owner

lucasteles commented Mar 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 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.

@lucasteles 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 InputMessage Mar 25, 2024
@lucasteles lucasteles self-assigned this Mar 25, 2024
@lucasteles lucasteles reopened this May 8, 2024
@lucasteles lucasteles removed their assignment Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant