-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[ffi] function call overhead? #52692
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
Comments
cc @dcharkes |
What Dart execution mode are you running the measurements on? JIT ( |
My measurements were taken on JIT ( |
Here are the results for AOT:
Pure function calls have improved significantly, "assembly" has improved only slightly in a way that does not affect my conclusion. |
Using the
Background info:
The remaining questions:
I have done some exploration #49418 https://dart-review.googlesource.com/c/sdk/+/251263. I have not done any performance measurements on the exploration. I expect it to be maybe slightly faster but not a whole lot than Yes, I'd like to land that work =)
@mraleph mentioned that LTO doesn't work unfortunately: #49418 (comment) |
I wanted to see if it would be possible to implement the features proposed in #52673 via FFI.
I've created a demo for compiling pure assembly to a dylib. (The demo can be found here. That file in that repo should be able to run on any arm/macos machine and reproduce my observations.)
I was able to make the following measurements on my arm macbook:
My conclusion is that the overhead of calling some assembly via a dynamically linked library takes ~2x the time it would take to invoke a closure and ~3x the time it would take to invoke a function. Furthermore, it seems like it wouldn't make sense to use this approach for exposing ARM instructions to Dart, as the overhead of calling them is too big.
I did expect the dylib calls to have some overhead, but I don't know how much overhead to expect.
I wanted to ask the following:
All in all, I'd like to be able to ship custom assembly with Dart, and the above questions are meant to find out if that could become practical (in a way that does not incur any performance penalties) in some form in the near future.
The text was updated successfully, but these errors were encountered: