New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issues with shift click crafting #3040

Closed
yueh opened this Issue Aug 18, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@yueh
Member

yueh commented Aug 18, 2017

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

@yueh yueh added this to the rv5.alpha - 1.12 milestone Aug 18, 2017

yueh added a commit that referenced this issue Aug 18, 2017

Fixes #3040: Cache recipe and revalidate it
This caches the last used recipe instead of only the result. Which
allows to revalidate the crafting grid against the recipe itself before
hitting the CraftingManager again. Therefore avoiding a high performance
hit for recipe lookups, just find the potential same recipe again.

@yueh yueh closed this in b8e685b Aug 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment