-
Notifications
You must be signed in to change notification settings - Fork 34
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
Less terrible chunk sending #138
Draft
ReCore-sys
wants to merge
17
commits into
master
Choose a base branch
from
rework/better-chunk-sending
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Still deadlocking though
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the atrocious chunk sending system I implemented before. Turns out simply hurling over 500 chunks at a client every 5 seconds was a sub-optimal strategy, who would have guessed?
Description
This PR implements a smarter "on-demand" chunk sending system to avoid overloading both the server and the client. The previous system had many flaws, including huge lag spikes for both the client and the server, extremely delayed chunk loading times, players only receiving world data every 5 seconds leading to extremely long join times, loading and sending heaps of unneeded data and unnecessarily prolonged component locking which has the potential to slow down the entire server. This new system splits the work over many tasks/threads and doesn't fetch or send unnecessary data, massively reducing the load on both the client and the server.
It works by attaching a
ChunkReciever
component to players and then using that to calculate what chunks the client needs whenever they cross a chunk border, meaning that clients will almost immediately receive the chunks they just came into view range of and also makes sure they aren't sent chunks they can already see. It also splits the work as much as it can by having 2 ECS systems used, one that fetches the chunks from the database and one that sends those chunks to the client. It also uses a separate tokio task for each player when fetching or sending chunk, splitting the work up even further. This approach is explained in more detail in the docs (WIP).It is important to note that this PR doesn't add support for chunks being updated or chunks being sent over multiple ticks, those will need to be addressed in future PRs.
Motivation and Context
The previous chunk sending system worked (somewhat) and was merged to just get something quick and dirty out the door as soon as possible. This PR massively improves pretty much everything about it, and should hold up for the foreseeable future.
How has this been tested?
These changes are hard to test with unit tests, but has been manually tested extensively. Some deadlocking issues did crop up and while I'm pretty confident they have been fixed, I was unable to reproduce them reliably so there is a chance they might persist.
Screenshots (if appropriate):
Types of changes
Checklist: