Applied Energistics 2

Applied Energistics 2

137M Downloads

Lags with Molecular Assemblers

Livan-pro opened this issue ยท 8 comments

commented

Hi. I have a server with Applied Energistics and many other mods. Recently TPS dropped to 5. There is WarmRoast screenshot. As I realized, this drop is caused by Molecular Assemblers, that doesn't connected to ME network(only energy), is receiving items from EnderIO conduits and crafting something. When I disabled Molecular Assemblers TPS back to 19-20. How can I deal with this?
WarmRoast screenshot

Forge v10.13.4.1492 (KCauldron 1.7.10-1492.150)
Applied Energistics rv2-stable-10

commented

Can you reproduce this with import and export busses or another pipe mod instead of EnderIO item conduits?

commented

Successfully reproduced this with 8(!) molecular assemblers and import/export busses. All busses and molecular assemblers have maximum speed upgrades.
Recipe:
Recipe
Normal ticking:
WarmRoast
With Molecular Assemblers:
WarmRoast
Setup:
Setup

  1. Tried this in single player, i.e clean Forge, not Cauldron.
  2. Removing binnie's mods isn't an option. It just reduce time by 30%. If players adds more Molecular Assemblers, it will lag again.
  3. I tried with minecraft items with identical NBT. Why not to cache recipes with NBT? This should help for items with equal NBT, right?
commented

We cannot really cache NBT for a couple of reasons.
We would have to do a copy of it for each and every assembler and itemstack, as using a shared NBT could change at any point and thus result in failures. Especially with some mods doing some pretty stupid things with NBT, you can assume that some NBT might have a size of several MBs. This can pretty easily waste several hundred MBs of memory and finally killing the server with it.

Forge is also pretty reluctant about improving their code (including minecraft), which could allow a pretty significant performance boost when looking up recipes or at least allow us to reliably cache the results without having memory issues. But their point is that some devs might have issues should they have to write correct code, so this cannot be done and all others have to pay the price for it. (For example compare the oredict recipes with the lower ones, which only take about 1% of it)

commented

Oh, ok. Aparently, my temporary solution isn't temporary.

commented

I am not really happy with this, but I simply do not have a good solution for now.

AE2 is already using a custom NBT implementation internally to share the same NBT data between different itemstacks, but these are also AE2 specific ones. Maybe this could be used with vanilla itemstacks, but I would not count on it.

Did you consider inversing your setup? So instead of dumping all possible ingredients into them, use a normal autocrafting setup and use it to keep a stock or export it indefinitely.

commented

What you mean? Currently, with my modification, Molecular Assemblers working with normal autocraft. I just made them to ignore patterns in slot 10. Normal autocraft(with ME interfaces) isn't causing TPS drops.
In appeng/tile/crafting/TileMolecularAssembler.java, recalculatePlan() I replaced this:

        final ItemStack is = this.inv.getStackInSlot( 10 );

        if( is != null && is.getItem() instanceof ItemEncodedPattern )
        {
            if( !Platform.isSameItem( is, this.myPattern ) )
            {
                final World w = this.getWorldObj();
                final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
                final ICraftingPatternDetails ph = iep.getPatternForItem( is, w );

                if( ph != null && ph.isCraftable() )
                {
                    this.progress = 0;
                    this.myPattern = is;
                    this.myPlan = ph;
                }
            }
        }
        else
        {
            this.progress = 0;
            this.forcePlan = false;
            this.myPlan = null;
            this.myPattern = null;
            this.pushDirection = ForgeDirection.UNKNOWN;
        }

with this:

        this.progress = 0;
        this.forcePlan = false;
        this.myPlan = null;
        this.myPattern = null;
        this.pushDirection = ForgeDirection.UNKNOWN;
commented

Because it's public server, I even don't know where this molecular assemblers and how many of them there is. But I will try to reproduce this in new world with busses.
And as temporary solution I just made Molecular Assemblers to ignore patterns in it.

commented

This is not really an AE2 issue, but in general an issue about how inefficient recipe looks in forge are and in particular binnies mod which takes the majority of time to process.

We already try to cache as much as possible, but this is not possible for items using NBT and there are/were some mods adding random NBT data to every itemstack.

Also keep in mind that you are using cauldron, which is unsupported and might also be the cause of it.

Your best options are really:

  1. Try it without cauldron.
  2. Remove binnie's mods.
  3. Look if any mod is adding NBT data to itemstacks.
  4. If NBT heavy recipes are used, try to filter the insertion first instead of trying to dump every item entering the network into the assembler.