major rewrite to pattern buffers#4910
Open
GilbertzRivi wants to merge 11 commits into
Open
Conversation
screret
suggested changes
Jun 5, 2026
screret
left a comment
Contributor
There was a problem hiding this comment.
please don't use var for 'simple' types (e.g. ones without nested generics); it makes code harder to read in the github review UI.
…PatternBufferPartMachine.java Co-authored-by: screret <68943070+screret@users.noreply.github.com>
…PatternBufferPartMachine.java Co-authored-by: screret <68943070+screret@users.noreply.github.com>
…PatternBufferPartMachine.java Co-authored-by: screret <68943070+screret@users.noreply.github.com>
…PatternBufferPartMachine.java Co-authored-by: screret <68943070+screret@users.noreply.github.com>
…PatternBufferPartMachine.java Co-authored-by: screret <68943070+screret@users.noreply.github.com>
This was referenced Jun 22, 2026
screret
approved these changes
Jun 23, 2026
# Conflicts: # src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEPatternBufferPartMachine.java
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
Remake of pattern buffers to improve performance
Implementation Details
The base greg buffers have 27 pattern slots, each is acting like a distinct input bus for a multiblock, so its basically like slapping 27 distinct dual hatches on the multiblock and it has to scan them all for recipes. So i made it so each buffer has only 1 distinct bus, for all its patterns, but it has blocking mode with allow the same pattern to be pushed and there is additional bus for each proxy. So 1 buffer + 3 proxy is 4 distinct busses for the multi to scan for recipes. It also allows to make bigger buffers for mod developers without them being unusable due to lag. From what i understand it should work roughly the same because a multi will do only 1 type of a recipe at once anyway. But because there is another bus for each proxy, 4 machines can make 4 recipes, all machines also see all busses so if only 1 pattern is used at the time all machines can do it in parallel and each can use max parallels because blocking allows the same pattern to be pushed. It also does one additional check before running the recipe handler, it checks if any item or fluid the slot has currently in its inventory matches any from the recipe and only if it does it runs the recipe handler. It also short circuits when the slot is just empty. The blocking mode with allow the same works like that each pattern pushed is held in a list and only pattern that is the same as the one in the list is allowed to be pushed to the slot, and it also will push the same pattern to the same slot always. I also added caching on some things that get queried more than once per tick.
AI Usage
Agent Used
ClaudeCode Sonet 4.6
Agent Usage Description
I used it to dig into the code so I can get a wider view of the repo easier. It was also used in very early stages of developing to make some base and boiler plate I can work with. The whole system, what it does and how it works, i came up with myself in 100%.
Outcome
Heavily optimizes pattern buffers.
How Was This Tested
It is a part of my addon that I added to my instance of monifactory. I use it heavily and they are not lagging my server almost at all. For comparsion when I first unlocked pattern buffers, i made one and used it on my ABS tower, my TPS fell down to 3 after I connected it to ME system instantly. Now I moved the code from my addon here and tested on dev instance with a few RHFs and LCRs, and they work as expected.
Additional Information
The comparsion chart bellow shows base buffers vs expanded from gtmutils vs insane buffers, where the insane are the ones I made with my custom logic. The optimization mentioned is done in another PR here

Potential Compatibility Issues
If the buffer has anything inside its slots, after this update it will lost those runtime items.