Skip to content

Finish processor link changes optimization#12232

Open
cardillan wants to merge 1 commit into
Anuken:masterfrom
cardillan:processor-links
Open

Finish processor link changes optimization#12232
cardillan wants to merge 1 commit into
Anuken:masterfrom
cardillan:processor-links

Conversation

@cardillan

Copy link
Copy Markdown
Contributor

Commit d13afc1 contains changes to optimize processor link changes, but the job wasn't finished. The new code only runs when a linked block is deleted. When links to existing blocks are added/removed via GUI, the code is still recompiled from scratch.

I've updated the code which manages adding/removing links to use the new system. For this to work, the variables representing linked blocks must exist in the executor (so that they're available via optionalVar()), so I'm copying them from the assembler to the executor as well - built-ins and literals are still excluded to keep the array small.

As a side effect, it is now possible to read linked blocks which also exist as a variable in the code via the read instruction. This is a bit inconsistent, as blocks that are linked but not referenced from the code can't be read that way. There's the #11838 PR for that; if you accept this PR, I'll update that one to be compatible.

If your pull request is not translation or serverlist-related, read the list of requirements below and check each box:

  • I have read the contribution guidelines.
  • I have ensured that my code compiles, if applicable.
  • I have ensured that any new features in this PR function correctly in-game, if applicable.

stop = false;
nameMap = null;
vars = builder.vars.values().toSeq().retainAll(var -> !var.constant).toArray(LVar.class);
vars = builder.vars.values().toSeq().retainAll(var -> !var.constant || var.name.charAt(0) != '_' && var.name.charAt(0) != '@').toArray(LVar.class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to add only the constants representing the linked variables here, to keep the array small. Before, all constants were excluded. Now I'm excluding the constants representing mlog literals (triple underscore) and builtin variables (@this, @links, etc.). What remains should be the constants representing linked blocks.

I could include the builtins as well, and they would be remotely readable, but the only really useful one is @links, and since links can't be read remotely anyway, its utility is limited. I'd probably add them in #11838.

@Anuken

Anuken commented Jun 21, 2026

Copy link
Copy Markdown
Owner

but the job wasn't finished. The new code only runs when a linked block is deleted. When links to existing blocks are added/removed via GUI, the code is still recompiled from scratch.

The purpose of the new code was to fix exponential lag machines caused by spamming processors with hundreds of links - one block change could cause hundreds of processor re-links per second. As far as I'm aware, there is no way to do the same by manually configuring blocks, due to the config rate limit.

Did you run into some performance issues with the current code?

@cardillan

Copy link
Copy Markdown
Contributor Author

In that case it was a misunderstanding on my part. I assumed the intent was to have a single way to manage links, and perhaps to allow managing links from logic one day.

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.

3 participants