Skip to content

Implement smoother chunk streaming #270

Closed

Description

@Schuwi

The server is loading chunks too fast :D
Right now the server checks which new chunks to load the instant a player crosses a chunk border and then sends all the newly loaded chunks to the player as fast as it can.
When running a release build with a server view distance of 16 the Minecraft vanilla client suffers. Every time when crossing a chunk border the client hangs for a good ~100ms while receiving the new 32 chunks sent by the server. When setting the view distance to 32 the client actually seems to lose a lot of chunks (maybe some receive-buffer overflowing or something?), so a lot of chunks in view distance are just permanently unloaded for the client.
I actually wonder how the vanilla server handles this. Maybe it's just slow enough at loading chunks ^^?
I'm not sure how to remedy this. The straightforward solution would be to implement some kind of chunk streaming queue and only send x chunks per time interval t to the client but maybe there is a better solution?

Activity

  1. skillman623 commented on Jul 26, 2020

    @skillman623

    The freezing may be CPU bound.
    According to some tests that I did by flying in creative mode
    - 97 chunk updates = 100fps drop (680 ->590)
    - 199 chunk updates = over 200fps drop (680 ->470 FPS)
    If I frame limit to 60fps my framerates do dip to about 58ish sometimes...

    The client does end up using 20% CPU {no cores maxed out), while the server uses about 18% CPU. My graphics card utilization stayed at 100% when under load like this throughout testing.
    While I agree that this should be limited for more reasonably speced hardware, maybe chunk rate limiting should be enabled it per player.
    As a note I had the server compiled in debug mode for these numbers, I'll retest in release mode if I have time.

    We could potentially use some sort of benchmark like checking for delay in player movement packets or pinging the client and measuring response times during chunk loading to detect client lag.
    As for the chunks not loading issue maybe we should check for things like clientside (serverbound) player position going downwards though solid blocks immediately after crossing a chunk border as a que to resend the chunk (maybe a few surrounding chunks as well).

    client hangs for a good ~ 100ms while receiving the new 32 chunks sent by the server
    Is this a tool/mod used to measure this? I'd be happy to do more thorough testing using it if it is.
    Specs
    Ryzen 1700x 3.4GHZ (8 core 16 threads) with a Nvidia 750Ti.
    ~~
    Tested on Windows 10 with vanilla 1.13.2.

    Tests were done in debug mode

  2. Schuwi commented on Jul 26, 2020

    @Schuwi
    MemberAuthor

    Yeah, the problem only arises when compiling in release mode, debug mode chunk loading is pretty slow in comparison

  3. skillman623 commented on Jul 26, 2020

    @skillman623

    Retested with release mode- Chunks no longer load properly.
    Sorry about that.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions