Rhl cache - #5165
Open
GilbertzRivi wants to merge 4 commits into
Open
Conversation
jurrejelle
requested changes
Jul 22, 2026
jurrejelle
left a comment
Contributor
There was a problem hiding this comment.
only nits I have, I do want reviews by some others as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adding cache to recipe handler so it can skip searching for recipes when nothing in the inputs/outputs changed
Implementation Details
I added RecipeCapabilityVersions, one instance per IRecipeCapabilityHolder, holding three counters and a cached group map, inputVersion and outputVersion that are bumped on handler content changes and topologyVersion that is bumped when the handler set changes for example when you add a bus or paint it.
AI Usage
Agent Used
ClaudeCode Opus 4.8
Agent Usage Description
I used it for basic sanity checking my work if i didn't miss anything important, and to help me get a wider view of the repo and the thing i wanted to do. I also used it to make a tool to measure the performance but it was not commited to the repo as it was only a tool.
Outcome
It increases performance in bases with hundreds of machines and on weaker hardware.

How Was This Tested
My friend tested this on 7.5.3 then I moved all changes to this branch and on weaker CPU in endgame monifactory base the change was impressive

it says 10.09 sec saved in 10s window because it was assuming the game runs at stable 20tps and it actually ran at ~7tps so it was not 10s but ~30s window, still about 1/3 time saved. Its also an estimation, it was comparing cache hit time vs full search, but the amount of measurements is high so I guess its rather accurate.
Additional Information
I also tried to optimize handle recipe itself but its so fast that cache hit was slower than the real recipe handling on average.

All I did with that is calling it less frequent when the machine is idle and the conditions are the same, and the machine reports no errors.
Additional Information 2
i changed
so energy containers that override the getter report their real stored energy and are no longer skipped as empty by the prefilter.
Additional Information 3
My friend profiled this change and a change to stocking input buses (I'll pr it next) with spark and the results are bellow (screenshots + links because links expire):




OLD: https://spark.lucko.me/MjRH6gc91y
NEW: https://spark.lucko.me/JmBrjCa5tZ
I also profiled this a bit earlier when not all the current changes were implemented and I did it on a weaker laptop, results bellow:
OLD: https://spark.lucko.me/MfsQrUmAzH
NEW: https://spark.lucko.me/XWbaUwQIkc