Stocking optimization - #5169
Open
GilbertzRivi wants to merge 3 commits into
Open
Conversation
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
Rework to stocking input buses and hatches
Implementation Details
This makes stocking buses and hatches managed by a grid service from AE2, so instead of each bus polling for all its items each 40 ticks, AE2 keeps track of all stocking parts in the grid and updates them accordingly. AE2 keeps a cached inventory updated each tick anyway, so based on that cache if any item that is observed by any bus (or fluid by hatch) changed in quantity, AE2 remembers and when the bus's tick is due, it checks the real extractable amount from the network (at most once per key per tick) and then updates all parts tracking that key. It also updates them silently and after its done then notifies their listeners, so 5 changes in the same bus will notify its RHL only once. Autopull is now also managed from the grid service, it does check for the top X keys in the network cache, then tries to fill the bus with those keys checking extractable amounts while doing so for valid candidates. It does also checks if a key is valid for the bus, if it does not exist in any other bus in the same group (painting or just not distinct).
AI Usage
Agent Used
ClaudeCode Opus 4.8
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 improves performance a lot on a bases that rely heavily on stocking buses/hatches
How Was This Tested
My friend tested this both with #5165 on 7.5.3 then I moved all stocking bus/hatch changes to this branch and on weaker CPU in endgame monifactory base the results were good, stocking parts no longer were top1 in observable and stopped taking 26% instead they took 0,8%.



before:
after:
Additional Information
it wont work without #5168 because it fixes me hatches/buses UI so it works at all. Didn't want to make it in 1 PR in case you don't want this one.
Additional information 2
My friend profiled #5165 change and a this one 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