Commit Graph

235 Commits

Author SHA1 Message Date
Ryan Macnak 55f91b69a5 [vm] Remove unneeded HandleScope immediately after StackZone.
There's no point in unwinding the zone's scoped handle blocks just before deleting the entire zone.

TEST=ci
Change-Id: I364c717bffd16f727d6f2427a7b9693a83d74c13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499400
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-29 15:36:54 -07:00
Alexander Aprelev 8649806076 [vm/profiler/gardening] Fix TSAN failures in profiler.
Use relaxed atomics for sample fields.
Fix lock grabbing ordering.

BUG=https://github.com/dart-lang/sdk/issues/62873
TEST=ci

Change-Id: I9c4ae0c78d5b81a72dc8a9e4802f08fd57beb27a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493161
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-04-06 10:35:42 -07:00
Slava Egorov 618d608c81 [perf_witness] Fix -o behavior with relative path
Target process and the recorder might be running in different working
directories so request to start recording should always use absolute
path.

This also cleans up how file recorders are created: it does not make
sense to create the recorder and the check if we can open the file
(in fact: creating recorder and failing to open file will cause
deadlocks). Thus this CL changes the code to first open the file
and only if we succeeded creates the recorder.

Fixes https://github.com/dart-lang/sdk/issues/62959

TEST=extended existing tests to cover this

Change-Id: Ib9d88ce23d93bcc5d6335ba1daebad2e6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490160
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-03-24 06:46:47 -07:00
Slava Egorov c3bd038008 [vm] Fix profile streaming in debug mode.
Simplify isolate group enter-exit logic in EmitModuleSymbolsFor: always
call it without an active isolate group. Make sure that we 
destroy StackZone before trying to exit the isolate.

Skip unit test with deferred units on Mac OS: as we don't support
deferred units when writing out Mach-O files currently.

TEST=ci

Change-Id: I8a8615f045781f263c92c45eecf955366a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483760
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-26 03:28:56 -08:00
Slava Egorov d7fa1ced6a [vm] Speedup profile data streaming in AOT
Current implementation of profile data streaming inherited its 
approach to symbolization from the implementation of vm-service's
get{,Perfetto}CpuSamples methods. These methods rather expensive
as they rely on CodeLookupTable to symbolize collected samples, and
constructing CodeLookupTable requires bringing all threads to safepoint
and iterating over old-space to collect code objects. This can take
significant amount of time - especially when old-space is large (e.g.
consider 1Gb+ heaps of Dart Analysis Server).

This CL rewrites profile data streaming to use a completely different
approach in AOT mode where Dart frames are not symbolized eagerly 
and instead stored in the timeline in their raw form: a pair of
an isolate group specific Mapping and a PC value relative to the start
of that mapping. At the end of streaming (or when isolate group
exits) an additional ModuleSymbols packet is emitted which provides
symbolization information for all collected frames. ModuleSymbols
mappings can be cheaply constructed from collected PCs using 
ReversePc lookup tables.

TEST=expanded existing tests

Change-Id: I56ef1dd4c9a17fb0d2e9c24e51f2e4656a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482782
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-25 04:48:51 -08:00
Slava Egorov 4ec7f9c25d [vm] Fix timeline track metadata handling
AddTrackMetadataBasedOnThread was looking at FLAG_timeline_recorder
to determine if it can skip recording metadata. However the flag
value is not necessary in sync with the current recorder because
NativeRuntime.streamTimelineTo can reconfigure recorder itself
without changing flag value.

It seems strange to be checking the flag instead of using proper OOP
anyway - the function is already virtual. This CL removes code
which was checking the FLAG and instead overrides the method in
subclasses which don't care about track metadata.

TEST=existing tests were updated to cover this case

Change-Id: I2a2859ab5ef28d8d6d2358259cc9ed8d6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476400
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-01-29 02:55:30 -08:00
Slava Egorov 0fee95455c [vm] Cleanup Profiler lifecycle
Move away from setting command line flags and calling Cleanup or Init
to reinitialize the profiler. Split starting and stopping the profiler
into separate methods and keep only one-time initialization/cleanup
in Init and Cleanup methods. Create a separate method for reconfiguring
the profiler Profiler::SetConfig.

This removes data races which were plaguing older code and makes it
simpler to reason about.

Fixes https://github.com/dart-lang/sdk/issues/62038
Fixes https://github.com/dart-lang/sdk/issues/61828

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-tsan-mac-release-arm64-try,vm-tsan-linux-release-x64-try
Change-Id: I679aa0a8724e39624e76abfad6814fe06a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472862
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-20 05:58:38 -08:00
Ryan Macnak 5541255c4e [vm] Fix data race over file timeline recorder's cached blocks.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/61475
Bug: https://github.com/dart-lang/sdk/issues/61796
Change-Id: I6995b00b47c3d67a7ea0a4a0e7d72509058ee392
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458060
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-10-28 12:34:49 -07:00
Vyacheslav Egorov 489f63a3bd [vm] Add NativeRuntime.streamTimelineTo
This API allows to programmatically generate timeline information 
including profiling samples if timeline format supports it.

This change also includes Perfetto timeline writer and profiler 
into non-mobile PRODUCT builds. The size of Mac OS X dartaotruntime
has increased by 34352 bytes (0.7%).

This relands commit 553887bc56 with fixes
for Android builds.

TEST=vm/dart/stream_timeline_to_test

CoreLibraryReviewExempt: VM specific dart:developer API.
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-product-arm-try,vm-ffi-android-release-arm-try,vm-aot-android-release-arm64c-try
Change-Id: Ifb7c66982fe9d17d2f5c9acb163a94c56a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457301
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-10-24 04:34:01 -07:00
Slava Egorov b24698b9b5 Revert "[vm] Add NativeRuntime.streamTimelineTo"
This reverts commit 553887bc56.

Reason for revert: Broken android builds

Original change's description:
> [vm] Add NativeRuntime.streamTimelineTo
>
> This API allows to programmatically generate timeline information 
> including profiling samples if timeline format supports it.
>
> This change also includes Perfetto timeline writer and profiler 
> into non-mobile PRODUCT builds. The size of Mac OS X dartaotruntime
> has increased by 34352 bytes (0.7%).
>
> TEST=vm/dart/stream_timeline_to_test
>
> CoreLibraryReviewExempt: VM specific dart:developer API.
> Change-Id: I326f5fd29ee82a503160f5f5a2a857a7c55330ec
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426220
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I583ad74b850514fb47054149da464a07874fc2f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-10-23 04:58:29 -07:00
Vyacheslav Egorov 553887bc56 [vm] Add NativeRuntime.streamTimelineTo
This API allows to programmatically generate timeline information 
including profiling samples if timeline format supports it.

This change also includes Perfetto timeline writer and profiler 
into non-mobile PRODUCT builds. The size of Mac OS X dartaotruntime
has increased by 34352 bytes (0.7%).

TEST=vm/dart/stream_timeline_to_test

