-
Notifications
You must be signed in to change notification settings - Fork 18k
Interface function invocation is horribly slow? #20116
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
Labels
Comments
This is due to inlining and escape analysis, not the call overhead itself. The compiler can prove to itself more about code with concrete types. Compare:
vs.
Closing as a dup of #19361 #18822 #19165 and other such bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I've had several types implementing the same interface. Invoking functions on the interface had horrible performance compared to running them on the concrete type:
These are the results I'm seeing:
Does it make any sense that using the concrete type is 45x faster? The only solution I could find is to use a type-switch everywhere I run this function.
When I remove the argument from the function definition (or replace it with an
int
), the runtime drops significantly. There's still a big difference but one that makes more sense to me. I suspect that it might be related to mem-copies?The text was updated successfully, but these errors were encountered: