Chunk Loader causes a lot of lag
Fourmisain opened this issue ยท 5 comments
Description
It seems the Chunk Loader implementation is very inefficient as it can decrease TPS by a ton just by placing it down - even when you're standing right beside it and chunks are already loaded.
Data (lots of screenshots incoming)
My first test was on a server with a fairly big modpack.
I used miniHUD to show TPS, here it is without a chunk loader:
and here is it with chunk loader:
Note: The first millisecond per tick value might not be accurate because that's only what the client sees, so it could actually be much lower than 50ms.
I tested the same in singleplayer in a freshly created world as well, this time with the TPS graph.
Here it is being placed down:
TPS takes a while to stabilize after placing the chunk loader down, but you can still see how the range changes from green (~10ms) to yellow (~20ms).
Here it is being destroyed:
The ms/tick quickly recovers.
Just because I saw it, here's AE2's debug chunk loader:
There's 0 impact on placing it, though I also don't know if it actually works.
Because it could be a mod conflict of some kind, I tested it in isolation too, with only Tech Reborn and miniHUD again, because the TPS graph doesn't really help much.
Here is a flatworld with nothing in it:
I let it stabilize in both shots.
The difference here is only about a millisecond, which doesn't seem like a lot, but considering there's only 50ms to work with per tick, that is still a notable overhead.
Conclusions
It doesn't seem to matter where I place the chunk loader at all, even just putting it in a chunk far away from any machines has the same effect.
The chunk radius also doesn't matter much, radius 1 vs radius 5 at most makes a difference of 1 TPS.
Placing a ton of chunk loaders in different chunks seems to have equally little effect.
Since you are not sure if the AE2 chunk loader even works, would you like to test again with this mod's chunk loader? Because that one definitely works correctly.
@NebelNidas
For completeness' sake I just tested Literally Chunk Loader in the 1.16 modpack and it also had 0 impact.
@modmuss50
I tested the change in 1.17-pre2 in an empty world and could not detect any lag whatsoever, looking good!
Btw, what does that RADIUS
in the commit specify? Because the chunk loader can have a radius of up to 5 but this constant is always 1. Are those radii unrelated?
I will backport this fix to 1.16 shortly. Thanks for testing.
This is the radius per chunk ticket (We give each chunk we want to load a ticket), not sure where this came from before but it was loading 31 chucks around (for each chunk the chunk loader was loading) thus causing the lag. Really stupid but easy fix. Sorry it took a while to get sorted.