You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have difficulties in understanding what is compiled upon the first call of a callback function.
It seems that even if the callback function has been used before something is compiled upon the first notification.
MWE: with the definitions
using Observables
o =Observable("Hello")
functionf(s::String)
println(s)
end
After redefinition of f, I have the same scenario. Calling f directly doesn't need any extra compilation (f is probably compiled directly after definition). But calling f on the observable needs extra compilation.
julia> function f(s::String)
s = s * s
println(s, " world!")
end
f (generic function with 1 method)
julia> @time f("Hello")
HelloHello world!
0.000377 seconds (10 allocations: 224 bytes)
julia> @time notify(o);
HelloHello world!
0.003482 seconds (29 allocations: 1.312 KiB, 91.26% compilation time)
julia> @time notify(o);
HelloHello world!
0.000332 seconds (12 allocations: 576 bytes)
Where does this compilation come from and could it be avoided? (Obviously calling notify() would be one way of forcing precompilation.)
The text was updated successfully, but these errors were encountered:
I have difficulties in understanding what is compiled upon the first call of a callback function.
It seems that even if the callback function has been used before something is compiled upon the first notification.
MWE: with the definitions
I end up with the following timings
After redefinition of
f
, I have the same scenario. Callingf
directly doesn't need any extra compilation (f
is probably compiled directly after definition). But callingf
on the observable needs extra compilation.Where does this compilation come from and could it be avoided? (Obviously calling
notify()
would be one way of forcing precompilation.)The text was updated successfully, but these errors were encountered: