Skip to content
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

Optimize recipe search by checking against last cached recipe before anything else #47

Merged
merged 1 commit into from
Feb 5, 2022

Conversation

FxMorin
Copy link
Contributor

@FxMorin FxMorin commented Jan 30, 2022

Firstly, auto crafting tables can cause a performance impact when used very often in large farms.
The main reason for this is due to the recipe lookup, which searches through all recipes.

So what I did was use the already existing last recipe, and attempt to check it first. This is a great performance boost since it drastically speeds up all the auto crafting tables in farms.

old = current state, new = with cache
image
Accidentally left the one with cache running for 10 seconds longer than the old one (after tick warp), either way, it shows the point.

image

As you can also see, the extra match against the last cache added 62ms to the total checks which are nearly negligible. So adding 62ms to all auto crafting tables is worth it for the performance boost that this offers.

@FxMorin
Copy link
Contributor Author

FxMorin commented Jan 30, 2022

As a side-effect, it fixes #46
Cause this is the same check which causes mass crafting to lag

@gnembon gnembon merged commit db7f1af into gnembon:master Feb 5, 2022
@FxMorin FxMorin deleted the optimize_cache_previous branch February 5, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants