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

Refactor replication to use a buffer cache per client #46

Merged
merged 8 commits into from
Sep 22, 2023
Merged

Conversation

Shatur
Copy link
Contributor

@Shatur Shatur commented Sep 21, 2023

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2023

Codecov Report

Patch coverage: 99.08% and project coverage change: -1.60% ⚠️

Comparison is base (d640c60) 95.47% compared to head (367eb74) 93.87%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #46      +/-   ##
==========================================
- Coverage   95.47%   93.87%   -1.60%     
==========================================
  Files          10       10              
  Lines         663      735      +72     
==========================================
+ Hits          633      690      +57     
- Misses         30       45      +15     
Files Changed Coverage Δ
src/lib.rs 100.00% <ø> (ø)
src/replicon_core.rs 94.04% <ø> (-2.25%) ⬇️
src/client.rs 89.42% <95.91%> (+4.67%) ⬆️
src/server.rs 97.17% <100.00%> (+0.70%) ⬆️

... and 2 files with indirect coverage changes

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

src/server.rs Outdated Show resolved Hide resolved
src/client.rs Outdated Show resolved Hide resolved
src/client.rs Outdated Show resolved Hide resolved
src/server.rs Outdated Show resolved Hide resolved
src/server.rs Show resolved Hide resolved
@UkoeHB
Copy link
Collaborator

UkoeHB commented Sep 21, 2023

If a message is empty you should not send it at all. In practice that will add up to a lot of bytes, since most ticks won't have anything to send other than network tick. Afaik it's fine for ack ticks to accumulate a large gap if there are no changes.

You can probably do the same on the client side, as long as ack invariants are preserved.

@Shatur Shatur requested a review from UkoeHB September 21, 2023 23:49
@UkoeHB
Copy link
Collaborator

UkoeHB commented Sep 22, 2023

Micro optimization: if there are no despawns then the despawn size isn't needed, and if there are no removals and no despawns then the removal and despawn sizes aren't needed. The deserializer can early-out if it reaches the cursor end when trying to deserialize removals/despawns.

To implement this you need to resize the vector to crop the reserved length bytes, because afaik Cursor<Vec<u8>>::set_position() will increase the vector size. Actually you could use resize itself to crop the trailing bytes, avoiding any mismatch between cursor and vector logic.

Copy link
Collaborator

@UkoeHB UkoeHB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Follow-up PRs:

  • Remove trailing empty array sizes.
  • Serialize entity as two u32 varints.
  • Provide config options for serializing component data with varints vs fixed ints.

@Shatur Shatur enabled auto-merge (squash) September 22, 2023 09:07
@Shatur Shatur disabled auto-merge September 22, 2023 09:07
@Shatur Shatur merged commit 0c681da into master Sep 22, 2023
3 checks passed
@Shatur Shatur deleted the memory-reuse branch September 22, 2023 09:07
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.

3 participants