-
-
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
Specialization on unused arguments #23753
Comments
One issue is that the caller doesn't know that the function doesn't use its argument, so generating a specialized entry point can still be worthwhile for more efficient caller code. That could also be handled with a different calling convention for such a function, but that carries significant complexity. In general, functions tend to use their arguments, so spending complexity on unused arguments is probably not worthwhile. |
If the function is as simple as this example, won't it tend to be inlined and therefore the issue is moot anyway? It seems like it would only have any effect in cases where the function is fairly beefy. So it seems like the concern here is not performance but avoiding generating the same code multiple times – i.e. don't change calling convention (pass the second argument), but automatically infer that it should be |
The bottom line is that unused arguments are rare enough in practice that this probably has minimal impact. I might have done some experiments on this in the past but I'm not sure. Without a more realistic example, it's hard to tell whether the issue is code size or performance. If the function is just over the inlining threshold, generating two copies of it could certainly be worthwhile to avoid boxing an argument on every call. |
Yeah, at the end of the day, I think we'd rather focus effort on #11339, i.e. being able to mark certain parameters to not specialize on, which is in a similar vein to the ask here. |
Fair enough. Julia was generating thousands of specializations of a certain function in my code, which caused very long compilation time. I couldn't avoid it through |
This would have no effect. For abstract types, this will also require boxing of the argument as Jeff mentioned. |
My issue was with compilation time getting out of hands. Wouldn't |
Well, |
🤦♂️ of course. I mistyped my example. I meant |
Julia 0.6 specializes on unused arguments:
There might be a very good reason for this, but I couldn't find any relevant issue. Wouldn't it be more memory/time efficient to share?
The text was updated successfully, but these errors were encountered: