Skip to content

Keep dataflow anomaly states in arrays instead of copied maps - #1479

Merged
Frotty merged 1 commit into
masterfrom
dataflow-state-arrays
Oct 17, 2026
Merged

Frotty merged 1 commit into
masterfrom
dataflow-state-arrays

Conversation

@Frotty

@Frotty Frotty commented Oct 17, 2026

Copy link
Copy Markdown
Member

The dataflow anomaly analysis (uninitialised reads, use after destroy, never-read assignments) rebuilt its whole map of locals on every read and write, and a local's multimap of reads on every read of it, so a long body with loops cost roughly the square of its size.

A state is now an array indexed by per-body ids of the locals; each local keeps sorted arrays of write ids and of (write, read) pairs. An operation copies the array once, and a merge returns one of its inputs when that input already holds the union. The lattice and its equality are unchanged, so the fixpoint takes the same steps and reports the same diagnostics. Utils.mergeMaps, mergeMultiMaps, mergeSets and Function2 had no other users and are removed.

Measured

Old and new implementation side by side in one JVM, each body analysed by both, alternating which runs first (both totals include the attribute evaluation they share):

bodies before after
large Lua map A 25,683 996 ms 369 ms
large Lua map B 13,799 972 ms 551 ms

The slowest single body went from 184 ms to 8 ms. On map A the analysis was about 3% of a 35 s unoptimised build.

Verified

  • Same oracle on both maps and on the 430 tests of FlowAnalysisTests, ClosureTests, SimpleStatementTests, BugTests, NewFeatureTests and ClassesTests: identical number of transfer steps per body and identical diagnostics. The only difference was the order of one local's never-read warnings in two tests.
  • Map A's emitted Lua is byte-identical.
  • Touched classes plus UtilsTest pass locally (Windows). The change is in-memory only, with no file, path or process handling.

Behaviour change

The never-read warnings of a body now come in the order of the locals' declarations and, per local, in source order. Before, the order followed the order in which branch states reached the end of the body. FlowAnalysisTests.neverReadAssignmentWarningsComeInSourceOrder fails on master and passes here.

The analysis rebuilt its whole map of locals on every read and write, and a
local's multimap of reads on every read of it, so a long body cost the square
of its size. A state is now an array indexed by per-body ids of the locals,
holding sorted arrays of write ids and of (write, read) pairs; an operation
copies the array once, and a merge returns an input when that input already
holds the union. The lattice and its equality are unchanged, so the fixpoint
takes the same steps and reports the same diagnostics. The never-read
warnings of a local now come in source order.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T09:07:07.401575Z 1b30457 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Frotty
Frotty merged commit f020876 into master Oct 17, 2026
2 checks passed
@Frotty
Frotty deleted the dataflow-state-arrays branch November 25, 2026 08:54
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.

1 participant