Advanced Peripherals

Advanced Peripherals

29M Downloads

ChatBox is a lag fest

Bennyboy1695 opened this issue ยท 10 comments

commented

Descripe

On servers with many players everytime they chat the mod is checking every tile entity in the world to see if its a chatbox.
This causes an intense amount of lag depending on how many tiles are in the world.

Steps to reproduce

Place a lot of tiles in the world. Or join a server with many tiles already.
Start chatting and experience the lag

Version

0.6.7b (Latest)

Minecraft, Forge and maybe other related mods versions

forge-1.16.5-36.1.31

Screenshots or Videos

No response

Crashlog/log

No response

commented

Fixed in 0.7a

commented

mod is checking every tile entity in the world

Not 100% right. We only check chat boxes. So if you don't place ~5000 chat boxes, it would not any weird latency.

Could you use the command /advancedperipherals debug and send me the output?

commented

Our original diagnosis of what was happening was wrong but it was still being caused by the tile check.
Issue was basically:
A player placed the chat box, set it up to be triggered by redstone.
It was cached, then they moved it over a block or so and put redstone back down.
When the chat event fires it checks the state which triggers the redstone that's connected to the now moved chat box.
And this caused a loop which lead to minecrafts watchdog crashing the server.

Command Output: https://gist.github.com/Bennyboy1695/ee540dba787809b3f6194c6ee21ef34a

commented

It was cached, then they moved it over a block or so and put redstone back down.

I don't quite understand what you mean, did he move the block with a piston?

When the chat event fires it checks the state which triggers the redstone that's connected to the now moved chat box.
And this caused a loop which lead to minecrafts watchdog crashing the server.

We don't check any state. We just check if at this position in the cache is an AP Tile Entity.
And how did he set it up to be triggered by redstone? With a lua script?

commented

I have used the chat box, I disagree. It does not cause severe lag.

commented

We don't check any state. We just check if at this position in the cache is an AP Tile Entity.

Chat boxes can both send and receive messages, these sent messages will trigger server chat events and by extension getTileEntities in your cache. The issue here is that getTileEntities can also cause block updates via isEmptyBlock which fires getBlockState internally.

If that block it's checking is a piece of unloaded redstone with a previous state that getBlockState can trigger an update which if hooked to a computer and lua script can yet again fire send message via a chat box triggering the entire process again.

By checking the block states to validate every chat box in the world on every chat message it can trigger a number of questionable conditions like this.

https://github.com/Seniorendi/AdvancedPeripherals/blob/8bef1bd5279803a9f4420ec4d3883076f951ff8d/src/main/java/de/srendi/advancedperipherals/common/events/Events.java#L29

https://github.com/Seniorendi/AdvancedPeripherals/blob/8bef1bd5279803a9f4420ec4d3883076f951ff8d/src/main/java/de/srendi/advancedperipherals/common/blocks/base/TileEntityList.java#L105

commented

Hm ...

these sent messages will trigger server chat events and by extension getTileEntities in your cache.

Are you sure? I have checked this in debug mode and message, sended by chatbox are not firing this event

Can I ask, please, to provide you world file, because seems, I am not very familiar with MC to understand problem from description. Or at least sceenshot/instruction how to cause problem.

Actually, I have a one solution, that might help, but I need to confirm problem first.

commented

@PurpleIsEverything @Bennyboy1695 Can you please, try this build: https://drive.google.com/file/d/1BQLPPt3HEJKPOtcyiAh811YJmlzVvb_3/view?usp=sharing

Basically, this is build from #136 and it should fix problem with block updating.

commented

Sorry for the delay! We will check shortly.

commented

Definitely looks like this should fix the problem, we can do some local testing however this issue was replicated on a larger public server running a community modpack. One thing players can do is create bugs you would never think possible.

So for now we will have to wait for that particular pack author to update their pack with these fixes! Thanks for your time and interest in fixing this particular issue looking over the changes I don't really see how this particular problem could reoccur.

We will update once this is tested on this particular server when the pack is updated.