Botania

Botania

133M Downloads

Spectator item freezes mainthread for multiple seconds

codeHusky opened this issue ยท 6 comments

commented

Mod Loader

Forge

Minecraft Version

1.20.1

Botania version

1.20.1-443

Modloader version

Forge 47.2.0

Modpack info

No response

The latest.log file

https://gist.github.com/codeHusky/26aaf380e8d1af1fc58adb2840253fe2

Issue description

Using Botania's Spectator item can cause the mainthread of the server to lock up while running SpectatorItem#scanForStack - it appears to be trying to grab unloaded chunks and forcing the server to stop to load them.

Steps to reproduce

No response

Other information

No response

commented

The spectator has a range of 12 blocks (cubic) for scanning block entities and a range of 24 blocks (also cubic) for scanning entities (players, etc.), both based on the player location.
I'm not sure how a chunk that close to the player could not be loaded. The line mentioned in your stack trace is for looking up block entities, so it could only be accessing at most the next chunk over. Did the player maybe move at some ludicrous speeds across potentially newly generating chunks?
Anyway, I guess adding a loaded check won't hurt.

commented

That seems very aggressive. Most things assume that at least the next chunk over exists, since it's definitely loaded under normal circumstances. (Active entities have a lazy chunk and a border chunk around them by default, active block entities have at least a lazy or border chunk around them.)

commented

It's not perfectly optimal, yeah, but we're still tuning things. At the very least, the loaded check would go pretty far to preventing any edge-case hangs like this in the future.

commented

My server is using a mod that performs lazy chunk loading to reduce the strain on the server during exploration. At the moment, that means that chunks directly next to the player are occasionally not generated, which I'm assuming is causing this hang to happen. I'd love to have pregenerated the chunks but we ran into some stability issues early on and we had to regen. That should hopefully be useful to reproduce this if you need to - just manage to slow down or freeze chunk generation

commented

TODO: Investigate how much performance overhead a (usually unnecessary) chunk-loaded check would add.

commented

BTW, I've put my health monitor tool up on GitHub. it's not quite ready for primetime but it should work for getting the same kind of lag debug printouts I was getting. https://github.com/codeHusky/HealthMonitor