I noticed when trying to build a large Parametron model that I was spending an unreasonable amount of time just constructing the initial model. From profiling, it looks like almost all of the time is spent inside the FunctionWrappersQuickFix.FunctionWrapper constructor.
I was curious to see if the quick fix might be slowing things down, and it does appear that what we're doing is dramatically slower than the normal FunctionWrapper. For example:
julia> using FunctionWrappers, Parametron, BenchmarkTools
julia> function f1(x)
Parametron.FunctionWrappersQuickFix.FunctionWrapper{Int, Tuple{Int}}(y -> y + x)
end
f1 (generic function with 1 method)
julia> function f2(x)
FunctionWrappers.FunctionWrapper{Int, Tuple{Int}}(y -> y + x)
end
f2 (generic function with 1 method)
julia> @btime f1($1)
188.514 ns (2 allocations: 64 bytes)
Parametron.FunctionWrappersQuickFix.FunctionWrapper{Int64,Tuple{Int64}}(Ptr{Nothing} @0x00007f9498be3570, Ptr{Nothing} @0x00007f9493ed8010, Base.RefValue{getfield(Main, Symbol("##7#8")){Int64}}(getfield(Main, Symbol("##7#8")){Int64}(1)), getfield(Main, Symbol("##7#8")){Int64})
julia> @btime f2($1)
9.602 ns (2 allocations: 64 bytes)
FunctionWrappers.FunctionWrapper{Int64,Tuple{Int64}}(Ptr{Nothing} @0x00007f9498beada0, Ptr{Nothing} @0x00007f9493ed8020, Base.RefValue{getfield(Main, Symbol("##9#10")){Int64}}(getfield(Main, Symbol("##9#10")){Int64}(1)), getfield(Main, Symbol("##9#10")){Int64})
julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E3-1535M v6 @ 3.10GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
so FunctionWrappers.FunctionWrapper is about 20x faster to construct for this example.
I'm not sure what exactly we can do about it, other than to keep making noise over at JuliaLang/julia#28669
I noticed when trying to build a large Parametron model that I was spending an unreasonable amount of time just constructing the initial model. From profiling, it looks like almost all of the time is spent inside the
FunctionWrappersQuickFix.FunctionWrapperconstructor.I was curious to see if the quick fix might be slowing things down, and it does appear that what we're doing is dramatically slower than the normal FunctionWrapper. For example:
so
FunctionWrappers.FunctionWrapperis about 20x faster to construct for this example.I'm not sure what exactly we can do about it, other than to keep making noise over at JuliaLang/julia#28669