-
Notifications
You must be signed in to change notification settings - Fork 1.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
[vm/ffi] Optimize ffi calls with multiple Dart_Handle arguments #42341
Comments
On x64 desktop in JIT the trampolines with Handles are a bit slower than trampolines passing integers or Pointers. FfiCall.Uint64x01(RunTime): 200.8482627033541 us. FfiCall.PointerUint8x01(RunTime): 261.3910088865656 us. FfiCall.Handlex01(RunTime): 355.4978670458585 us. FfiCall.Handlex02(RunTime): 384.86376755820663 us. FfiCall.Handlex04(RunTime): 492.896007885658 us. FfiCall.Handlex10(RunTime): 846.1214043993232 us. FfiCall.Handlex20(RunTime): 1193.412291169451 us. Issue: #36858 Issue: #41319 New issue for optimizing multiple handles: #42341 Also cleans up dart2/native which was erroneously left over from the benchmark duplication for NNBD. Change-Id: I81223fefc47129d00984492efb9502d5449f0d4a Cq-Include-Trybots: luci.dart.try:benchmark-linux-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145593 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Jonas Termansen <sortie@google.com>
When using a lot of handles, the old
source: https://dart-review.googlesource.com/c/sdk/+/218920 @cskau-g What is the distribution of the number of handle arguments in the If we have a lot of calls with many handles, we should address this issue. Related PR (pre-work for |
Quickly ran the numbers for the 169 APIs I've had a look at and see:
So I imagine optimising for lots of handles won't have a measurable impact on |
FfiCall.Handlex01(RunTime): 347.8671304347826 us.
FfiCall.Handlex02(RunTime): 384.86376755820663 us.
FfiCall.Handlex04(RunTime): 492.896007885658 us.
FfiCall.Handlex10(RunTime): 846.1214043993232 us.
FfiCall.Handlex20(RunTime): 1193.412291169451 us.
We currently call into C for every handle with
sdk/runtime/vm/compiler/frontend/kernel_to_il.cc
Lines 2750 to 2764 in 755686e
sdk/runtime/vm/runtime_entry.cc
Lines 3559 to 3570 in 755686e
Instead, we can extend the EnterHandleScope with an int how many handles we want, and do some integer arithmetic in IL to compute the addresses of those handles. (Up to the number of handles that fit into one single block.)
sdk/runtime/vm/compiler/frontend/kernel_to_il.cc
Lines 2731 to 2736 in 755686e
The text was updated successfully, but these errors were encountered: