Repository navigation
Interpreter: less work per call - #1442
Merged
Merged
Conversation
…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.
…function-perf-283503
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.
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. |
…-283503' into claude/interpreter-call-overhead
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #1441 (its commit is included here; merge that one first).
What each interpreted call did whether it needed it or not:
isSubclassOfwas 14 % of the compile-time samples on gods-arena). The implementation is kept per method and receiver class now (ProgramState.dispatch).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.methodDispatchPerReceiverClassAtOneCallSitedispatches 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.