Applied Energistics 2

Applied Energistics 2

137M Downloads

Server lag when autocrafting using items from Mekanism Creative Bin

ToMe25 opened this issue ยท 7 comments

commented

Describe the bug

When using items from a mekanism Creative Bin for autocrafting in 1.16.3 the internal server freezes for a few seconds.

To Reproduce

  1. Build a simple ME system
  2. Attach a Creative Bin using a Storage Bus, and put sand into it
  3. Teach the ME system the sandstone recipes
  4. Try to let the ME system craft sandstone
  5. See the internal server freeze for a few seconds before showing the resources needed to craft the sandstone

Expected behavior

I would expect the me system to show the needed resources almost immediately like with items from almost every other item storage.

Additional context

I also reported this to the mekanism issue tracker(mekanism/Mekanism#6608) and got told this is likely to be a AE2 issue.
Forced Crash Log: https://pastebin.com/64RsgV6d
Test system i used to reproduce this in a new world:
2020-10-09_17 12 14

Environment

  • Environment:
    Applied Energistics 2 Version: 8.1.0-alpha.3
    Minecraft Version: 1.16.3
    Forge Version: 34.1.12
    Mekanism Version: 10.0.11
    Jei Version: 7.5.0.43
    OS: Ubuntu 16.04
commented

That is simply caused by how inefficiently they handle extracting items from it. Nothing we can really do about it on our side.

commented

@yueh I'll take a look at it. Supposedly they only expose a single item slot, so it should be seen as 64 items and that's it.

commented

So, I did check this. The bin has 1 slot that is reporting an item stack with a size of ~2 billion.

When we build the crafting screen, we try to extract the reported amount (2 billion), but the bin only returns 64. This sends AE into a loop trying to fullfill the request (even if simulated), which means it loops 2 billion / 64 times. Not great :-|

commented

Why does AE2 even try to extract everything that exists from everywhere possible, rather then only trying to extract items needed for the requested item?
Also thanks for writing here what is actually the thing that takes this long, so far i couldn't tell, and to my knowledge neither could the pupnewfster(mekanism).

commented

It does this to build a cache of available items, really. And generally it'll do this to check permissions as well as trying to figure out what the actual available amount is. (i.e. it's possible that subnetworks double-report depending on what crazy thing you do).

There's a problem with AE2's current approach of determining the item amount though. It tries to do a "dry-run" extraction, and will repeat this until it has the 2 billion items. But since it's a dry-run, it's pointless since nothing actually changes about the bin, so extracting over and over again will obviously succeed and always return 64 from the bin. The fix for this is actually not very nice however, since it'll reduce the available amount of items from the bin to 64 for each crafting operation. (Since the only sensible thing to do is to stop trying after the bin returns 64 items).

commented

I still don't understand why it tries extracting every single item from every single external storage, even if it doesn't need them for the recipe.
I may miss something, but for me it seems strange to try and extract everything, rather then just everything that has a connection to the recipe.
Edit: I think i understand that now.

commented

I have figured something new out in the meantime that might be helpful, with the mekanism bins attached to Storage Busses the time the resource calculation takes seems pretty linearly linked to the amount of items in attached bins.
Having one Creative Bin with 2 Billion items seems to take about 8-10 times the time as one with 200 million items.
Also the time it takes depends on the Bins attached to the system, not the bins with items used for this recipe.
So in the example above, i could have sand on a drive, and grass in the bin rather then sand, and the freeze time would not significantly change.