Build item cache used up too much time
Holi0317 opened this issue ยท 1 comments
Describe the bug
Our server now use around 7 minutes to build RS item cache on bootup. After some profiling, we found out RS is spending too much time on indexing enchanted books in our system. We currently got 464,471 enchanted books in our system.
We made a custom RS build to log out how much time is spent on indexing each item. The analysis is not very accurate as it's just using nanoTime
but enchanted books are using 100x time compare to item without NBT and 10x time compare to item with simple NBT.
Profile shows that JVM is spending time on com.refinedmods.refinedstorage.api.util.IComparer#isEqualNoQuantity
in method com.refinedmods.refinedstorage.apiimpl.util.ItemStackList#add(net.minecraft.item.ItemStack, int)
. One possible solution would be disable item stacking for hard-coded/configerable list of items. That may solve the performance issue with stacking large NBT items.
How can we reproduce this bug or crash?
- Put large amount of enchanted book in RS system
- Reboot server
What Minecraft version is this happening on?
Minecraft 1.16.5 (Enigmatica6 0.5.21)
What Forge version is this happening on?
36.2.22
What Refined Storage version is this happening on?
1.9.16
Relevant log output
No response
I fixed this personally with a mixin mod that only invalidated networks once per tick - ideally this should be integrated into RS itself soon though. It's available at https://github.com/RaVenInTheDark/RSFreezeFix/releases/tag/1.0, and it's open source with an MIT license so there should be zero issue in porting it directly (although there's probably better methods.)
I've tested this on an e6 server and it dropped 15+ minute first tick times to mere seconds, with no issues found so far.