From 75311aefa8f8db6121d6a4fc4e4792a6ca67dafd Mon Sep 17 00:00:00 2001 From: Derek Xu Date: Tue, 22 Apr 2025 07:42:27 -0700 Subject: [PATCH] [VM/Timeline] Add Microtask stream TEST=runtime/vm/dart_api_impl_test.cc Change-Id: Icb078489f3600ac0fb8b314ca3bf748f482a687e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422860 Reviewed-by: Ben Konyi --- pkg/dartdev/lib/src/commands/run.dart | 5 +++-- pkg/vm_service/java/version.properties | 2 +- pkg/vm_service/lib/src/vm_service.dart | 2 +- pkg/vm_service_interface/lib/src/vm_service_interface.dart | 2 +- runtime/bin/main_options.cc | 6 +++--- runtime/docs/timeline.md | 3 ++- runtime/include/dart_tools_api.h | 1 + runtime/observatory/tests/service/get_version_rpc_test.dart | 2 +- runtime/vm/dart_api_impl_test.cc | 3 +++ runtime/vm/service.h | 2 +- runtime/vm/service/service.md | 5 +++-- runtime/vm/timeline.cc | 2 +- runtime/vm/timeline.h | 1 + 13 files changed, 22 insertions(+), 14 deletions(-) diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart index b1bc4788799..fcfdebaebb1 100644 --- a/pkg/dartdev/lib/src/commands/run.dart +++ b/pkg/dartdev/lib/src/commands/run.dart @@ -153,8 +153,9 @@ class RunCommand extends DartdevCommand { 'timeline-streams', help: 'Enables recording for specific timeline streams.\n' 'Valid streams include: all, API, Compiler, CompilerVerbose, Dart, ' - 'Debugger, Embedder, GC, Isolate, VM.\n' - 'Defaults to "Compiler, Dart, GC" when --observe is provided.', + 'Debugger, Embedder, GC, Isolate, Microtask, VM.\n' + 'Defaults to "Compiler, Dart, GC, Microtask" when --observe is ' + 'provided.', valueHelp: 'str1, str2, ...', hide: !verbose, ); diff --git a/pkg/vm_service/java/version.properties b/pkg/vm_service/java/version.properties index 6d2c168d5e0..8a10b956333 100644 --- a/pkg/vm_service/java/version.properties +++ b/pkg/vm_service/java/version.properties @@ -1 +1 @@ -version=4.17 +version=4.18 diff --git a/pkg/vm_service/lib/src/vm_service.dart b/pkg/vm_service/lib/src/vm_service.dart index d5cbefc285e..e14557b3bf3 100644 --- a/pkg/vm_service/lib/src/vm_service.dart +++ b/pkg/vm_service/lib/src/vm_service.dart @@ -27,7 +27,7 @@ export 'snapshot_graph.dart' HeapSnapshotObjectNoData, HeapSnapshotObjectNullData; -const String vmServiceVersion = '4.17.0'; +const String vmServiceVersion = '4.18.0'; /// @optional const String optional = 'optional'; diff --git a/pkg/vm_service_interface/lib/src/vm_service_interface.dart b/pkg/vm_service_interface/lib/src/vm_service_interface.dart index 53036d01c2e..daec83769ae 100644 --- a/pkg/vm_service_interface/lib/src/vm_service_interface.dart +++ b/pkg/vm_service_interface/lib/src/vm_service_interface.dart @@ -17,7 +17,7 @@ import 'service_extension_registry.dart'; export 'service_extension_registry.dart' show ServiceExtensionRegistry; -const String vmServiceVersion = '4.17.0'; +const String vmServiceVersion = '4.18.0'; /// A class representation of the Dart VM Service Protocol. abstract interface class VmServiceInterface { diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc index 315222b3ccd..eac2cf36ec1 100644 --- a/runtime/bin/main_options.cc +++ b/runtime/bin/main_options.cc @@ -168,7 +168,7 @@ void Options::PrintUsage() { " --pause-isolates-on-exit\n" " --pause-isolates-on-unhandled-exceptions\n" " --warn-on-pause-with-no-debugger\n" -" --timeline-streams=\"Compiler, Dart, GC\"\n" +" --timeline-streams=\"Compiler, Dart, GC, Microtask\"\n" " This set is subject to change.\n" " Please see these options (--help --verbose) for further documentation.\n" "--write-service-info=\n" @@ -210,7 +210,7 @@ void Options::PrintUsage() { " --pause-isolates-on-exit\n" " --pause-isolates-on-unhandled-exceptions\n" " --warn-on-pause-with-no-debugger\n" -" --timeline-streams=\"Compiler, Dart, GC\"\n" +" --timeline-streams=\"Compiler, Dart, GC, Microtask\"\n" " This set is subject to change.\n" " Please see these options for further documentation.\n" #endif // !defined(PRODUCT) @@ -456,7 +456,7 @@ bool Options::ProcessObserveOption(const char* arg, vm_options->AddArgument("--pause-isolates-on-unhandled-exceptions"); vm_options->AddArgument("--profiler"); vm_options->AddArgument("--warn-on-pause-with-no-debugger"); - vm_options->AddArgument("--timeline-streams=\"Compiler,Dart,GC\""); + vm_options->AddArgument("--timeline-streams=\"Compiler,Dart,GC,Microtask\""); #if !defined(DART_PRECOMPILED_RUNTIME) dfe()->set_use_incremental_compiler(true); #endif // !defined(DART_PRECOMPILED_RUNTIME) diff --git a/runtime/docs/timeline.md b/runtime/docs/timeline.md index bed61056c3e..d1df0e97f4b 100644 --- a/runtime/docs/timeline.md +++ b/runtime/docs/timeline.md @@ -33,6 +33,7 @@ Streams, also called categories, are sets of events whose recordering can be ena | `Embedder` | Events created by `Dart_RecordTimelineEvent`. | | `GC` | Events related to garbage collection or heap iteration. | | `Isolate` | Isolate or isolate group lifecycle events such as startup or shutdown. | +| `Microtask` | Events representing `dart:async` microtasks. This stream only contains events when the VM is started with the `--profile-microtasks` flag. | | `VM` | VM lifecycle events such a startup or shutdown. | The set of enabled streams can be selected with the `timeline_streams` flag. E.g., `--timeline_stream=VM,Isolate,GC,Dart` or `--timeline_streams=All`. @@ -45,7 +46,7 @@ There are also some convenience flags: | Flag | Expansion | | ---- | --------- | -|`--timeline_streams=All` | `--timeline_streams=API,Compiler,CompilerVerbose,Dart,Debugger,Embedder,GC,Isolate,VM` | +|`--timeline_streams=All` | `--timeline_streams=API,Compiler,CompilerVerbose,Dart,Debugger,Embedder,GC,Isolate,Microtask,VM` | | `--complete_timeline` | `--timeline_recorder=endless --timeline_streams=All` | | `--startup_timeline` | `--timeline_recorder=startup --timeline_streams=All` | diff --git a/runtime/include/dart_tools_api.h b/runtime/include/dart_tools_api.h index 367e1eb56fa..1ec1a2c8bf2 100644 --- a/runtime/include/dart_tools_api.h +++ b/runtime/include/dart_tools_api.h @@ -300,6 +300,7 @@ DART_EXPORT bool Dart_IsReloading(); * "Embedder" - Execution of Dart embedder code * "GC" - Execution of Dart Garbage Collector * "Isolate" - Dart Isolate lifecycle execution + * "Microtask" - Execution of Dart microtasks * "VM" - Execution in Dart VM runtime code * "" - None * diff --git a/runtime/observatory/tests/service/get_version_rpc_test.dart b/runtime/observatory/tests/service/get_version_rpc_test.dart index 3dbb24a7725..32dddc5dbe0 100644 --- a/runtime/observatory/tests/service/get_version_rpc_test.dart +++ b/runtime/observatory/tests/service/get_version_rpc_test.dart @@ -12,7 +12,7 @@ var tests = [ final result = await vm.invokeRpcNoUpgrade('getVersion', {}); expect(result['type'], 'Version'); expect(result['major'], 4); - expect(result['minor'], 17); + expect(result['minor'], 18); expect(result['_privateMajor'], 0); expect(result['_privateMinor'], 0); }, diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc index 49cef77ff68..6712acee2d5 100644 --- a/runtime/vm/dart_api_impl_test.cc +++ b/runtime/vm/dart_api_impl_test.cc @@ -10140,6 +10140,7 @@ TEST_CASE(DartAPI_TimelineCategories) { EXPECT_NOTSUBSTRING("Debugger", js_str); EXPECT_NOTSUBSTRING("Embedder", js_str); EXPECT_NOTSUBSTRING("Isolate", js_str); + EXPECT_NOTSUBSTRING("Microtask", js_str); EXPECT_NOTSUBSTRING("VM", js_str); } @@ -10158,6 +10159,7 @@ TEST_CASE(DartAPI_TimelineCategories) { EXPECT_NOTSUBSTRING("Debugger", js_str); EXPECT_NOTSUBSTRING("Embedder", js_str); EXPECT_SUBSTRING("Isolate", js_str); + EXPECT_NOTSUBSTRING("Microtask", js_str); EXPECT_NOTSUBSTRING("VM", js_str); } @@ -10176,6 +10178,7 @@ TEST_CASE(DartAPI_TimelineCategories) { EXPECT_NOTSUBSTRING("Debugger", js_str); EXPECT_NOTSUBSTRING("Embedder", js_str); EXPECT_NOTSUBSTRING("Isolate", js_str); + EXPECT_NOTSUBSTRING("Microtask", js_str); EXPECT_NOTSUBSTRING("VM", js_str); } } diff --git a/runtime/vm/service.h b/runtime/vm/service.h index 8a39d8c326c..6562f6fdc9b 100644 --- a/runtime/vm/service.h +++ b/runtime/vm/service.h @@ -19,7 +19,7 @@ namespace dart { #define SERVICE_PROTOCOL_MAJOR_VERSION 4 -#define SERVICE_PROTOCOL_MINOR_VERSION 17 +#define SERVICE_PROTOCOL_MINOR_VERSION 18 class Array; class EmbedderServiceHandler; diff --git a/runtime/vm/service/service.md b/runtime/vm/service/service.md index 9df2c5a1235..446a9bb29d9 100644 --- a/runtime/vm/service/service.md +++ b/runtime/vm/service/service.md @@ -1,8 +1,8 @@ -# Dart VM Service Protocol 4.17 +# Dart VM Service Protocol 4.18 > Please post feedback to the [observatory-discuss group][discuss-list] -This document describes of _version 4.16_ of the Dart VM Service Protocol. This +This document describes of _version 4.18_ of the Dart VM Service Protocol. This protocol is used to communicate with a running Dart Virtual Machine. To use the Service Protocol, start the VM with the *--observe* flag. @@ -4994,5 +4994,6 @@ version | comments 4.15 | Added `closureReceiver` property to `@Instance` and `Instance`. 4.16 | Added `reloadFailureReason` property to `Event`. Added `createIdZone`, `deleteIdZone`, and `invalidateIdZone` RPCs. Added optional `idZoneId` parameter to `evaluate`, `evaluateInFrame`, `getInboundReferences`, `getInstances`, `getInstancesAsList`, `getObject`, `getRetainingPath`, `getStack`, and `invoke` RPCs. 4.17 | Added `Timer` stream, added `TimerSignificantlyOverdue` event kind, and added `details` property to `Event`. +4.18 | Added `Microtask` timeline stream. [discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc index f90a108eb7b..8e8a9b75b39 100644 --- a/runtime/vm/timeline.cc +++ b/runtime/vm/timeline.cc @@ -77,7 +77,7 @@ DEFINE_FLAG(charp, nullptr, "Comma separated list of timeline streams to record. " "Valid values: all, API, Compiler, CompilerVerbose, Dart, " - "Debugger, Embedder, GC, Isolate, and VM."); + "Debugger, Embedder, GC, Isolate, Microtask, and VM."); DEFINE_FLAG(charp, timeline_recorder, DEFAULT_TIMELINE_RECORDER, diff --git a/runtime/vm/timeline.h b/runtime/vm/timeline.h index a4a17348bb3..df1db117c50 100644 --- a/runtime/vm/timeline.h +++ b/runtime/vm/timeline.h @@ -78,6 +78,7 @@ class Zone; V(Embedder, "dart:embedder", true) \ V(GC, "dart:gc", true) \ V(Isolate, "dart:isolate", true) \ + V(Microtask, "dart:microtask", true) \ V(VM, "dart:vm", true) #endif // defined(SUPPORT_TIMELINE)