Skip to content

Check a Lua build's native calls on one scan of its script - #1480

Merged
Frotty merged 2 commits into
masterfrom
lua-native-call-check-one-scan
Oct 17, 2026
Merged

Frotty merged 2 commits into
masterfrom
lua-native-call-check-one-scan

Conversation

@Frotty

@Frotty Frotty commented Oct 17, 2026

Copy link
Copy Markdown
Member

Every Lua build checks its finished script for leaked hashtable natives and for __wurst_GetHandleId calls without a helper definition. It did so with two assertions, each of which lexed the whole text twice: once for the called names and once for the defined ones, the second testing for the function keyword at every character. In a profile of an unoptimised build of a large map these scans were 4.7% of the compiler thread's samples.

LuaAssertions.collectFunctionNames now collects both name sets in one pass, and the build calls LuaAssertions.assertNoLeakedNativeCalls, which runs both checks on it. The two single checks keep their signatures and messages.

Measured

On that map's 9.4 MB script, in one JVM, alternating:

cold warm
before: the two checks ~600 ms ~145 ms
after: the combined check 150 to 250 ms ~45 ms

The emitted Lua of the map is byte-identical.

Verified

  • LuaTranslationTests.combinedNativeCallCheckRejectsWhatEitherCheckRejects: on ten scripts (calls, declarations, comments, strings, defined and undefined helpers, both failures at once) the combined check rejects exactly what the two checks reject, with the same message.
  • LuaTranslationTests and LuaHashtableTests pass locally (Windows). The change is in-memory text scanning, with no file or process handling.

BACKLOG

A second commit records two measurements so they are not repeated:

  • Exact-receiver devirtualisation: on the optimised Lua of two large maps, most fresh-receiver dispatch sites are either one-shot code or inside forEach loops, which need a whole-program destruction proof; the straight-line version alone is not worth an analysis.
  • SLL-clean grammars: the LL fallback was 2 of 417 parse-thread samples in a build, so the entry moves to Notes as not worth doing.

Every Lua build checked its finished script for leaked hashtable natives and
for __wurst_GetHandleId calls without a helper with two assertions, each of
which lexed the whole text twice: once for the called names and once for
the defined ones, the second testing for the function keyword at every
character. One pass now collects both sets, and the build runs both checks
on it. On a 9.4 MB script that is 150 to 250 ms cold instead of 600 ms
(45 ms warm instead of 145 ms). The checks and their messages are unchanged.
@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-17T12:25:21.970525Z 072c6cf 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 ac4bcf5 into master Oct 17, 2026
2 checks passed
@Frotty
Frotty deleted the lua-native-call-check-one-scan branch October 17, 2026 12:32
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