-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.customer-flutter
Description
This tracker is for issues related to:
- Dart VM
Description
I was doing some performance testing on iOS and noticed that 7% of CPU time was spent in GetCurrentThreadCPUMicrosForTimeline. It is the second hottest symbol I'm executing beyond memcpy (I'm copying thousands of buffers that are a megabyte big for microbenchmarks). Compared to the other symbols, some that are also doing system calls, it's shocking how much CPU time it is taking.
Steps to reproduce
- Check out https://github.com/flutter/flutter/tree/master/dev/benchmarks/platform_channels_benchmarks
- Make the following code change so channels use
compute(which will call Dart_TimelineEvent which calls GetCurrentThreadCPUMicrosForTimeline)\
--- a/packages/flutter/lib/src/services/platform_channel.dart
+++ b/packages/flutter/lib/src/services/platform_channel.dart
@@ -57,7 +57,10 @@ class BasicMessageChannel<T> {
/// Returns a [Future] which completes to the received response, which may
/// be null.
Future<T?> send(T message) async {
- return codec.decodeMessage(await binaryMessenger.send(name, codec.encodeMessage(message)));
+ final ByteData? encodedResult =
+ await binaryMessenger.send(name, codec.encodeMessage(message));
+ return compute<ByteData?, T?>(codec.decodeMessage, encodedResult);
+// return codec.decodeMessage(await binaryMessenger.send(name, codec.encodeMessage(message)));
}- Run the platform channels benchmarks with
flutter run --profilewith instruments running a Time Profiler probe.
Profile
All of the time is in the thread_info call.
Version
Dart version 2.16.0 (build 2.16.0-56.0.dev)
Evaluation
Can't we just use the system clock for Dart_TimelineEvent, why does it have to be the clock from thread_info?
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.customer-flutter

