Skip to content

Dispatch performance regression #55807

@charleskawczynski

Description

@charleskawczynski

I think I found a regression with compiling methods with increasing type information (cc @gbaraldi). Here is a reproducer:

Base.@kwdef struct Nested{A,B}
    num::Int = 1
end
nest_val(na, nb, ::Val{1}) = Nested{na, nb}()
nest_val(na, nb, ::Val{n}) where {n} = nest_val(Nested{na, nb}, Nested{na, nb}, Val(n-1))
nest_val(na, nb, n::Int) = nest_val(na, nb, Val(n))
nest_val(n) = nest_val(1, 1, n)
foo(t::Nested) = 1
for i in 1:4:25
    let i=i
        NV = nest_val(i)
        @time begin
            foo(NV)
        end
    end
end
Julia 1.8 🚀
  0.000002 seconds
  0.000057 seconds (355 allocations: 24.688 KiB, 76.66% compilation time)
  0.000055 seconds (355 allocations: 24.688 KiB, 77.15% compilation time)
  0.000060 seconds (355 allocations: 24.688 KiB, 76.81% compilation time)
  0.000061 seconds (355 allocations: 24.688 KiB, 76.18% compilation time)
  0.000121 seconds (355 allocations: 24.688 KiB, 86.99% compilation time)
  0.000063 seconds (355 allocations: 24.688 KiB, 74.36% compilation time)
Julia 1.9 🐢
  0.000002 seconds
  0.000087 seconds (323 allocations: 23.266 KiB, 86.27% compilation time)
  0.000102 seconds (323 allocations: 23.266 KiB, 83.09% compilation time)
  0.000180 seconds (323 allocations: 23.266 KiB, 41.63% compilation time)
  0.001830 seconds (323 allocations: 23.266 KiB, 10.49% compilation time)
  0.024255 seconds (323 allocations: 23.266 KiB, 0.37% compilation time)
  0.391652 seconds (323 allocations: 23.266 KiB, 0.02% compilation time)
Julia 1.10 🐢
  0.000002 seconds
  0.000106 seconds (312 allocations: 23.031 KiB, 71.90% compilation time)
  0.000112 seconds (312 allocations: 23.031 KiB, 80.39% compilation time)
  0.000233 seconds (312 allocations: 23.031 KiB, 57.58% compilation time)
  0.001319 seconds (312 allocations: 23.031 KiB, 4.36% compilation time)
  0.019645 seconds (313 allocations: 23.125 KiB, 0.24% compilation time)
  0.318507 seconds (312 allocations: 23.031 KiB, 0.03% compilation time)
Julia 1.11.0-rc3 🐢
  0.000004 seconds
  0.000043 seconds (105 allocations: 4.828 KiB, 56.51% compilation time)
  0.000043 seconds (105 allocations: 4.828 KiB, 50.47% compilation time)
  0.000125 seconds (105 allocations: 4.828 KiB, 18.22% compilation time)
  0.001327 seconds (105 allocations: 4.828 KiB, 1.66% compilation time)
  0.022224 seconds (106 allocations: 4.922 KiB, 0.12% compilation time)
  0.343260 seconds (105 allocations: 4.828 KiB, 0.01% compilation time)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions