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

Rework messages serialization #352

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Rework messages serialization #352

wants to merge 19 commits into from

Conversation

Shatur
Copy link
Contributor

@Shatur Shatur commented Nov 13, 2024

The performance is a bit slower, but we getting a free byte per changed entity and several bytes per message.
For example, in our statistic test we using only 16 bytes for a test message instead of 33.

While writing the documentation, I decided to rename InitMessage to ChangeMessage and UpdateMessage to MutateMessage (and related types). This change helps make it clear that MutateMessage stores only component mutations. In contrast, ChangeMessage stores any type of change and may even include mutations if there is an insertion or removal. I considered including the rename into a separate PR, but decided to keep it here since the messages got completely reworked.

I would recommend to start reading from change_message and mutate_message modules, they contain a lot of internal documentation and description about how the new approach works.

I also switched to plain Vec for serialization since we no longer need Cursor for it
and Writer::write_all is much slower then Vec::extend_from_slice.

See comments in the code for details.
I also switched to plain `Vec` for serialization since we no longer need `Cursor` for it
and `Writer::write_all` is much slower then `Vec::extend_from_slice`.
@Shatur Shatur requested a review from UkoeHB November 13, 2024 01:26
@Shatur Shatur linked an issue Nov 13, 2024 that may be closed by this pull request
@Shatur Shatur changed the title Optimize replication message packing Optimize replication message sizes Nov 13, 2024
@Shatur Shatur changed the title Optimize replication message sizes Optimize replication message size Nov 13, 2024
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 95.14731% with 28 lines in your changes missing coverage. Please review.

Project coverage is 90.46%. Comparing base (0efa807) to head (a37d3ca).

Files with missing lines Patch % Lines
src/client.rs 92.99% 11 Missing ⚠️
src/core/replication/replicated_clients.rs 87.50% 5 Missing ⚠️
src/core/event_registry/server_event.rs 69.23% 4 Missing ⚠️
src/server.rs 97.29% 3 Missing ⚠️
src/server/replication_messages/serialized_data.rs 91.17% 3 Missing ⚠️
src/server/replication_messages/change_message.rs 98.34% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #352      +/-   ##
==========================================
+ Coverage   89.98%   90.46%   +0.47%     
==========================================
  Files          41       44       +3     
  Lines        2367     2422      +55     
==========================================
+ Hits         2130     2191      +61     
+ Misses        237      231       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shatur Shatur changed the title Optimize replication message size Rework messages serialization Nov 17, 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 this pull request may close these issues.

Init message header
1 participant