Optimize spout recipe generation by avoiding filling non-empty items #7274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Much of the time spent in Create's JEI plugin initialization is spent in
SpoutCategory
, where it iterates the entire list of JEI ingredients to generate filling recipes.Most of the bottleneck is in
getCapability
as Forge fires an event for every single call (due to the item stacks being freshly constructed). The optimization here is to avoid the secondgetCapability
call (that runs per registered fluid) by hoisting a check for whether the item could even be filled above the call. (We assume that a single-tank item cannot simultaneously be filled with two non-equal fluids.)Another player and myself see a 7-10x improvement in the
create:jei_plugin
loading time with this change, tested on 1.20.1 with the following mods:An additional optimization would be to reduce the number of items being probed for capabilities, e.g. by iterating the item registry, instead of iterating the list of ingredients in JEI. I did not implement this as it would likely cause some edge case recipes to disappear.