avoid method proliferation for Tuple
functions
#59421
Open
+102
−59
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.
Motivation:
Introducing new types and methods for a callable can invalidate already compiled method instances of a function for which world-splitting is enabled (
max_methods
).Invalidation of sysimage or package precompiled code worsens latency due to requiring recompilation.
Lowering the
max_methods
setting for a function often causes inference issues for existing code that is not completely type-stable (which is a lot of code). In many cases this is easy to fix by avoiding method proliferation, such as by merging some methods and introducing branching into the merged method.This PR aims to fix the latter issue for some
Tuple
-related methods of some functions where decreasingmax_methods
might be interesting.Seeing as branching was deliberately avoided in the bodies of many of these methods, I opted for the approach of introducing local functions which preserve the dispatch logic as before, without branching. Thus there should be no regressions, except perhaps because of changed inlining costs.
This PR is a prerequisite for PRs which try to decrease
max_methods
for select functions, such as PR:max_methods
world-splitting setting for some functions #59377