Applied Energistics 2

Applied Energistics 2

156M Downloads

Performance issues with shift click crafting

yueh opened this issue ยท 0 comments

commented

Description

Shift clicking inside a crafting terminal can cause a major performance issue.

This is actually not directly caused by AE2, but due to the CraftingManager.findMatchingResult() being a major issue. Especially once it gets crowded due to a large amount of mods.

There are not many options for AE2 itself. One good option is to only validate a complete crafting grid and not per changed slot. Which would reduce the amount of recipe lookups by up to 8. But this is still just a linear improvement. Should the lookup through forge scale worse with the amount of mods/recipes/handlers it might not solve anything.

Another option would be to avoid looking up a new recipe, if the inventory is actually unchanged after refilling it from the network. But this can certainly run into issue for very special cases (e.g. some has the idea to limit the recipe of once per day or so). But it might provide a very noticable improvement as it would reduce it to one lookup until the grid has actually changed. For example by about 63 looks up for a single shiftclick should the output be 1 per craft and stack up to 64.
It would be a balance act between risking breaking some very special crafting recipes and a better performance for everything else.

An idea for a minor improvement might be to refill the grid before crafting. A full lookup seems to be a bit faster than a partial one. So ensuring that no slots actually changes besides the stacksize might be a minor improvement. But it comes with a hefty cost as we could no longer use oredict items as replacement due to being unable to put them into an occupied slot.

See the attached zip for two .nps snapshots with a very crude hack to validate the recipe once per grid vs for every slot change.

Environment

NPS snapshots
shift-click-sampling-results.zip
shift-click-1-per-slot.nps - Validate the crafting grid/recipe per slot changed
shift-click-1-per-matrix.nps - Validate the crafting grid/recipe once finished/last slot changed