Commit graph

17 commits

Author SHA1 Message Date
Clement Skau 4d5055805f [VM/FFI] Adds FFI leaf calls.
This CL adds FFI leaf calls by adding `lookupFunction(.., isLeaf)`
and `_asFunctionInternal(.., isLeaf)`, which generate FFI leaf calls.
These calls skip a lot of the usual frame building and generated <->
native transition overhead.

`benchmark/FfiCall/` shows a 1.1x - 4.3x speed-up between the regular
FFI calls and their leaf call counterparts (JIT, x64, release).

TEST=Adds `tests/ffi{,_2}/vmspecific_leaf_call_test.dart`. Tested FFI tests.

Closes: https://github.com/dart-lang/sdk/issues/36707
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-release-arm64-try,vm-ffi-android-release-arm-try,vm-ffi-android-product-arm64-try,vm-ffi-android-product-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-precomp-nnbd-mac-release-simarm64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Bug: https://github.com/dart-lang/sdk/issues/36707
Change-Id: Id8824f36b0006bf09951207bd004356fe6e9f46e
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179768
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-21 11:12:02 +00:00
Clement Skau 4235154e3d [ffi/benchmark] Refactor FfiCall benchmarks.
Inlines in the test classes:
- Native function lookup.
- The main benchmark loop.

This CL contains the refactoring necessary to update the
benchmarks to include leaf calls, as seen in:
https://dart-review.googlesource.com/c/sdk/+/179768

TEST=tools/build.py -m release dart && out/ReleaseX64/dart benchmarks/FfiCall/dart{,2}/FfiCall.dart

Change-Id: I1e85f991d895862c27ae99a71f5d4785ccdf5676
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188465
Commit-Queue: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-03-02 16:06:22 +00:00
Clement Skau 3e7d590a30 [ffi/benchmark] Dedup. test code in FfiCall.
This also serves as a step in the refactoring needed for
the FFI leaf call benchmark changes in:
https://dart-review.googlesource.com/c/sdk/+/179768

Change-Id: I0876d610b1d79b05c4bcd7e3cd9ef48d1beff432
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186294
Auto-Submit: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-02-23 14:45:59 +00:00
Clement Skau 9d03dd9378 [ffi/benchmark] Fix FfiCall branchmarks.
- Fixes expect logic in Float.. and Double.. benchmarks.
- Fixes expected values in the same benchmarks.
- Fixes typos in a few FFI function lookups.
- Adds expected value to 'Unexpected result' message.

Change-Id: I16eff1cac451412b376f56c070c5b8127ff744e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186284
Auto-Submit: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-02-23 08:41:39 +00:00
Daco Harkes a45276ab91 Reland "[vm/ffi] Roll package:ffi to Allocator and Opaque"
This can only be landed when `Allocator`, `Opaque`, and `AllocatorAlloc`
have rolled into Flutter/engine, that into Flutter/flutter, and into g3.

Deletes all the copies of `_CallocAllocator` and uses the one from
`package:ffi` instead.

Bug: https://github.com/dart-lang/sdk/issues/44622
Bug: https://github.com/dart-lang/sdk/issues/43974
Bug: https://github.com/dart-lang/sdk/issues/44621
Bug: https://github.com/dart-lang/sdk/issues/38721

Change-Id: I486034b379b5a63cad4aefd503ccd0f2ce5dd45e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180188
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-02-10 10:19:28 +00:00
Daco Harkes 3cfcc5a8e5 Revert "[vm/ffi] Roll package:ffi to Allocator and Opaque"
Revert submission 177862

Reason for revert: breaks g3 without https://github.com/flutter/engine/pull/23808
Reverted Changes:
I50b3b4c31:[vm/ffi] Roll `package:ffi` to `Allocator` and `Op...
I3f5b08c08:[vm/ffi] Change `Pointer<T extends Struct>.ref` to...
I6141c193b:[vm/ffi] Disallow empty structs

Change-Id: I128e7b096faea650e0ba0850a411eed3e97c00e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180185
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-01-20 21:37:11 +00:00
Daco Harkes 7d648e3ae7 [vm/ffi] Roll package:ffi to Allocator and Opaque
This can only be landed when `Allocator` and `Opaque` have rolled into
Flutter/engine, that into Flutter/flutter, and that into g3.
flutter/flutter/commit/a706cd211240f27be3b61f06d70f958c7a4156fe

Deletes all the copies of `_CallocAllocator` and uses the one from
`package:ffi` instead.

Issue: https://github.com/dart-lang/sdk/issues/44622
Issue: https://github.com/dart-lang/sdk/issues/43974
Issue: https://github.com/dart-lang/sdk/issues/44621
Issue: https://github.com/dart-lang/sdk/issues/38721

Change-Id: I50b3b4c31a2b839b35e3e057bd54f463b90bc55e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179540
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-01-20 18:08:25 +00:00
Daco Harkes c36028b002 [vm/ffi] Migrate benchmarks/Ffi* to CallocAllocator
This CL does not yet roll `package:ffi` to use `Allocator`, because that
breaks the checked in Dart in Flutter in g3. Instead, this copies
`_CallocAllocator` from `package:ffi` into the benchmarks. (We need a
copy per benchmark such that file-copying before running benchmarks
works properly.) The copies can be deleted when we can update
`package:ffi` in the DEPS file to contain `_CallocAllocator`.

New API landed in: https://dart-review.googlesource.com/c/sdk/+/177705

Issue: https://github.com/dart-lang/sdk/issues/44621
Issue: https://github.com/dart-lang/sdk/issues/38721

Change-Id: I546de7ec65ceb6f05644a5f269b83f64656892e5
Cq-Include-Trybots: luci.dart.try:benchmark-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178995
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-01-14 12:35:58 +00:00
Jonas Termansen 80621fed03 [benchmark] Add language version comments to benchmarks.
Change-Id: I44047a9d7907d166a6360397d0047ce9b835e5c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166854
Auto-Submit: Jonas Termansen <sortie@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
2020-10-13 01:43:22 +00:00
Daco Harkes 585fa217a1 [benchmarks/ffi] Migrate benchmarks to NNBD
Change-Id: I36568f4f4d59c0a337aab82b6ca15d40495cb269
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152850
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2020-06-30 14:44:27 +00:00
Daco Harkes f0851772e9 [benchmarks/ffi] Fix lints
Change-Id: I37fe24f122ed9da269be658b9f98b957ddfcb7fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152848
Reviewed-by: Clement Skau <cskau@google.com>
2020-06-30 14:44:27 +00:00
Daco Harkes d87046342f [benchmarks/ffi] Add FfiCall benchmark with Handles
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: https://github.com/dart-lang/sdk/issues/36858
Issue: https://github.com/dart-lang/sdk/issues/41319

New issue for optimizing multiple handles:
https://github.com/dart-lang/sdk/issues/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>
2020-06-15 13:27:16 +00:00
Jonas Termansen 0f505e0e08 [benchmark] Fix oversights from the benchmark fork.
The shared libraries for the FfiBoringssl benchmark had been moved up a
level but unfortunately the same change wasn't made for the FfiCall
benchmark.

The IsolateJson benchmark had a typo in the path and broke.

Change-Id: Iec2fec1d5508022d9cfbfb040d80c74b078a0640
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150024
Reviewed-by: William Hesse <whesse@google.com>
2020-06-04 11:00:20 +00:00
Jonas Termansen 6f66f82625 [benchmark] Fork benchmarks for null safety and pin internal ones.
This change forks the benchmarks for the null safety feature where there
now is a null safe version at benchmarks/Foo/dart and a legacy Dart 2
version at benchmarks/Foo/dart2. This change allows benchmarks to be
migrated per go/dart-nnbd-benchmark-migration.

Additionally this change pins the internal benchmarks which have been
moved into their own repository and is now versioned along with the Dart
SDK.

The dart2 implementation will be benchmarked instead of the null safe
dart implementation as of this change. The null safe dart implementation
will be used when null safe benchmarking is turned on.

Change-Id: If039fd7100c960169f4161c1d98167aca0af2ded
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148440
Reviewed-by: Alexander Thomas <athom@google.com>
2020-06-02 12:53:24 +00:00
Samir Jindel c885bdde1d [vm] DBC is obsolete. Remove dead code.
Change-Id: Ica33af158cca53c8e951e4b2582de83660e8a60d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121851
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-27 18:18:29 +00:00
Samir Jindel 63d3012e68 [vm/ffi] Deprecate Pointer.allocate/free.
Fixes https://dart-review.googlesource.com/c/sdk/+/118442.

Also updates untested sample code in samples/ffi.

Change-Id: Id40a7b8fbb35c5d989269646ebb22864cebcfcac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118441
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-10 13:17:43 +00:00
Daco Harkes fbf13f561f [benchmarks/ffi] Add micro and macro benchmarks for dart:ffi
Adds micro benchmarks to measure low level (1) C memory reads and writes from Dart and (2) calls from Dart into C. This CL also adds a macro benchmark to measure overall performance using BoringSSL to digest data. The shared libraries are precompiled for Linux and live in cipd packages. The benchmarks run on all hardware architectures (with the exception of Linux'es hardfp on Arm32: https://github.com/dart-lang/sdk/issues/36309).

Issue: https://github.com/dart-lang/sdk/issues/36247

Change-Id: I8dfb30cc66a26a2942bb09194c5eb0da0b6ca1b5
Cq-Include-Trybots: luci.dart.try:benchmark-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108724
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2019-07-19 14:59:57 +00:00