Refined Storage

Refined Storage

77M Downloads

Crafting Upgrades in an Interface cause lag

tgstyle opened this issue ยท 8 comments

commented

Issue description:

When I have crafting upgrades in an interface it causes huge TPS spikes when the items to craft an item are not always available in storage.

What happens:

TPS increases 20+TPS

What you expected to happen:

No TPS Increase

Steps to reproduce:

  1. Place Crafting Upgrade in an Interface
  2. Place Item to craft in the Interface
  3. Make the Item it is to auto-craft not have what it needs in storage
    ...

Version (make sure you are on the latest version before reporting):

  • Minecraft: 1.12.2
  • Forge: 2760
  • Refined Storage: 1.6.5

Does this issue occur on a server? yes

commented

*It may require a stack upgrade in the Interface also

commented

I ran 2 samples starting with the stack upgrade and crafting upgrade inserted. Both the exporter and interface have the same issue, it's worse with the interface.

https://www.dropbox.com/s/lbco4jeixjn3qen/sampler-snapshot-interface.nps?dl=1
https://www.dropbox.com/s/cghmy3a7it1zial/sampler-snapshot-exporter.nps?dl=1

commented

I have a similar issue. It's gets worse the more complex a recipe is (more crafting steps). I think what happens is that every tick, or perhaps more often, the Interface checks to see if crafting is possible. For example trying to stock a stack of top tier food from pam's harvestcraft in an Interface with a Crafting Upgrade and External Storage attached, when missing just 1 base ingredient, doubles the tick duration from 20ms to 40ms on my Core i7 16GB RAM server.

A simple solution would be to limit the crafting upgrade in an interface to just 1 item per tick. And when crafting fails introducing a delay before checking again. A better solution would be to cache which ingredient failed and not recalculating the crafting command until that item is in stock again.

commented

On which version are you.

commented

Version 1.6.4

I checked the current code on github and noticed you don't speed limit the export function of the interface. The import part is speed limited however. This way a crafting request is done every tick. Perhaps the interface should be speed limited like the exporter? Also, without an stack upgrade, perhaps just request one item instead of the entire delta.

The best solution would be to cache failed crafting requests for a few ticks so you can fail them a lot faster in a large network.

commented

You're right, it needs to be throttled. Going to look into this this weekend.

commented

Fixed for 1.6.6.

Available on builds on Jenkins now already.

If your automated crafting task fails, prepare to get throttled 3 seconds before you can do the new request :-)