-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Speculative inlining/devirtualization #10805
Comments
@vtjnash correct me if I'm wrong but this handle the case What I'm proposing at https://github.com/JuliaLang/julialang.github.com/blob/master/gsoc/2015/index.md#project-specialized-call-site-method-caching is easier since there is an addtional layer of indirection so we can update those small caches when method def are added. It should take care of the biggest chunk of the overhead which is dynamic dispatch and not the actual function call. |
(yeah wifi is flaky here) We can solve it whenever someone does it :). The problem is that while the implementation itself is conceptually not hard (record every callsite "assumptions" made by inference and whether it was inlined or not, invert the graph, invalidate code transitively on method def and stop when the assumptions are not violated & method was not inlined), the two big problems I see are :
|
We basically do this now. |
AFAIK, julia only optimize/inline functions when the type inference can narrow down the arguments to a single type. However, in some cases this is effectively throughing away the hard work of the type inference if it had narrow down the types to a few (>1). In the following example, manually doing type assertion leading to much better code generated.
(It is when I was exploring this possibility that I discovered bug #9765)
I thought this might not be too important since (at least for numerical calculation) people that care about performance should probably ensure type stability in julia. However, I came across this blog post series and changed my mind. It seems that this is a technique used in mordern compilers and can have a non-negligible effect even for not so dumb code.
I thought it shouldn't be hard to implement this and was going to code sth up a few month ago. However, I also have another generic question about implementing sth like this (also what I was trying to do in #9642) in julia. It seems that for a non-inlined function call, function lookup is done at least three times, typeinf, codegen and in
jl_apply_generic
. Is there any method/plan to keep this info and not do repeating work?The text was updated successfully, but these errors were encountered: