avoid method proliferation for Tuple functions#59421
Open
nsajko wants to merge 14 commits intoJuliaLang:masterfrom
Open
avoid method proliferation for Tuple functions#59421nsajko wants to merge 14 commits intoJuliaLang:masterfrom
Tuple functions#59421nsajko wants to merge 14 commits intoJuliaLang:masterfrom
Conversation
89ebaa7 to
32f6824
Compare
* 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 decreasing `max_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: * JuliaLang#59377
56b2887 to
0b1bc8d
Compare
nsajko
commented
Jan 25, 2026
Member
Author
|
Changed the PR to rely on branching more, as suggested. |
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 29, 2026
nsajko
added a commit
to nsajko/julia
that referenced
this pull request
Jan 30, 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.
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_methodssetting 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_methodsmight be interesting.This PR is a prerequisite for PRs which try to decrease
max_methodsfor select functions, such as PR:max_methodsworld-splitting setting for some functions #59377