ChestSort icon indicating copy to clipboard operation
ChestSort copied to clipboard

Lag TPS Issue when accessing containers

Open DarkChromaMC opened this issue 1 year ago • 5 comments

Used ChestSort version 14.1.0

Used Spigot version 1.21.1

Describe the bug When opening a container with lots of shulkers, the server TPS gets a lag spike.

To Reproduce Open this shulker by pasting schematic and repeatedly open it chest.schem.zip

Expected behavior No lag when opening containers

Additional context It seems to be caused by de.jeff_media.chestsort.listeners.ChestSortListener.onChestClose()

Spark profile: https://spark.lucko.me/qTH7xF7Xxg?hl=11900 Server version: 1.21.1

DarkChromaMC avatar Oct 02 '24 09:10 DarkChromaMC

Pro tip: Don't call Inventory#getHolder half a billion times. Chest closing isn't the only thing that triggers this incredibly expensive method.

IllusionTheDev avatar Oct 02 '24 13:10 IllusionTheDev

Pro tip: Don't call Inventory#getHolder half a billion times. Chest closing isn't the only thing that triggers this incredibly expensive method.

Feel free to pull request improvements :) I don‘t think that calling a simple getter will have any significant impact though.

mfnalex avatar Oct 02 '24 14:10 mfnalex

Pro tip: Don't call Inventory#getHolder half a billion times. Chest closing isn't the only thing that triggers this incredibly expensive method.

I don‘t think that calling a simple getter will have any significant impact though. getHolder clones vanilla inventories. It's fairly known, and clearly visible by the spark output. image

IllusionTheDev avatar Oct 06 '24 17:10 IllusionTheDev

Please try whether ChestSort 14.1.1 fixed this

mfnalex avatar Oct 06 '24 18:10 mfnalex

It fixes to a small extent. not as good as #198

IllusionTheDev avatar Oct 06 '24 19:10 IllusionTheDev