Skip to content

slow type definition with repeated Unions #49731

Closed
@vtjnash

Description

@vtjnash

Reduced from RRTMGP.jl (except there, this has even more parameters and fields, and thus takes a few minutes longer)

julia> @time @eval struct S{FT<:AbstractFloat, A<:Union{Nothing, Val{FT}}, B<:Union{Nothing, Val{FT}}, C<:Union{Nothing, Val{FT}}, D<:Union{Nothing, Val{FT}}, E<:Union{Nothing, Val{FT}}, F<:Union{Nothing, Val{FT}}, G<:Union{Nothing, Val{FT}}}
    a::A; b::B; c::C; d::D; e::E; f::F; g::G;
end

  4.398847 seconds (5.38 M allocations: 2.002 GiB, 3.56% gc time)

Not certain there is anything we can do here, but opening this to record it, since it can be a bit of a surprising gotcha, although regardless of this, the runtime will still punish you pretty hard with bad performance everywhere because of those unions (e.g. #49725).

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