-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
codegen of cfunction #35252
Comments
Boiling down MWE even further i reached an even minimal'er example; g(f) = Nothing
cfun = @cfunction(g, Type{Nothing}, (Ref{typeof(g)},))
function m()
for i in 1:10000000
ccall(cfun, Type{Nothing}, (Ref{typeof(g)},), g)
end
end
@time m() # slow
@time m() # still slow
cfun = @cfunction(g, Type{Nothing}, (Ref{typeof(g)},)) # redefining after use and it becomes fast.
@time m() # fast!
@time m() # still fast!
g(f) = Nothing
cfun = @cfunction(g, Type{Nothing}, (Ref{typeof(g)},)) # redefining both g and cfun it's slow again
@time m() # slow again
cfun = @cfunction(g, Type{Nothing}, (Ref{typeof(g)},)) # redeining after use and it becomes fast (again)
@time m() # fast again!
|
Looks superficially like garbage collection might make the difference. |
I'm unable to reproduce this in latest git version. I tried to bisect to find out what fixed it, but, it took so long and was such a hassle with branches and dependency chances I gave up. |
duplicate of #36977 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Originally seen when using FunctionWrappers. @yuyichao was nice enough to provide a MWE, that shows non-repeatably inefficient code. I am out of my depth here for such julia internals, just relaying the message :)
Cheers!
The text was updated successfully, but these errors were encountered: