-
-
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
Vararg vs "..." slurping has huge performance impacts which defy analysis #32761
Comments
Dup of #23749. Some other references, |
This is not a dup, as this issue is primarily about the resulting performance issue and how expressing the same method in two different ways causes wildly different performance. I don't care what the |
#28720 (comment) then? |
This is due to the |
Is this documented somewhere? Julia is always described as specializing on the runtime types of the arguments. I don't think many people know that type parameters change the specialization behaviour of otherwise identical methods. |
I thought this was documented but I might have mixed it up with variables captured in closures. I think adding something small about this is a good idea. It tends to happen for |
Count me as flabbergasted by this too. I would have expected both versions to be identical. Actually, I don't even understand the explanation about the specialization on |
The method generated will work for any |
Cool, I'll write up an addition to Performance Tips today and check to see if there are any good places to link to it from other places. |
I've come up with some good examples for Type and Vararg but I'm having trouble getting one for Function. Anyone have any suggestions? |
Sometimes |
Thanks! I had checked `"::F.*Function" but yours returns more useful results |
Interestingly, the two most prominent uses in Base specialize either way ( |
If I remember correctly, the |
@mbauman That seems to be the key observation, thank you! That also explains why I had to search a long time to find an example for Based on that (and checking specialization behaviour in the REPL), it seems like there are a number of functions in Base which could have their |
Here are two almost-identical functions:
And now a benchmark:
The code_lowered and code_typed are identical.
For a function containing a call to this function, the code_typed is different:
The reason for this difference in performance/compilation is not clear. The function signatures describe identical methods. If you define both as methods for the same function, there is still only one method in the function. I think this is a bug?
The text was updated successfully, but these errors were encountered: