[SPIGOT-7094] massive lagspike when loading chunks Created: 04/Jul/22 Updated: 25/Dec/24 |
|
Status: | Open |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | BloodEko | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 0 |
Labels: | async, chunkloading, lagspike, spigot, teleport | ||
Environment: |
Ubuntu with a modern AMD processor. |
Attachments: |
![]() ![]() ![]() |
Version: | CraftBukkit version 3544-Spigot-475f600-991aeda (MC: 1.19) (Implementing API version 1.19-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
Versions 1.19
Problematic behavior Loading chunks in modern minecraft versions became painfully expensive with currently lagspikes up to 800-1600ms on the main thread. This is mostly triggered by single actions causing an unloaded chunk to load. Like teleporting the player or reading block states. So when a player using Essentials teleports to their home, or already listing the homes, which reads the bed block state, causes such a lagspike.
Expected behavior The chunk loading should take a moderate time like 10-20ms or an API should be added which allows to load a chunk asynchronously, where a callback can be used which is then executed synchronously, when the chunk is loaded.
How to recreate Use player.teleport() to an unloaded chunk.
Notes Paper seems to have done both already. Synchronous chunk loads take a moderate time and there exists a world.getChunkAtAsync() method which returns a CompletableFuture<Chunk>.
The PaperLib brings an inspiration how such an API could looks like.
Also in the screenshot we can see that minecraft already has a logic for this with the IAsyncTaskHandler. But spigot seems to wait and block on the asynchronous tasks. |
Comments |
Comment by BloodEko [ 04/Jul/22 ] |
It's already tested with NVMe SSD hardware. The timings screenshot indicates that the "real" load is only ~6.19ms. And the rest of the time is spent waiting on the IAsyncTaskHandler which seems to be parked.
In comparison, Paper already fixed this, which reduces the overhead to 6-15ms. This is clearly a software problem, not a hardware problem. |
Comment by Black Hole [ 04/Jul/22 ] |
Modern Minecraft versions require a fast SSD to run decently. An old hard drive or network storage can lead to this lags for chunk loads on the main thread. |