Repository navigation
Interpreter: dispatch looks only at the overrides in the receiver's classes - #1448
Merged
Merged
Conversation
…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.
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. |
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.
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
isSubclassOftwice 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.isSubclasswas 76 % of the execute samples).isSubclassOfanswers) are worked out once per class.ProgramState.isInstanceOfuses 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.txtbyte-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.