-
-
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
Make f(args...)
as efficient as f(args)
#11248
Comments
Also, if |
jeff mentioned to me recently that it is now possible, following the recent tuple change, to enable this. the general tradeoff is that you don't want to make a new optimized function for every possible argument list that you encounter, since the codegen time would end up dominating the runtime of that function. but there is probably a happy medium where |
@vtjnash I agree there's probably a tradeoff between efficiency of generated code and how much to generate. As mentioned above, the point of this issue though, is that the methods are already specialized. If you call IMHO, what needs to be changed is probably the convention for calling vararg functions that can be specialized. |
And also I'm not talking about making |
ah, good call: julia> @code_typed f1(1, 2, 3)
1-element Array{Any,1}:
:($(Expr(:lambda, Any[:(args::Any...)], Any[Any[],Any[Any[:args,Tuple{Int64,Int64,Int64},0]],Any[],Any[]], :(begin
$(Expr(:meta, :noinline)) # none, line 1:
return args::Tuple{Int64,Int64,Int64}
end::Tuple{Int64,Int64,Int64})))) if you want to take a shot at this, take a look at |
@vtjnash Thanks for the pointer. Probably not now but I'll keep it on my list and will probably try it sometime unless someone else implement it (or sth better) before I get to it (e.g. after a thesis defence). |
This would certainly be a big deal. Currently a good number of |
@timholy Didn't know about that. Do you have an example of it? Not that I think it should be the long term solution but I'm interested to see what's the current work around (and that I have thought about using |
#10337 has extensive discussion. See also julia/base/multidimensional.jl Lines 283 to 292 in 08f4aa0
|
dup of #5402 |
Close as dup of #5402. |
It seems that for both
f(args...)
andf(args)
(called with a tuple), the function is specialized to take a tuple as argument. However, in the first case, the argument is always boxed into ajl_value_t*
before passing in while for the second case (at least after) the tuple type change, no boxing/gc frame is necessary.From the output from the example code below, it seems that the function is already specialized on the types of the arguments although they are somehow still using the generic
jl_value_t*
type as the type for both input and output.Example code
Output
(Related to #11244)
The text was updated successfully, but these errors were encountered: