-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Description
I have a function with thousands of keyword arguments of which a few hundred are used at any given call site. Inference really doesn't like this and takes several minutes to infer the call. Cursory debugging shows most of the time being spent in haskey(::NamedTuple{<lots of fields here>})
. Here is a very minimal reduced example that already shows several second compile times while being trivial (my actual code has non-trivial defaults, etc, which I think makes up the difference):
julia> params = [Expr(:kw, Symbol("k$i"), i) for i = 1:3000]
julia> params2 = reverse([Expr(:kw, Symbol("k$i"), i) for i = 1:600])
julia> @eval function f($(Expr(:parameters, params...)))
nothing
end
f (generic function with 1 method)
julia> @eval g() = f($(params2...))
g (generic function with 1 method)
julia> @time @code_typed g()
7.163038 seconds (7.44 M allocations: 1.996 GiB, 14.41% gc time, 100.00% compilation time)
CodeInfo(
1 ─ return nothing
) => Nothing
NHDaly
Metadata
Metadata
Assignees
Labels
No labels