Applied Energistics 2

Applied Energistics 2

156M Downloads

TPS Lag when coupled with Storage Drawers

nrllewellyn opened this issue ยท 9 comments

commented

Description

NOTE: This is simply a cross-post of a bug in Storage Drawers, in case there is any relevant discussion to have between mod authors. I'm pretty sure that the slowness is on their side.

Issue in Storage Drawers' repo: jaquadro/StorageDrawers#442

I have found that Storage Drawers causes extreme TPS lag when coupled with the AE2 storage bus and AE2 autocrafting. My setup includes:

  • A large set of drawers with a drawer controller
  • An AE2 system set up to with a storage bus on the drawer controller
  • An AE2 autocrafting system
  • An AE2 export bus with the crafting card attempting to export a crafted item to another inventory

When I profile the running application, 46.8% of the server thread's time is being spent in these two methods:
com.jaquadro.minecraft.storagedrawers.inventory.DrawerItemHandler.extractItem() 33.696033 60,314 ms (33.7%) 60,314 ms
( Most of the time in this method is being used here: com.jaquadro.minecraft.storagedrawers.storage.BaseDrawerData.getStoredItemCopy() 22.505943 40,284 ms (22.5%) 40,284 ms)
com.jaquadro.minecraft.storagedrawers.inventory.DrawerItemHandler.getStackInSlot() 10.388455 18,594 ms (10.4%) 18,594 ms

Not sure if this is something that can be resolved, or is just a limitation of mixing the two mods, but I thought you might want to know!

Environment

Minecraft: 1.10.2
Forge: 12.18.3.2239
Applied Energistics: rv4-alpha-11
Storage Drawers: 3.6.0

commented

Almost forgot the relevant AE2 parts that were lagging. A rough call chain is:
appeng.me.storage.NetworkInventoryHandler.extractItems() -> appeng.me.storage.MEInventoryHandler.extractItems() -> appeng.me.storage.MEPassThrough.extractItems() -> appeng.parts.misc.ItemHandlerAdapter.extractItems() -> appeng.parts.misc.ItemHandlerAdapter.extractItems()
(I'm guessing those last two have different method declarations, but VisualVM doesn't show that!)
Inside the extractItems method, almost all of the time is spent inside Storage Drawers' methods.

commented

ItemStack handling in 1.10 is really bad in terms of performance (forge itself). Especially when handling a large amount of copies (StorageDrawers) very frequently (autocrafting export buses). It is certainly better compared to 1.7.10 AE2 or StorageDrawers, but Forge has some new regressions to negate it to some degree.

Thus there is probably not much we can do.

commented

The problem is with the interaction between AE2 and Storage Drawers. The equivalent setup using Refined Storage does not have this issue.

commented

If it helps, using an external crafting device (e.g. the Crafter from Ender IO) with a normal export bus does not lag in this setup. It's only when a crafting upgrade is used. Is it possible that the code is pre-caching the items for the crafting operation before checking to see if there would be space to insert the finished product?

commented

I just reproduced this without the export bus. Connecting the Storage Bus to the Drawer Controller and request an auto-crafting operation causes the game to hang for a few seconds, and then the request is ignored.

commented

@soronthar What do you mean request is ignored?

If you mean clicking the start button does not start the craft, then that is likely a problem with your use of compacting drawers, as AE2 has no way to know that the stacks the drawers report are OR, not AND counts, so simulation completes, but extracting the items to start fails.

commented

I tried four scenarios:

  1. Crafting a blank pattern, as it requires Iron and in my setup Iron is stored in a Compacting Drawer.
  2. Crafting planks, the wood is stored in a normal Storage Drawer
    It took a minute or two to show the simulation UI, and then I quit the screen after 3 minutes waiting for something to appear.
  3. Crafting Polished Stone (from Quark), it uses Stone Slabs and they were stored in a drive.
    After a little while the simulation UI appeared and I could start the request (which ended succesfully)
  4. Crafting Polished Stone, this time without being connected to the Drawer Controller.
    In this case there was no wait at all.

In the first three scenarios, the message "Waiting for Server" was shown in the TOP box. I took a pair of screenshots:
http://imgur.com/a/XxuyM

commented

How many drawers are connected to the drawer controller? As Yueh mentioned earlier it can cause issues in large volumes

commented

there are 50 drawers with around 50 item types (a mix of 1x1, 1x2 and 2x2, some are empty), and 21 compacting drawers.