Skip to content

Interpreter: less work per call - #1442

Merged
Frotty merged 6 commits into
masterfrom
claude/interpreter-call-overhead
Oct 13, 2026
Merged

Frotty merged 6 commits into
masterfrom
claude/interpreter-call-overhead

Conversation

@Frotty

@Frotty Frotty commented Oct 12, 2026

Copy link
Copy Markdown
Member

Builds on #1441 (its commit is included here; merge that one first).

What each interpreted call did whether it needed it or not:

  • A method call went through every override of the method and walked the superclasses twice for each (isSubclassOf was 14 % of the compile-time samples on gods-arena). The implementation is kept per method and receiver class now (ProgramState.dispatch).
  • The error position of each frame was computed when the frame was pushed. It is computed when a message needs it.
  • Every call allocated maps for type substitutions and type arguments, and every local state a map of modified array indexes. They are allocated when there is something to put in them; type arguments are bound only for receivers whose class hierarchy has type variables or arguments.
  • Whether a function is a compile-time native was read from its annotations on every call. The translator flags it, now also for extension functions, which the object editing natives are, and the interpreter reads the flag.
  • A return formatted a trace message, and resolving a type allocated a matcher also for types without type variables.

The method call also built a map of type substitutions it never used; it is gone.

Compile-time functions of gods-arena (Jass, execute phase), against #1441: 1593 to 1475 ms cold (median of 3), about 840 to 595 ms warm (builds 2 to 6 in one JVM, two JVMs each). The Jass output is identical.

InterpreterTests.methodDispatchPerReceiverClassAtOneCallSite dispatches one call site over receivers of five classes in turn; it fails when the cache ignores the receiver class. Run locally: InterpreterTests, CompiletimeTests, CompiletimeNativesTest, CompiletimeHashtableTests, ClassesTests, ClassesExtTests, InterfaceTests, InterfaceExtendedTests, GenericsTests, GenericsModuleTests, GenericsWithTypeclassesTests, TypeClassTests, ClosureTests, FieldIterationTests, ModuleTests, NewFeatureTests, BugTests, ObjectExportServiceTest, ModelManagerTests.

…ocation

ProgramState.allocate built its trace message on every allocation, which
prints the allocating constructor or closure, although trace logging is
off. It is built only when tracing is on now.

The interpreter memoised the results of natives it considers pure. The
natives are cheaper than hashing and comparing their arguments, and the
eviction removed one entry per call once a native had 2048 results. The
natives whose handle identity matters keep their own handles (the
conversions, Player), so the cache is removed.

On gods-arena the compile-time functions ran in 2103 ms before, 1791 ms
with the first change and 1546 ms with both (median of 3 cold builds);
on a warm JVM the cache made no gain either. Output identical.
What each interpreted call did whether it needed it or not:

- A method call went through every override of the method and walked the
  superclasses twice for each. The implementation is kept per method and
  receiver class now.
- The error position of each frame was computed when the frame was
  pushed. It is computed when a message needs it.
- Every call allocated maps for type substitutions and type arguments, and
  every local state a map of modified array indexes. They are allocated when
  there is something to put in them; type arguments are bound only for
  receivers whose class hierarchy has type variables or arguments.
- Whether a function is a compile-time native was read from its
  annotations on every call. The translator flags it, now for extension
  functions too, which the object editing natives are, and the interpreter
  reads the flag.
- The return of a function formatted a trace message, and resolving a type
  allocated a matcher also for types without type variables.

The method call ignored a map of type substitutions which it built on every
call; it is gone.

Compile-time functions of gods-arena: 1593 to 1475 ms cold, about 840 to
595 ms warm (builds 2 to 6 in one JVM). Output identical.
@chatgpt-codex-connector

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-12T15:44:33.297401Z bc9a90e 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 1310878 into master Oct 13, 2026
3 checks passed
@Frotty
Frotty deleted the claude/interpreter-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