Repository navigation
Fuzz client-local code; merge locals across locality - #1483
Conversation
Constant and copy propagation refused every value the local-player analysis marks as dependent, "deliberately conservative" since #1207. A propagation replaces a read of a local by the local or constant it is known to hold at that point: on every client the replaced read sees the value the original read saw, and no computation moves, appears or disappears, so it cannot make clients diverge. The passes which do move code (the local merger, the branch merger) keep their locality checks. In UI code, where most values derive from client-local frame state, the guard kept almost every copy the inliner makes. Without it the pass needs no locality analysis and is an ordinary pass; the function splitter builds the analysis for the local merger only, after the propagation.
LocalPlayerFuzzTests generates random programs full of client-local values (GetLocalPlayer(), the client's width and activity, as UI code reads them): branches, loops, breaks and early returns on them, copies, globals, fields, allocations and calls. Each program is compiled to Lua without optimisations and with -localOptimizations, with and without -inline, and every build runs in Lua once per simulated client. On every client an optimised build has to make the same calls with the same arguments as the unoptimised one. CI runs 25 programs; WURST_FUZZ_PROGRAMS and WURST_FUZZ_SEED run a campaign. A failing seed keeps its program and both scripts in test-output/fuzz. Planted bugs it catches: copy propagation keeping facts at a join where the predecessors disagree (35 of 60 programs), the local merger merging int or boolean locals whose live ranges overlap (118 and 46 builds of 120).
The local merger kept client-local and synchronised locals apart only so that the locality analysis, made before it, stayed true for the passes which read it later in the sweep. Since copy propagation reads it no longer, no pass does, and merging two locals with disjoint live ranges holds on every client the values the two held. The merger is an ordinary pass now, and the local optimisations build no locality analysis: on an optimised Lua build of a large map they take 5.5 s instead of 6.7 to 7.2 s and the build about 2 s less, with the script within 0.03%. The function splitter and the old-generics cast merge call the merger without one. The inliner's register budget still counts the two as separate classes, which over-estimates now; counting per type changes what is inlined and costs more build time than it saves (BACKLOG).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 351026bdd5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f967932ca5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41ef89eb71
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…t-locality # Conflicts: # de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/optimizer/FunctionSplitter.java # de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/optimizer/LocalPlayerContextAnalyzer.java # de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imoptimizer/ImOptimizer.java
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6eb3befe31
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Builds on #1482 (its commits are in this branch until it is merged; merge that first).
Differential fuzzing of client-local code
LocalPlayerFuzzTestsgenerates random programs full of client-local values:GetLocalPlayer(), plusBlzGetLocalClientWidth()andBlzIsLocalClientActive(), which the locality analysis treats as client-local the way it treats UI state. The programs branch, loop,breakandreturnearly on those values, and mix in copies, globals, fields, allocations and calls. Each program is compiled to Lua without optimisations, with-localOptimizations, and with-inline -localOptimizations. Every build runs in Lua once per simulated client (4 clients), with the client-local natives answering for that client. On every client, an optimised build must make the same calls with the same arguments as the unoptimised one. Allocations (CreateGroup) are logged too, so an optimisation that moved, dropped or duplicated one per client would show.WURST_FUZZ_PROGRAMS/WURST_FUZZ_SEEDrun a campaign; a failing seed keeps its program and both scripts intest-output/fuzz.Merge locals across locality
The local merger kept client-local and synchronised locals in separate variables only so that the locality analysis, built before it, stayed true for the passes reading it later in the sweep. After #1482 no pass does. A merged local holds on every client the values the separate ones held, so the merger becomes an ordinary pass and the local optimisations no longer build the analysis at all.
Optimised Lua of a large map, two alternating runs each:
A second large map: -0.01% instructions. No new locals-table spills.
The inliner's Lua register budget still counts client-local and synchronised locals as separate classes. That over-estimates now, which is safe. I measured counting per type instead: more arithmetic helpers then fit, the late helper phase re-runs the local optimisations (+3.2 s), and the main inliner's decisions shift (+0.17% instructions). So that is left out and recorded in BACKLOG.
Tests
LuaTranslationTests.luaLocalMergerReusesSlotsAcrossLocality: aGetLocalPlayer()local and aPlayer(0)local with disjoint live ranges share one Lua local; on Propagate copies of values which depend on the local player #1482 they get two.LocalMergerunit tests calloptimize(translator);LocalPlayerAwareOptimizerPasshas no implementations left and is removed.OptimizerTests,LuaBackendAuditTests,LuaTranslationTests,LocalPlayerContextAnalyzerTests,ObservableEffectsTests,DeterministicChecks,CompiletimeTests,BugTests,ClassesTests, the Lua backend classes andLocalPlayerFuzzTests, 995 tests.