CyclopsMC / IntegratedTunnels

Transfer other energy, items and fluids over Integrated Dynamics networks
MIT License
20 stars 13 forks source link

Item importer in combination with aerial inerface from pneumaticcraft causes siginificant lag #276

Closed AlexiyOrlov closed 9 months ago

AlexiyOrlov commented 9 months ago

Issue type:


Short description:

If you place an item importer to extract specific items from aerial interface from pneumaticcraft, it will cause significant lag. I used Spark to find the cause.

Steps to reproduce the problem:

  1. Set up Aerial Interface.
  2. Set item importer to extract specific items from the interface, like cobblestone, lapis, diorite, andesite, granite.

Versions:

Profiler output:

https://spark.lucko.me/FV8c66RiDE

rubensworks commented 9 months ago

Thanks for reporting!

rubensworks commented 9 months ago

There's not much I can do about this on IT's end I'm afraid. The actual lag itself is coming from the code of pneumaticcraft, which in turn invokes the very costly ItemStack.copy().

The only thing that you could do on IT's end is lower the tickrate of the item importer (see its part settings).

AlexiyOrlov commented 9 months ago

Hm. I already reported this to Pneumaticcraft, but they said they can't do anything https://github.com/TeamPneumatic/pnc-repressurized/issues/1226

rubensworks commented 9 months ago

Modifying the tickrate is the only thing you'll be able to do then. See also this: https://github.com/TeamPneumatic/pnc-repressurized/issues/1226#issuecomment-1734263934

desht commented 9 months ago

Hi, PNC author here. You're totally right that ItemStack#copy() is an expensive op, but technically it's Forge that's doing it here :smile: For the Aerial Interface, I do need to wrap the player's vanilla Inventory with something that mods can interact with, i.e. an IItemHandler. And the docs for IItemHandler#extractItem specifically state:

The returned ItemStack can be safely modified after, so item handlers should return a new or copied stack.

So I don't think there is much I can do here; if you have any thoughts, I'd be interested to hear...

(Note: not at all attempting to blame IT here, just to be clear!)

rubensworks commented 9 months ago

@desht Yep, I agree, there's not much that can be done to improve performance here using the IItemHandler interface.

One possible solution however could be to look into the slotless item handler and the IInventoryState, which is recognized by IT. (not saying you have to do this, just that it's an option :-) )