CoreLibraryReviewExempt: VM specific dart:developer API.
Change-Id: I326f5fd29ee82a503160f5f5a2a857a7c55330ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-10-23 04:47:13 -07:00
Slava Egorov 07c9599ead [vm] Tweak location of Perfetto protos
This CL tries to address version skew issues which occur in internal
monorepo which we created by checking in *.pbzero.h files into
runtime/vm/protos/*. These files refer to protozero internal headers,
which in the internal monorepo come from a shared Perfetto dependency
which does not necessarily match the version we pinned in our DEPS and
used to generated these files.

This version skew caused problems for the Perfetto team, see
https://github.com/google/perfetto/pull/3195

To resolve this change layout of our repo to allow us to depend on the
shared Perfetto entirely - including its version of *.pbzero.h headers.

We change include paths in the VM source to

    #include "third_party/perfetto/protos/..."

which match location of these headers in the internal monorepo.

To make the code compile in the normal SDK checkout we shift location of
Perfetto and checked in code:

* Perfetto source moves from third_party/perfetto to
  third_party/perfetto/src.
* Generated code moves from runtime/vm/protos into
  third_party/perfetto/protos.

Note: experiments show that *.pbzero.h files tree-shake very well and
you pay only for things that you use. That means depending on *.pbzero.h
files generated from full message definitions rather than our manually
tree-shaken versions does not actually increase the size of the VM
binaries. We could switch our external build to do the same but this
would make protoc a build time dependency, which seems excessive.

TEST=ci

Change-Id: I724b9d9304be83302a5d83c2337154b36a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454260
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-10-13 02:09:31 -07:00
asiva d417da5ed5 [VM/Runtime] Cleanup TimelineEventArgument state when it is reused so that there is no stale state when TimelineEventArgument::Free is called.
TEST=ci

Change-Id: Ia7d7712a4e014b5a330477eac88a61521c19ca25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310777
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-07-31 09:26:40 -07:00
Tess Strickland 6b53073eae Reland "[vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots."
This is a reland of commit 38ef28a058

Fixes:

* Fix comparisons in ASSERT_EQUAL statements on 32-bit architectures.
* Take simulated architectures into account when deciding whether
  to use dlopen() for native shared object formats.
* Fix struct/field name collision for GCC.
* Use CPU_TYPE_ANY/CPU_SUBTYPE_ANY for architectures that do not
  have more specific cpu_type_t/cpu_subtype_t constants defined.

Original change's description:
> [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
>
> This is the initial framework for creating snapshots as Mach-O dynamic
> libraries. Note that this framework is not 100% feature complete
> compared to generating Mach-O snapshots via assembly. In particular,
> the directly-compiled Mach-O dylib does not yet contain compact
> unwinding information.
>
> Other changes:
>
> * Adds UuidCommand to the native_stack_traces package's Mach-O reader,
>   which now appropriately returns the UUID as the build ID for Mach-O
>   shared objects.
>
> * Adds Utils::Basename(path) for portably retrieving the basename
>   from a path. (Returns nullptr for all arguments where it is not
>   currently implemented on Fuchsia or Windows.)
>
> * Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
>   as that interferes with uses of the namespaced Mach-O definitions
>   in platform/mach_o.h.
>
> * Only attempt to dlopen() a snapshot if ELF is the native format
>   for the host platform or the snapshot is not an ELF shared object.
>   If dlopen() is used, report the error message if it fails rather
>   than attempting to manually load the snapshot as an ELF shared object.
>
> * Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
>   dynamic libraries.
>
> * Remove the detection of reverse-endian Mach-O magic numbers in
>   DartUtils::SniffForMagicNumber(), since all our Mach-O related code
>   assumes host-endian Mach-O files and so there's no point other than
>   to give a slightly better error message when failing.
>
> TEST=vm/dart/exported_symbols_test
>      vm/dart/unobfuscated_static_symbols_test
>      vm/dart/use_dwarf_stack_traces_flag_test
>      vm/cc/CanDetectMachOFiles
>
> Issue: https://github.com/dart-lang/sdk/issues/60307
> Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

TEST=vm/dart/exported_symbols_test
     vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test
     vm/cc/CanDetectMachOFiles
     ci on trybots that failed on the original CL

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try
Change-Id: Iaffea0ddc6173100c8b5b2a9fe46c45f4f611a2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431240
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-05-27 06:30:20 -07:00
Tess Strickland 38ea3a8f5e Revert "[vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots."
This reverts commit 38ef28a058.

Reason for revert: Breaks build on debug mode 32-bit arches,
                   release mode simarm_x64

Issue: https://github.com/dart-lang/sdk/issues/60307
Original change's description:
> [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
>
> This is the initial framework for creating snapshots as Mach-O dynamic
> libraries. Note that this framework is not 100% feature complete
> compared to generating Mach-O snapshots via assembly. In particular,
> the directly-compiled Mach-O dylib does not yet contain compact
> unwinding information.
>
> Other changes:
>
> * Adds UuidCommand to the native_stack_traces package's Mach-O reader,
>   which now appropriately returns the UUID as the build ID for Mach-O
>   shared objects.
>
> * Adds Utils::Basename(path) for portably retrieving the basename
>   from a path. (Returns nullptr for all arguments where it is not
>   currently implemented on Fuchsia or Windows.)
>
> * Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
>   as that interferes with uses of the namespaced Mach-O definitions
>   in platform/mach_o.h.
>
> * Only attempt to dlopen() a snapshot if ELF is the native format
>   for the host platform or the snapshot is not an ELF shared object.
>   If dlopen() is used, report the error message if it fails rather
>   than attempting to manually load the snapshot as an ELF shared object.
>
> * Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
>   dynamic libraries.
>
> * Remove the detection of reverse-endian Mach-O magic numbers in
>   DartUtils::SniffForMagicNumber(), since all our Mach-O related code
>   assumes host-endian Mach-O files and so there's no point other than
>   to give a slightly better error message when failing.
>
> TEST=vm/dart/exported_symbols_test
>      vm/dart/unobfuscated_static_symbols_test
>      vm/dart/use_dwarf_stack_traces_flag_test
>      vm/cc/CanDetectMachOFiles
>
> Issue: https://github.com/dart-lang/sdk/issues/60307
> Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

Issue: https://github.com/dart-lang/sdk/issues/60307
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iff2ab4c84a513a184784129f456bd357ae8e3a67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431220
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2025-05-27 01:05:48 -07:00
Tess Strickland 38ef28a058 [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
This is the initial framework for creating snapshots as Mach-O dynamic
libraries. Note that this framework is not 100% feature complete
compared to generating Mach-O snapshots via assembly. In particular,
the directly-compiled Mach-O dylib does not yet contain compact
unwinding information.

Other changes:

* Adds UuidCommand to the native_stack_traces package's Mach-O reader,
  which now appropriately returns the UUID as the build ID for Mach-O
  shared objects.

* Adds Utils::Basename(path) for portably retrieving the basename
  from a path. (Returns nullptr for all arguments where it is not
  currently implemented on Fuchsia or Windows.)

* Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
  as that interferes with uses of the namespaced Mach-O definitions
  in platform/mach_o.h.

* Only attempt to dlopen() a snapshot if ELF is the native format
  for the host platform or the snapshot is not an ELF shared object.
  If dlopen() is used, report the error message if it fails rather
  than attempting to manually load the snapshot as an ELF shared object.

* Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
  dynamic libraries.

* Remove the detection of reverse-endian Mach-O magic numbers in
  DartUtils::SniffForMagicNumber(), since all our Mach-O related code
  assumes host-endian Mach-O files and so there's no point other than
  to give a slightly better error message when failing.

TEST=vm/dart/exported_symbols_test
     vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test
     vm/cc/CanDetectMachOFiles

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-05-26 08:52:26 -07:00
Ryan Macnak eb563faf6d [vm, gc] Report RSS as timeline counter events, sampled before and after GC.
Catapult will display a nice graph for this.

TEST=view timeline
Change-Id: I6b6fdede463b37dbb10841cfa7c1e08c95e7cb62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427060
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-12 10:46:39 -07:00
Vyacheslav Egorov 3e65c9d2a7 [vm] Buffer writes in TimelineEventFileRecorderBase
Previous implementation allocated individual events and then
executed writes directly - both of these add unnecessary overhead.

Instead allocate and process events in blocks just like other
recorders and buffer writes in a temporary buffer before passing
data to Dart::file_write_callback().

Currently if you write something like this:

    int fib(int n) {
      return Timeline.timeSync('fib', () {
        // typical recursive fib implementation here.
      });
    }

    for (var i = 0; i < 1000; i++) {
      fib(10);
    }

and then run it with perfettofile recorder you end up waiting several
seconds before recorder is drained with program spending most time
doing small writes via File::WriteFully.

This is no longer the case after this change.

TEST=ci

Change-Id: I6a33ccdb1f293a94669ad0dd7d883837b86c8b6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426861
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-07 08:13:17 -07:00
Derek Xu 75311aefa8 [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 <bkonyi@google.com>
2025-04-22 07:42:27 -07:00
Derek Xu 2cc25a8baf [VM/Timeline] Fix bug in timeline proto arguments
TEST=This can only be tested by writing events using the C++ timeline
API. My tests for microtask profiling will cover this.

Change-Id: Ie68dcee5b696f41c3f2244ae524199f57986a94d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421860
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-04-10 08:55:19 -07:00
Vyacheslav Egorov 2a437c54a0 [vm] Intern strings when writing Perfetto timeline
Intern the following fields:

* Category names
* Event labels
* Debug annotation keys and values

This significantly reduces the size of the timeline
(e.g. a timeline containing 60k slices goes from 15Mb
to 5Mb timeline)

This relands commit f2614d24f8
with a fix for Android build.

TEST=ci and manually

Cq-Include-Trybots: luci.dart.try:vm-ffi-android-release-arm64c-try
Change-Id: I88d4c5e1142ff66b270a22b82bacd1e9313fa953
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418220
Reviewed-by: Derek Xu <derekx@google.com>
2025-03-27 06:44:23 -07:00
Vyacheslav Egorov f9e5b9282b Revert "[vm] Intern strings when writing Perfetto timeline"
This reverts commit f2614d24f8.

Reason for revert: Android build broken

Original change's description:
> [vm] Intern strings when writing Perfetto timeline
>
> Intern the following fields:
>
> * Category names
> * Event labels
> * Debug annotation keys and values
>
> This significantly reduces the size of the timeline
> (e.g. a timeline containing 60k slices goes from 15Mb
> to 5Mb timeline)
>
> TEST=ci and manually
>
> Change-Id: I59e850279b6714b8b75c5b8e79e6a8b0a981a261
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417202
> Reviewed-by: Derek Xu <derekx@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I17b83f06ca78fb4b91af554ff4b2aff00366d107
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418024
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
2025-03-26 14:26:58 -07:00
Vyacheslav Egorov f2614d24f8 [vm] Intern strings when writing Perfetto timeline
Intern the following fields:

* Category names
* Event labels
* Debug annotation keys and values

This significantly reduces the size of the timeline
(e.g. a timeline containing 60k slices goes from 15Mb
to 5Mb timeline)

TEST=ci and manually

Change-Id: I59e850279b6714b8b75c5b8e79e6a8b0a981a261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417202
Reviewed-by: Derek Xu <derekx@google.com>
2025-03-26 14:05:39 -07:00
Vyacheslav Egorov 00b3627b7f [vm] Reduce duplication when writing Perfetto packets
Consolidate code populating TracePacket in a single
function instead of multiple helpers. Most of the
duplication in the previous code was caused by
how Duration events were handled - this CL
avoids this duplication by making the core helper
takes event_type, timestamp and timeline event.

This allows to perform Duration split simply by
doing:

  PopulateAndWritePacket(TimelineEvent::kBegin, event.TimeOrigin(), event);
  PopulateAndWritePacket(TimelineEvent::kEnd, event.TimeEnd(), event);

Instead of duplicating large chunks of code.

TEST=ci

Change-Id: Ica5d00264f3e872b939059ea90fcbfbf6c8768e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417201
Reviewed-by: Derek Xu <derekx@google.com>
2025-03-26 11:29:03 -07:00
Vyacheslav Egorov 6659976329 [vm] Reduce duplication in timeline.cc
Place serialization code shared between fixed
buffer and endless recorders into an abstract
superclass.

TEST=ci

Change-Id: I643e606ec144b06406375b796f4f2b369b657d3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417200
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-03-25 08:13:56 -07:00
Ryan Macnak 94a0f6b530 [vm] Fix hang during file recorder shutdown due to drain function never running.
TEST=ci, rr chaos mode
Bug: https://github.com/dart-lang/sdk/issues/59620
Change-Id: I806f836dc5e21bb5b7048f49ebda5188e9ce340e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400002
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-12-10 22:28:49 +00:00
Ryan Macnak 2719e10bfa [vm, timeline] Include thread names when using the file recorder.
TEST=ci
Change-Id: I95fb30d4da30dcdb0ee725827120e266133af2b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384581
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2024-09-10 21:07:18 +00:00
Ryan Macnak 2c4e65f85f [vm] Drain all events when shutting down the file timeline recorder.
TEST=vm/dart/isolates/fast_object_copy_timeline_test
Change-Id: I650adcf552e5532fb8bffbf942a099adf7bab285
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375022
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-07-10 16:03:38 +00:00
Martin Kustermann 698bf0846b [vm] Hoist CStringUniquePtr out of Utils, add CAllocUniquePtr` to simplify code
Hoist `CStringUniquePtr` out of the `Utils` class as there
is no reason it has to be nested inside a class - it just makes
code more verbose.

This simplifies code of the form
   std::unique_ptr<T, decltype(std::free)> a = { nullptr, std::free };
to
   CAllocUniquePtr<T> a;

TEST=ci

Change-Id: Ice42c1b16dfa5b20b321c13fbe5b28b3918581cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368425
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-05-29 10:16:28 +00:00
Daco Harkes f98a2138b7 [vm] Run clang-format on code base
When uploading CLs, the presubmit checks verify that the lines in the
diff are formatted correctly according to `git cl format runtime`.

However, when `buildtools/<os>-<arch>/clang/bin/clang-format` is
updated, it does not force reformatting of files that would be
reformatted.

This leads to two issues:
* Inconsistent style within the code base and within a single file.
* Spurious reformatting in CLs when (1) clang-format is used on the
  whole file, or (2) the diff lines overlap.

`clang-format` doesn't change that frequently, so in general this is
not a large issue, but I've seen a bit too many "spurious formatting,
please revert" comments on CLs recently.

This CL formats the runtime to be in line with the current pinned
`clang-format`:

```
$ find runtime/ -iname *.h -o -iname *.cc | xargs buildtools/mac-arm64/clang/bin/clang-format -i
```

`git cl format` (which only formats changed lines, and does so with
`clang-format`) seems to not agree with itself, or clang-format, or
cpplint in a handful of places. This CL adds `// clang-format off`
for these. (See previous patchsets for the specific instances.)

TEST=A variety of bots including GCC, MacOS and Windows.

Change-Id: I470892e898971899fda14bb3b8f2c8efefd67686
Cq-Include-Trybots: luci.dart.try:vm-gcc-linux-try,vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-win-debug-x64-try,vm-win-debug-x64c-try,vm-mac-debug-x64-try,vm-mac-debug-arm64-try,vm-aot-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362780
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-04-17 19:14:41 +00:00
Parker Lougheed 7901612ea3 [vm] Remove macOS 10.14 and iOS 12 availability checks
macOS 10.14 has been Flutter's minimum for a while, and iOS 12 is the new minimum as of https://github.com/flutter/flutter/issues/140474.

Dart has not marked these platforms as supported for an even longer time.

Supported platforms reference: https://docs.flutter.dev/reference/supported-platforms

TEST=ci

Bug: https://github.com/flutter/flutter/issues/140474
Change-Id: I12377975d9c4d57e19d486898f0fcd89a1583f7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346920
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-01-25 08:23:51 +00:00
Derek Xu 9c829013ef [VM/Timeline] Print deprecation warning when --systrace-timeline flag is used
TEST=CI

Change-Id: I74882dbc6cb0ee1cb09ae112316ccd17f59ba777
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330503
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-10-16 14:02:31 +00:00
Derek Xu f0310b5b7c [VM/Timeline] Change locking scheme used by TimelineEventRingRecorder to prevent races
TEST=Loaded the timeline in DevTools on a debug build with the recorder
set to ring, endless, and startup. Recorded traces on a debug build with
the recorder set to systrace, file, and perfettofile. Ran the
vm/cc/TimelineRingRecorderRace test on ASAN and TSAN.

Issue: https://github.com/flutter/flutter/issues/129258
Change-Id: I39920ac3e4a70e5714915fcd554ae171ed82504a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312721
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-10 20:33:33 +00:00
Derek Xu 3cb3e9a49e [VM/Timeline] Delete unsafe versions of Clear() and ReclaimCachedBlocksFromThreads()
TEST=Recorded traces using the file recorder on ASAN and TSAN builds.

Change-Id: I2251a8373d952d6e3ef1803e9a79de85522f518a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312720
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-10 20:33:33 +00:00
Derek Xu f98f292708 Reland "[VM/Timeline] Add Dart_RecordTimelineEvent Embedder API to support reporting flow events that can be serialized in Perfetto's format"
Patchset 1 is a reland of commit
f52bdb96aa, and Patchset 2 adds a
corrected reland of commit 0d0e301979.

The leak in g3 was caused by moving the `state_ = 0;` line before the
`owns_label()` check in `TimelineEvent::Reset`.

TEST=Ran the g3 tests that were failing on a cbuild copy with these
changes (sponge2/1134a5bb-5168-4e4c-bb03-72a7d7ad6ab4).

Original change's description:
> [VM/Timeline] Add Dart_RecordTimelineEvent Embedder API to support reporting flow events that can be serialized in Perfetto's format
>
> Added a deprecation notice to Dart_TimelineEvent as well.
>
> TEST=Used the embedder API to report an events of each of the following types:
> Dart_Timeline_Event_Begin, Dart_Timeline_Event_Duration,
> Dart_Timeline_Event_Instant, Dart_Timeline_Event_Async_Begin, and
> Dart_Timeline_Event_Async_Instant, each associated with flow IDs. Then,
> retrieved the trace using GetPerfettoVMTimeline and checked that flow arrows
> were displayed correctly in the Perfetto trace viewer.
>
> Change-Id: I82e49554b5970767e306dc4149a782e99a5c6512
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302963
> Commit-Queue: Derek Xu <derekx@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

Change-Id: I08783d6b5575fb3fe43da3203e58902bf9b7d038
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308721
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-06-12 19:31:38 +00:00
Derek Xu 524cf849b2 Revert "[VM/Timeline] Add Dart_RecordTimelineEvent Embedder API to support reporting flow events that can be serialized in Perfetto's format"
This reverts commit f52bdb96aa.

Reason for revert: https://dart-review.googlesource.com/c/sdk/+/308360
was reverted due to g3 problems, and the code in this CL will leak
without the code in that CL.

Original change's description:
> [VM/Timeline] Add Dart_RecordTimelineEvent Embedder API to support reporting flow events that can be serialized in Perfetto's format
>
> Added a deprecation notice to Dart_TimelineEvent as well.
>
> TEST=Used the embedder API to report an events of each of the following types:
> Dart_Timeline_Event_Begin, Dart_Timeline_Event_Duration,
> Dart_Timeline_Event_Instant, Dart_Timeline_Event_Async_Begin, and
> Dart_Timeline_Event_Async_Instant, each associated with flow IDs. Then,
> retrieved the trace using GetPerfettoVMTimeline and checked that flow arrows
> were displayed correctly in the Perfetto trace viewer.
>
> Change-Id: I82e49554b5970767e306dc4149a782e99a5c6512
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302963
> Commit-Queue: Derek Xu <derekx@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

Change-Id: I98a259c7de8fa4b7dbcbe42f7332ab20b553e9cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308680
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-06-12 15:40:07 +00:00
Ilya Yanok 84a6b3197b Revert "[VM/Timeline] Reset flow_ids_ in TimelineEvent::Reset"
This reverts commit 0d0e301979.

Reason for revert: breaks tests in G3, see b/286799580

Original change's description:
> [VM/Timeline] Reset flow_ids_ in TimelineEvent::Reset
>
> TEST=Ran the vm/cc/DartAPI_TimelineEvents_Serialization test with ASAN.
>
> Fixes: https://github.com/dart-lang/sdk/issues/52652
> Change-Id: I665c7fc6c8fa2a12c24b579386b1373f7e63792c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308360
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Change-Id: I344320d97cb414f29b627859f71fba4967073062
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308660
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-12 10:35:27 +00:00
Derek Xu 0d0e301979 [VM/Timeline] Reset flow_ids_ in TimelineEvent::Reset
TEST=Ran the vm/cc/DartAPI_TimelineEvents_Serialization test with ASAN.

Fixes: https://github.com/dart-lang/sdk/issues/52652
Change-Id: I665c7fc6c8fa2a12c24b579386b1373f7e63792c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308360
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-06-09 16:18:47 +00:00
Derek Xu f52bdb96aa [VM/Timeline] Add Dart_RecordTimelineEvent Embedder API to support reporting flow events that can be serialized in Perfetto's format
Added a deprecation notice to Dart_TimelineEvent as well.

TEST=Used the embedder API to report an events of each of the following types:
Dart_Timeline_Event_Begin, Dart_Timeline_Event_Duration,
Dart_Timeline_Event_Instant, Dart_Timeline_Event_Async_Begin, and
Dart_Timeline_Event_Async_Instant, each associated with flow IDs. Then,
retrieved the trace using GetPerfettoVMTimeline and checked that flow arrows
were displayed correctly in the Perfetto trace viewer.

Change-Id: I82e49554b5970767e306dc4149a782e99a5c6512
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302963
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-06-08 21:32:38 +00:00
Derek Xu 475240d234 Reland "[VM/Timeline] Make timestamp1_or_id variables more understandable"
This is a reland of commit 46e70a7c07

It turns out that flow events do need to be associated with IDs in
Chrome's trace format, so the diff between patchset 1 and 6 contains the
changes required to document that.

TEST=Checked that duration events still looked correct in traces written
by the Perfetto file recorder. Checked that events still looked correct
in traces recorded to the MacOS recorder. Checked that flow events still
looked correct in Observatory. Ran the
vm/cc/DartAPI_TimelineEvents_Serialization test in debug mode, and with
ASAN and TSAN.

CoreLibraryReviewExempt: Does not change any APIs, just stops passing a
value that will never be read. Specifically, we do not need to pass a
flow ID on the end side of track events.
Change-Id: I6b8bb3236339dbe54378b2e9dea06faf22b964a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306664
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-06-01 19:50:38 +00:00
Derek Xu e7fd092044 Revert "Reland "[VM/Timeline] Make timestamp1_or_id variables more understandable""
This reverts commit 46e70a7c07.

Reason for revert: New asserts failing in Flutter Engine tests

Original change's description:
> Reland "[VM/Timeline] Make timestamp1_or_id variables more understandable"
>
> Relanding without changes because the cbuild failure was unrelated.
>
> TEST=Checked that duration events still looked correct in traces written
> by the Perfetto file recorder. Checked that events still looked correct
> in traces recorded to the MacOS recorder.
>
> This is a reland of commit 354e1d22cb
>
> Original change's description:
> > [VM/Timeline] Make timestamp1_or_id variables more understandable
> >
> > This CL improves documentation, and renames fields/methods to make it
> > more understandable that timestamp1 and id are stored in the same field
> > of dart::TimelineEvent (because the event types that need to store
> > timestamp1 are disjoint from the ones that need to store id).
> >
> > TEST=Checked that duration events still looked correct in traces written
> > by the Perfetto file recorder. Checked that events still looked correct
> > in traces recorded to the MacOS recorder.
> >
> > Change-Id: I25ff1f4c6cc432f035ac2be99fa7f162290ea77f
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305880
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Derek Xu <derekx@google.com>
>
> Change-Id: I28c0c3af9869900cc8bb2b3b416904a231d143e0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306301
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Change-Id: Ia1fe524268c06fd68c689fe048d8cc38a6ed8a23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306661
Reviewed-by: Ben Konyi <bkonyi@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-05-31 16:51:49 +00:00
Derek Xu 46e70a7c07 Reland "[VM/Timeline] Make timestamp1_or_id variables more understandable"
Relanding without changes because the cbuild failure was unrelated.

TEST=Checked that duration events still looked correct in traces written
by the Perfetto file recorder. Checked that events still looked correct
in traces recorded to the MacOS recorder.

This is a reland of commit 354e1d22cb

Original change's description:
> [VM/Timeline] Make timestamp1_or_id variables more understandable
>
> This CL improves documentation, and renames fields/methods to make it
> more understandable that timestamp1 and id are stored in the same field
> of dart::TimelineEvent (because the event types that need to store
> timestamp1 are disjoint from the ones that need to store id).
>
> TEST=Checked that duration events still looked correct in traces written
> by the Perfetto file recorder. Checked that events still looked correct
> in traces recorded to the MacOS recorder.
>
> Change-Id: I25ff1f4c6cc432f035ac2be99fa7f162290ea77f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305880
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Change-Id: I28c0c3af9869900cc8bb2b3b416904a231d143e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306301
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-05-30 15:40:33 +00:00
Derek Xu 2e29ed3874 Revert "[VM/Timeline] Make timestamp1_or_id variables more understandable"
This reverts commit 354e1d22cb.

Reason for revert: broke cbuild

Original change's description:
> [VM/Timeline] Make timestamp1_or_id variables more understandable
>
> This CL improves documentation, and renames fields/methods to make it
> more understandable that timestamp1 and id are stored in the same field
> of dart::TimelineEvent (because the event types that need to store
> timestamp1 are disjoint from the ones that need to store id).
>
> TEST=Checked that duration events still looked correct in traces written
> by the Perfetto file recorder. Checked that events still looked correct
> in traces recorded to the MacOS recorder.
>
> Change-Id: I25ff1f4c6cc432f035ac2be99fa7f162290ea77f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305880
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Change-Id: I37c74620105299c0b5e7725fd994609af177a9f8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306280
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-05-29 19:10:27 +00:00
Derek Xu 354e1d22cb [VM/Timeline] Make timestamp1_or_id variables more understandable
This CL improves documentation, and renames fields/methods to make it
more understandable that timestamp1 and id are stored in the same field
of dart::TimelineEvent (because the event types that need to store
timestamp1 are disjoint from the ones that need to store id).

TEST=Checked that duration events still looked correct in traces written
by the Perfetto file recorder. Checked that events still looked correct
in traces recorded to the MacOS recorder.

Change-Id: I25ff1f4c6cc432f035ac2be99fa7f162290ea77f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305880
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-05-29 18:46:54 +00:00
Derek Xu 193c4ccbb9 [VM/Timeline] Store an array of flow IDs in each dart::TimelineEvent
instead of just one ID

Sometimes the Flutter Engine is associating events with multiple flows,
this change is needed to allow events to be associated with multiple
flows in a Perfetto-format trace.

TEST=Checked the flow events reported through dart:developer still
looked correct when retrieved in Perfetto traces.

Change-Id: I2901ffde5e8b984abb1e924e014722bb0568f6d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305801
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-05-26 13:08:27 +00:00
Vyacheslav Egorov f86f41226d [vm/timeline] Include callback data into Dart_TimelineRecorderEvent.
This simplifies embedders which otherwise need to maintain
special mappings to find their isolate specific data structures.

TEST=vm/cc/DartAPI_SetTimelineRecorderCallback

Change-Id: If819437cad2e1bf3fe5ba50fe67d01e8bd992064
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304962
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-05-25 10:19:48 +00:00
Derek Xu 0e3069ea23 [VM/Timeline] Support serializing duration events in Perfetto's format
TEST=Reported duration events using the embedder API, then retrieved the
trace using GetPerfettoVMTimeline and checked that the timestamps of
events were correct in the Perfetto trace viewer.

Change-Id: I077d7f545d9546727bcc3022c05dfc0b7b3826f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302962
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-05-15 20:51:38 +00:00
Derek Xu fe43431184 [VM/Timeline] Add perfetto_utils::SetTimestampAndMonotonicClockId
TEST=Retrieved a trace using GetPerfettoVMTimeline and checked that the
timestamps of events were correct in the Perfetto trace viewer.

Change-Id: Ie06e9e883a5d740022fa162bf7162dca6babcf58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302961
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-05-15 20:51:38 +00:00
Derek Xu 61e280aa11 [VM/Timeline] Change return type of GetIsolate(Group)Id to unique_ptr
TEST=Retrieved a trace using GetPerfettoVMTimeline and checked that the
isolateIds and isolateGroupIds of events still showed up correctly in
the Perfetto trace viewer.

Change-Id: I13cf8dd2bb9af7fbe82da199b7f0d3c32a8cf1e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302960
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-05-15 20:51:38 +00:00
Derek Xu e26fe2817c [VM/Timeline] Start skipping over dart::TimelineEvents that provide no useful information when writing Perfetto traces
TEST=Checked that traces written using the Perfetto file recorder, and
traces retrieved through `getPerfettoVMTimeline` still looked correct.

Change-Id: I7e327ef525c99187fa8aea868d1cc48721af9f98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302420
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-05-10 19:06:10 +00:00