Skip to content

Add check to not cache invalid recipes#4486

Merged
jurrejelle merged 1 commit into1.20.1from
jj/speedup-match-recipe-logic
Jan 21, 2026
Merged

Add check to not cache invalid recipes#4486
jurrejelle merged 1 commit into1.20.1from
jj/speedup-match-recipe-logic

Conversation

@jurrejelle
Copy link
Copy Markdown
Contributor

What

Adds back a check to not invalidate recipes. This was caused by the r -> true change in #3986

Implementation Details

what happened before the r -> true change AKA scenario A:

  1. iterate over all gtrecipes through the lookup
  2. for every recipe, try to call matchRecipe(r) before returning it (expensive)
  3. if it succeeds, return it,
  4. fully modify it, call matchRecipe(r) again (expensive)
  5. if this post-modified check fails, store the recipe in lastFailedMatches and go back to 2 with the next recipe
  6. if this post-modified check succeeds, return the recipe.

after the r->true change AKA scenario B:

  1. iterate over all gtrecipes through the lookup
  2. fully modify it, call matchRecipe(r) (expensive)
  3. if this post-modified check fails, store the recipe in lastFailedMatches and go back to 2 with the next recipe
  4. if this post-modified check succeeds, return the recipe.

The error here is that recipes that never passed the pre-modified matchRecipe(r) check go into the lastFailedMatches (because that check doesn't exist anymore), causing significant slowdowns and logic errors

after this PR aka scenario C:

  1. iterate over all gtrecipes through the lookup
  2. fully modify it, call matchRecipe(r) (expensive)
  3. if this post-modified check succeeds, return the recipe.
  4. if this post-modified check fails, do another check for matchRecipe(r) pre-modified
  5. if this pre-modified check succeeds, store the recipe in lastFailedMatches
  6. go back to 2 with the next recipe

So in the happy path, it's faster than scenario A since we no longer call matchRecipe(r) on the pre-modified recipe. but in the unhappy path, we still call the check and don't store incorrect recipes in the cached miss list

Ty to luckyblock for reporting here: https://discord.com/channels/701354865217110096/1089296351906504835/1462466586022641933

@jurrejelle jurrejelle requested a review from a team as a code owner January 18, 2026 16:05
@jurrejelle jurrejelle added type: bugfix General bug fixes 1.20.1 Release: Patch - 0.0.X Smaller changes that either are bug fixes or very minor tweaks. labels Jan 18, 2026
@github-actions github-actions bot added the Tests: Passed Game Tests have passed on this PR label Jan 18, 2026
@jurrejelle jurrejelle merged commit 195bed9 into 1.20.1 Jan 21, 2026
5 of 6 checks passed
@jurrejelle jurrejelle deleted the jj/speedup-match-recipe-logic branch January 21, 2026 09:34
screret pushed a commit to screret/GregTech-Modern that referenced this pull request Jan 24, 2026
screret pushed a commit to screret/GregTech-Modern that referenced this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20.1 Release: Patch - 0.0.X Smaller changes that either are bug fixes or very minor tweaks. Tests: Passed Game Tests have passed on this PR type: bugfix General bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants