Skip to content

Conversation

@michaelPoul
Copy link

Hi, here are 3 routing nodes bug fixes and one performance optimization:

  • Make Fluid output filters respect allowedAmount
    Fluid output filters would try to extract the amount given to them by the input filter, ignoring their own limits. This caused odd behavior where inputs limited to amounts such as 50 mb would insert 1000mb in the tank.
  • Fix input item routing filters not properly filtering
    All the input item filters derived from PreciseItemFilter had odd behavior since empty item stacks are treated like air in many comparisons.
  • Fix fluid routing with multiple nodes (fix Fluid routing issues #1657)
    see related issue
  • Improve item routing perf by reducing ItemStack copies
    Changes the item filter code to make less ItemStack copies and do less simulated ItemStack extractions, improving performance in large routing systems. Also adds a canSkip heuristic to prune filters that won't be used.
  • Rename TestItemFilter -> PreciseItemFilter
    I know the contributing guidelines say not to do unnecessary file renames, but I feel this one is useful since it better matches the ingame item name. Also, I think the old name was meant to be temporary ;). I can remove this commit though.

The commit messages have more information as well! I tested the routing out on a sample world w/one input and one output of each type (including default filters) and several tanks. It seems to work

This matches the name ingame
ItemStack copies (through ItemHandler::copy() or ItemHandler::extractItem())
are a rather expensive operation. This version only does item extraction when
the item matches both the input and output filter's conditions. Ideally,
this should mean roughly 1 copy per itemstack moved, although it could
be more if the input/output inventories fail to extract or insert.

This commit also adds a "canSkip()" heuristic function to item filters,
allowing filters that can neither accept nor provide items to be skipped.
transferThroughInputFilter was returning the amount it could still transfer, while TileMasterRoutingNode expected to receive the amount actually transferred.
ItemStacks with count <= 0 are empty, causing them to be treated as a
stack of air. Many comparisons with empty stacks will directly use air
as the item INSTEAD of the ItemStack's actual item.

Input filtering nodes were using negative stack sizes to get the amount
of items that can be pulled, causing incorrect comparisons.
Previously, they would drain the stack given by the input filter and
ignore their own output limits.
@michaelPoul michaelPoul requested a review from TehNut January 22, 2020 03:21
@michaelPoul
Copy link
Author

Looks like 0823493 was an already known issue: #1625

@keraldi keraldi added the 1.12 label Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fluid routing issues

2 participants