Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid inferring when compilation signature differs from call site sig #46581

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Sep 1, 2022

Added in #43415, this was too aggressive for many cases. Unlike the
comment suggested, it is unneeded in many cases, so only do it when it
is expected to be maximally profitable.

Fixes #46492

julia> @time norm(C_212)
before 45.959497 seconds (81.85 M allocations: 6.976 GiB, 6.31% gc time, 100.00% compilation time)
after  15.781804 seconds (20.81 M allocations: 1.294 GiB, 6.32% gc time, 100.00% compilation time)

Added in #43415, this was too aggressive for many cases. Unlike the
comment suggested, it is unneeded in many cases, so only do it when it
is expected to be maximally profitable.

Fixes #46492

julia> @time norm(C_212)
before 45.959497 seconds (81.85 M allocations: 6.976 GiB, 6.31% gc time, 100.00% compilation time)
after  15.781804 seconds (20.81 M allocations: 1.294 GiB, 6.32% gc time, 100.00% compilation time)
base/compiler/abstractinterpretation.jl Show resolved Hide resolved
Comment on lines +216 to +223
if infer_compilation_signature(interp) && 1 == seen == napplicable && rettype !== Any && rettype !== Union{} && !is_removable_if_unused(all_effects)
match = applicable[1]::MethodMatch
method = match.method
sig = match.spec_types
mi = specialize_method(match; preexisting=true)
if mi !== nothing && !const_prop_methodinstance_heuristic(interp, match, mi::MethodInstance, arginfo, sv)
csig = get_compileable_sig(method, sig, match.sparams)
if csig !== nothing && csig !== sig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may want to pack these condition checks into a separate function, e.g.

    if infer_compilation_signature(interp)
        compilation_sig = maybe_compilation_signature(applicable, seen, rettype, all_effects, arginfo, sv)
        if compilation_sig !== nothing
            (; method, csig, sparams) = compilation_sig
            ...
        end
    end

But maybe_compilation_signature's argument list is so long depending on many local variables of abstract_call_gf_by_type, so I'm fine with the current code if you prefer it.

@vtjnash vtjnash merged commit f718238 into master Sep 2, 2022
@vtjnash vtjnash deleted the jn/46492 branch September 2, 2022 16:27
@ufechner7
Copy link

Can this be backported to 1.8 ?

@KristofferC KristofferC added the backport 1.8 Change should be backported to release-1.8 label Sep 8, 2022
@aviatesk aviatesk mentioned this pull request Sep 9, 2022
28 tasks
aviatesk pushed a commit that referenced this pull request Sep 9, 2022
…#46581)

Added in #43415, this was too aggressive for many cases. Unlike the
comment suggested, it is unneeded in many cases, so only do it when it
is expected to be maximally profitable.

Fixes #46492

```
julia> @time norm(C_212)
before 45.959497 seconds (81.85 M allocations: 6.976 GiB, 6.31% gc time, 100.00% compilation time)
after  15.781804 seconds (20.81 M allocations: 1.294 GiB, 6.32% gc time, 100.00% compilation time)
```
@aviatesk aviatesk removed the backport 1.8 Change should be backported to release-1.8 label Sep 9, 2022
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.

18x increase in compile time on v1.8
4 participants