Applied Energistics 2

Applied Energistics 2

137M Downloads

Crafting With Large Inventories Freezes Server

natedogith1 opened this issue ยท 2 comments

commented

Describe the bug
I have a 139 YABBA barrels connected to an AE system via an "Item Barrel Connector" and a storage bus. The barrels have infinity upgrades, and across all of them, there's about 276204000 items.

When I calculate the craft for anything (click "Next" on the "Select Amount" window) (tested with 1 certus quartz -> 1 charged certus quartz), the entire server freezes for several seconds.

To Reproduce

  1. Set up a small network with:
    • an interface with an encoded pattern (input can be anything, doesn't have to be in system)
    • a terminal (to attempt to start a craft)
    • a YABBA barrel with an infinity upgrade
    • a storage bus on the yabba barrel
    • some form of power for the network
  2. put a ton of items in the YABBA barrel (an easy way to do this is to put one item in and then nbtedit the count to a much larger value (something like 276204000))
  3. Open the terminal
  4. Click the craftable item to get to the "Select Amount" screen
  5. Click "Next"
  6. Notice the long delay.

Expected behavior
The server doesn't freeze.

Additional context
A stack trace while the server is frozen:

net.minecraft.item.Item.getItemStackLimit(Item.java:965)
net.minecraft.item.ItemStack.func_77976_d(ItemStack.java:248)
com.latmod.yabba.tile.ItemBarrel.extractItem(ItemBarrel.java:241)
com.latmod.yabba.tile.TileItemBarrelConnector.extractItem(TileItemBarrelConnector.java:240)
appeng.parts.misc.ItemHandlerAdapter.extractItems(ItemHandlerAdapter.java:134)
appeng.parts.misc.ItemHandlerAdapter.extractItems(ItemHandlerAdapter.java:53)
appeng.me.storage.MEPassThrough.extractItems(MEPassThrough.java:63)
appeng.me.storage.MEInventoryHandler.extractItems(MEInventoryHandler.java:117)
appeng.me.storage.NetworkInventoryHandler.extractItems(NetworkInventoryHandler.java:228)
appeng.me.cache.NetworkMonitor.extractItems(NetworkMonitor.java:93)
appeng.crafting.MECraftingInventory.(MECraftingInventory.java:141)
appeng.crafting.CraftingJob.(CraftingJob.java:90)
appeng.me.cache.CraftingGridCache.beginCraftingJob(CraftingGridCache.java:499)
p455w0rd.wct.sync.packets.PacketCraftRequest.serverPacketData(PacketCraftRequest.java:81)
p455w0rd.wct.sync.network.WCTServerPacketHandler$1.call(WCTServerPacketHandler.java:49)
p455w0rd.wct.sync.WCTPacket.func_148833_a(WCTPacket.java:97)
net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
net.minecraft.util.Util.func_181617_a(SourceFile:46)
net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:723)
net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397)
net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)
net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
java.lang.Thread.run(Thread.java:748)

Environment

  • Minecraft Version: 1.12.2
  • AE2 Version: rv6-stable-6
  • Forge Version: 14.23.5.2808
  • YABBA Version: 1.1.2.43
  • Mod Pack: Modern Skyblock 3 Departed 3.6.0
commented

This is basically what Forge considers acceptable performance. They simply don't take inventories into account, which are not vanilla chests and as long as this does not change, there isn't anything we can really do about it. (Neither YABBA nor we)

commented

If I'm understanding the code right. You're making a cache of the entire network by stimulating extracting everything. This could bev improved by special-casing stimulated extraction (if simulating extracting one stack works, I'd assume stimulating the same extraction 1000 times would also work, and therefore 999 iterations could be skipped)