Insane TPS lag caused by MoreRed
ViRb3 opened this issue · 3 comments
I am running AllTheMods 6 modpack version 1.2.0, which comes with MoreRed installed. My host is PebbleHost Premium, i9 10th gen @ 5GHz with 5GB RAM. When I walk around the map and generate new chunks, I get insane TPS drops - from 20 to about 4-5, and sometimes actions and chat messages will lag for up to 20 seconds. I used the spark mod to profile the server, and it returned this log:
https://spark.lucko.me/#PsDmKOHFeC
If you set the mappings to MCP 1.16.3, and you expand down the chain, you will notice the following lines consuming almost all of the CPU time:
net.minecraftforge.eventbus.EventBus.doCastFilter()80.87%65308ms
commoble.morered.MoreRed$$Lambda$5017/1515141381.accept()80.87%
commoble.morered.MoreRed.onPlayerStartWatchingChunk()80.87%
net.minecraft.world.World.getChunkAt()80.83%
After I removed MoreRed, the server TPS never goes below 20. I don't know if this is an issue in this mod by itself or a conflict, but it is making the game seriously unplayable.
I've verified that MoreRed::onPlayerStartWatchingChunk definitely significantly increases the time the server spends loading chunks while flying around, I should have a fix soonish
I haven't had the chance to test your fix. but I wanted to share one observation that I noticed - it seems that MoreRed, when I last tested it, didn't simply make the chunk loading slower, but it also seemed to block all other events on the server which should have been running in parallel. From my observations, when the server is lagging behind on TPS, it will still process chat messages and some other events in parallel, so they won't block/lag while the server is catching up on ticks. But with MoreRed installed, all of these events were blocking while the server was catching up ticks. You may have fixed it with the referenced commit, I haven't tested, but I wanted to let you know in case this is something you recognize.
That's correct -- as far as I could tell, it was causing chunks to try to be loaded on the main thread when the game normally tries to load chunks on worker threads. I changed the way the mod's chunk data is sent, so instead of happening when a player starts tracking a chunk (which was too early), it now sends its data after the chunk is loaded, immediately after the server sends the vanilla chunk data to the client. This is fixed in version 1.16.3-2.0.1.0; I haven't checked whether the ATM6 modpack has updated to this, but if not, then you would be able to manually update it on your own server by replacing the morered jar with the new one -- this shouldn't require clients to manually update their mod as well, but I haven't tested that