Severe performance issues with large inventories
What I expected to happen was...:
Your inventory items would not meaningfully effect performance
What actually happened was...:
Increase in mspt of about 5x with a full inventory
Using a datapack to run a command for all players with a certain SelectedItem every tick increases the mspt even more, a datapack running it 27 times per tick is enough to crash the server with a single player
Steps to Reproduce:
Create a bundle, fill it with 64 unique items
Create a shulker box, fill it with 27 copies of the bundle
Fill your inventory with the shulker boxes
Also effects 1.17.1
Linked issues
relates to 1
Attachments
Comments 8
Please provide the data pack, or an example data pack, so that we can test this. Would also be great if you could point out what exact command causes the performance issue.
I have provided the datapack, along with an example of playerdata that causes lag
The main cause of the lag seems to be
@s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{}}}{{{}{CustomModelData:2}{}}}{{{}}}]
selectors, since the performance increases when reducing the number of them and stays the same otherwise
The datapack will cause a lot more lag when holding a carrot on a stick, because it does an initial check for holding the carrot on a stick and then further checks for the custom model data if they are
Why do I feel like the answer to this issue is "uh nuh duh" given NBT compression reduces the memory usage geometrically provided the same items are stored together. For example a bundle filled with 64 of the same item in every slot of a shulker box filling every slot of a double chest would consume far less memory than the same situation but with dissimilar items simply due to how NBT compression works. Then higher memory usage results in more processing needed to load/unload chunks or parse player data.
Does MC-233604 describe your issue?