Lags with Molecular Assemblers
Livan-pro opened this issue ยท 8 comments
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?
Forge v10.13.4.1492 (KCauldron 1.7.10-1492.150)
Applied Energistics rv2-stable-10
Can you reproduce this with import and export busses or another pipe mod instead of EnderIO item conduits?
Successfully reproduced this with 8(!) molecular assemblers and import/export busses. All busses and molecular assemblers have maximum speed upgrades.
Recipe:
Normal ticking:
With Molecular Assemblers:
Setup:
- Tried this in single player, i.e clean Forge, not Cauldron.
- Removing binnie's mods isn't an option. It just reduce time by 30%. If players adds more Molecular Assemblers, it will lag again.
- I tried with minecraft items with identical NBT. Why not to cache recipes with NBT? This should help for items with equal NBT, right?
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)
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.
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;
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.
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:
- Try it without cauldron.
- Remove binnie's mods.
- Look if any mod is adding NBT data to itemstacks.
- 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.