Skip to content

Interpreter: dispatch looks only at the overrides in the receiver's classes - #1448

Merged
Frotty merged 1 commit into
masterfrom
claude/dispatch-ancestor-sets
Oct 13, 2026
Merged

Frotty merged 1 commit into
masterfrom
claude/dispatch-ancestor-sets

Conversation

@Frotty

@Frotty Frotty commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

The dispatch cache from #1442 still did the expensive part on each miss: for a method and receiver class it had not seen, it went through every override of the method and asked isSubclassOf twice for each, which walks the supertypes again every time. On a large map a method has thousands of overrides and there are thousands of such method and class pairs: tens of millions of checks, about 2.9 s of its compile-time functions (TypeId.isSubclass was 76 % of the execute samples).

  • The overrides of a method are indexed by the class they belong to, once per method.
  • The ancestors of a class (itself included, as isSubclassOf answers) are worked out once per class.
  • A miss collects only the overrides in the receiver's ancestors and applies the same rule to them in the same order as before, so the result does not change. The ancestor sets are only used for membership; the collected positions are sorted.
  • ProgramState.isInstanceOf uses the ancestor sets too.

A large map (Jass): compile-time functions 4.2 to 2.6 s, execute 3811 to 2257 ms (median of 3 alternating builds against master). 02_compiled.j.txt byte-identical.

The old loop ran next to the new one as an oracle on every miss of a large map's build and of InterpreterTests, ClassesTests, ClassesExtTests, InterfaceTests, InterfaceExtendedTests, GenericsTests, GenericsWithTypeclassesTests, TypeClassTests, ModuleTests, NewFeatureTests, BugTests, CompiletimeTests and ClosureTests: no difference, and those classes pass. InterpreterTests.methodDispatchPerReceiverClassAtOneCallSite (from #1442) covers dispatch per receiver class.

…lasses

A method call the interpreter had not seen for a receiver class went through
every override of the method, and asked isSubclassOf twice for each, which
walks the supertypes again every time. SurvivalChaosReborn has a method with
5261 overrides and 15669 such method and class pairs: 45 million checks, about
2.9 s of the compile-time functions.

The overrides of a method are indexed by their class once, and the ancestors
of a class are worked out once, so a miss looks only at the overrides in the
receiver's classes. They are taken in the same order and by the same rule.
instanceof uses the ancestors too.

SurvivalChaosReborn: compile-time functions 4.2 to 2.6 s (execute 3811 to
2257 ms, median of 3 alternating). Output identical; the old and new answer
were compared on every miss of that build and of the dispatch test classes.
@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:01:26.616870Z 691ee1f 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 42165fe into master Oct 13, 2026
2 checks passed
@Frotty
Frotty deleted the claude/dispatch-ancestor-sets 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