Skip to content

Compile-time natives: no per-call strings or keys, field writes by field, object files serialised once - #1449

Merged
Frotty merged 1 commit into
masterfrom
claude/native-call-overhead
Oct 13, 2026
Merged

Frotty merged 1 commit into
masterfrom
claude/native-call-overhead

Conversation

@Frotty

@Frotty Frotty commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Costs of the object editing natives and the object writeback, found profiling a large map with thousands of compile-time functions:

  • ReflectionNativeProvider.invoke turned every argument of every native call into a string ("" + args[i]) for an error message it builds only on failure; for an interpreter string that decodes its bytes. It also copied the method's parameter types (getParameterTypes clones) each call. NativeJassFunction keeps the types and the name offset; the message uses the argument when it fails.
  • ReflectionBasedNativeProvider, which serves the object editing natives, allocated and hashed a Pair(name, arity) per call. It looks the method up by name, then by arity.
  • CompiletimeNatives.modifyObject went through every mod of the object to find the old values of the field (8 % of the compile-time samples); an ability with many levels has thousands. wc3libs' Obj keeps its mods by field (getModsOfField, kept in step by addMod, remove and the object file reader), so only the field's are looked at. Same mods removed, same order.
  • ProgramStateIO.writeBack serialised each object file to hash it and again to write it, and MD5-hashed the copy in the map to compare. It serialises once, hashes once for the manifest, and compares the map's copy with Arrays.equals.

The same map, on top of #1448 (measured together, alternating against #1448 alone): compile-time functions execute about 2.4 to 2.0 s (median of 3; noisy). 02_compiled.j.txt identical apart from the version line, exported object data (WurstExportedObjects_*.wurst.txt) identical.

Behaviour is unchanged, so no new test; CompiletimeNativesTest (field replacement across levels and data pointers, mods read from the map file, writeback across runs), ExportToWurstTest, ObjectExportServiceTest, CompiletimeTests, CompiletimeHashtableTests, InterpreterTests, StdLibStringTests and NewFeatureTests pass.

…eld, object files serialised once

- ReflectionNativeProvider turned every argument of every native call into a
  string for an error message it builds only on failure, decoding each
  interpreter string, and copied the method's parameter types each time.
  NativeJassFunction keeps them.
- ReflectionBasedNativeProvider, which serves the object editing natives,
  allocated and hashed a (name, arity) pair per call. It looks the method up
  by name and then by arity.
- A field write went through every mod of the object to find the old values
  of the field; an ability with many levels has thousands. The object keeps
  its mods by field, so only those of the field are looked at.
- The writeback serialised each object file to hash it and again to write
  it, and hashed the copy in the map to compare. It serialises once, hashes
  once for the manifest and compares the map's copy byte by byte.

SurvivalChaosReborn, with #1448: compile-time functions execute about 2.4 to
2.0 s (median of 3). Output and exported object data identical.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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-13T07:24:08.523379Z 071ea15 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 921e52d into master Oct 13, 2026
2 checks passed
@Frotty
Frotty deleted the claude/native-call-overhead branch November 25, 2026 08:53
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