Help to find lag causes

maglink

New member
Jan 15, 2023
2
0
1
Hi everyone

I want to find lag cause on my server. But I can't because everething stucks in "SELF" metrics
Help me please. I'm working around already whole week

Timings Report
Minecraft::world - Sync Chunk Load (SELF)

Spark Report
net.minecraft.util.thread.IAsyncTaskHandler.waitForTasks()

Why SyncChunkLoad possible?
Shouldn't chunks be loaded asynchronously?
 
Last edited:

electronicboy

Administrator
Staff member
Dec 11, 2021
225
10
38
28
chunk loads are async, but, there are cases where we have to wait for them to load in order to allow something to occur

In this case, you have something, likely a plugin, loading chunks off the main thread. Due to how much of a pain this is to actually turn this into an async chunk load for such an unsupported (and stupid) behavior, it will block the main thread.
 

maglink

New member
Jan 15, 2023
2
0
1
chunk loads are async, but, there are cases where we have to wait for them to load in order to allow something to occur

In this case, you have something, likely a plugin, loading chunks off the main thread. Due to how much of a pain this is to actually turn this into an async chunk load for such an unsupported (and stupid) behavior, it will block the main thread.
You were right!

I found exact line in my code. But I still don't know why it causing lags in main thread
I just checking if chunk is loaded

Java:
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> {
    if (location.getChunk().isLoaded()) {
        //do stuff
    }
}, checkPeriod, checkPeriod);
 

electronicboy

Administrator
Staff member
Dec 11, 2021
225
10
38
28
calling getChunk will load the chunk, you shouldn't be messing with that stuff off the main thread anyways