-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
This may just be naiveté on my part with regards to writing Julia functions, but I'm seeing a performance hit when adding keyword arguments to function calls.
Basically, I was looking at the implementation of QuickSort and wanted to see if by adding a user-defined cutoff for insertion sort (rather than the built-in constant of 20) I could improve performance. What I found was that simply adding the keyword arguments to function definitions reduced performance substantially (even when the keywords aren't used in the calls). I ran the following both times (results further down):
v = rand(1_000_000)
@time sort(v)
@time sort(v)
I'm calling sort()
twice because the second time is always faster (presumably because of the VM generating code the first time around?) Before my change the first call took about 0.23 seconds and the second around 0.10. After the change the first call took about 0.30 seconds and the second 0.16.
Any ideas what is causing this to happen? I think if I reference this issue in a commit you'll be able to see my code. Otherwise, I'll just copy-and-paste the diff.