Commit Graph

97 Commits

Author SHA1 Message Date
Ben Konyi 3e83400e0f [ VM / Service ] Added getAllocationTraces and setTraceClassAllocation RPCs and identity hash support
This change adds two new RPCs and various new properties:
  - getAllocationTraces
  - setTraceClassAllocation
  - classId and identityHashCode properties in CpuSample
  - traceAllocations property in Class

TEST=get_allocation_traces_test.dart

package:vm_service has been regenerated for 3.43 of the service protocol
and is ready for a 6.1.0 release.
Change-Id: Ia8ed055423798d7d17fe9f5fd74efb4239b875fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182666
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-12 21:15:35 +00:00
Ryan Macnak b1c09ecd8f [vm] Make naming more consistent when converting between handles, tagged and untagged pointers.
Currently we have things called XPtr which are not what you get from ptr().

Old world:
handle->raw() returns RawObject* (tagged)
raw_obj->ptr() returns RawObject* (untagged)

After 6fe15f6df9:
handle->raw() returns ObjectPtr
obj_ptr->ptr() returns ObjectLayout*

New world:
handle->ptr() returns ObjectPtr
obj_ptr->untag() returns UntaggedObject*

TEST=ci
Change-Id: I6c7f34014cf20737607caaf84979838300d12df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149367
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-01-15 23:32:02 +00:00
Alexander Markov 7588ed86de Remove bytecode mode from the VM
Change-Id: Ief167b7ffc128105a03cc225ab750234c9a6a7a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169147
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-28 17:42:35 +00:00
Zach Anderson cbb5cee914 Widen profile sample task kind bitfield
To match: https://github.com/dart-lang/sdk/blob/master/runtime/vm/thread.h#L247

Change-Id: If065823ff3d124ae6ad8113ccb262c4b63107265
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152587
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-06-25 22:21:22 +00:00
Vyacheslav Egorov 45310394a6 [vm] Exclude class name from function name in instruction sizes json.
Issue https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: Idf2bb9c9d6392c7a95aa09a2cc1f2190adcf782d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150522
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-10 10:18:37 +00:00
Vyacheslav Egorov d959f4290e [vm/compiler] Disambiguate Code names when emitting instruction sizes info.
Previously the output used scrubbed qualified names which hides some
of the information and causes names of various synthetic functions
collide. We change it to use internal qualified names instead and add
additional information for disambiguation:

- For functions this means adding a prefix for various synthetic
methods;
- For anonymous closures we add their token position;
- For types we prefix type parameters with their owner's name.

We also add a unit test covering parsing of
--print-instructions-sizes-to output.

As part of adding a test dart2native was changed to support passing
extra arguments to gen_snapshot binary.

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

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: I299ab0fb5993c8af9b51246483608d1e65970d67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146581
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2020-05-07 12:39:27 +00:00
Ryan Macnak 6fe15f6df9 [vm] Represent tagged pointers as C++ value types instead of C++ pointer types.
This works around bugs in UndefinedBehaviorSanitizer and Clang.

Bug: b/28638298
Change-Id: I6be595f9664516019d28017d24559583a1ae3a21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144354
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-04-25 05:21:27 +00:00
Ryan Macnak 98da22a11f [observatory] Display process-wide memory usage with heap snapshots.
Include major memory users known to the VM: isolate heaps, profiling buffers, timeline buffers.

Change-Id: I2580ad74b5d4d07c5c75fde28bb7a5d71fddb09b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127382
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2019-12-07 00:28:15 +00:00
Ben Konyi 60c34ac420 [ VM / Service ] Allow for the profiler to be enabled/disabled via SetFlags RPC
Disabling the profiler will **not** release the sample buffer on Linux,
MacOS, and other platforms which utilize signals for profiling as
there's no way to ensure all signals have been receieved after the
thread interrupter has been shutdown.

Change-Id: Ifb3230fdb95e9bc9147cbd4b85d1a84e976ce119
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123554
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-10-31 21:18:38 +00:00
Ryan Macnak f4f0831c69 [vm] Fix TSAN failures related to object headers and GC task phases.
Change-Id: I15078e845712e8e712e2cb0a044fc7550127ea36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120629
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-10-09 21:48:20 +00:00
Ben Konyi fae7d07fbc [ VM / Profiler ] Add --sample-buffer-duration flag to specify sample buffer size
This flag consumes a time in seconds and calculates the correct capacity
for the sample buffer so it can contain at least that many seconds worth
of samples based on the maximum number of samples that can be chained to
represent a stack and the sampling rate.

Providing a value to this flag will likely greatly increase memory
consumption, so a warning message is printed which contains the
information used to calculate the buffer capacity as well as the size of
the resulting buffer in bytes. Example output:

** WARNING ** Custom sample buffer size provided via --sample-buffer-duration
The sample buffer can hold at least 120s worth of samples with stacks depths of up to 128, collected at a sample rate of 20000Hz.
The resulting sample buffer size is 3532800000 bytes.

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

Change-Id: I58aff6da268b9a6b02258021d2be8bf4f80ae999
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117208
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2019-09-20 02:30:04 +00:00
Ben Konyi 68dede011e [ VM / Service ] Add getCpuProfileSamples RPC which returns a minimally processed sample buffer.
Change-Id: Ic0a47d5eea692b235327622508d904f7396babe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112265
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-09-07 01:04:08 +00:00
Matthew Dempsky 6d5f763952 [vm] Eliminate Mutex/Monitor indirection where possible
In many cases, the Mutexes and Monitors have to be marked "mutable"
because they're used to synchronize const accessor methods.

Small text segment improvement for Product builds:

$ size dart.{arm,x64}.{before,after}
   text	   data	    bss	    dec	    hex	filename
19726069	 409960	 392332	20528361	1393ce9	dart.arm.before
19725525	 409960	 392332	20527817	1393ac9	dart.arm.after
22576021	 600376	1782824	24959221	17cd8f5	dart.x64.before
22574821	 600376	1782824	24958021	17cd445	dart.x64.after

Change-Id: I68f5cd5ad452044df8bfebd160910496036a3e6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101745
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-05-13 21:17:51 +00:00
Ryan Macnak 0feba40c4b [vm] Further fixes to the interpreter for ProfilerDartStackWalker.
Adjust type of Interpreter::pc_ to reduce casting.

Change-Id: I3b2098068fb4f6b5bd5cb552a857a985a06dafb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98922
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-04-09 20:57:47 +00:00
Ryan Macnak b7a5e478bb [vm, service] Allow choice of tags and code-verus-function when getting profile samples as timeline events.
Change-Id: Ie0cf3d43d5ccc748216ba2b45a9466ce60dcf239
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97176
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-03-26 22:52:40 +00:00
Zach Anderson 8332fb0631 [vm] Adds an API call to dump the CPU profile to the timeline
Used in https://fuchsia-review.googlesource.com/c/topaz/+/258655

Change-Id: I79b102e0d318d7be3bae44fb88f81bb8086a10d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/94400
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2019-03-07 21:28:26 +00:00
Ben Konyi a10ddca1b1 [ VM / Service ] Allow for profile_period flag to be set via the service protocol
`profile_period` has been added to the list of flags which can be
changed at runtime via the `setFlag` RPC. Changing this flag at runtime will
cause the ThreadInterrupter to be shutdown, reinitialized, and started with the
new profiling period.

Fixes #35654.

Change-Id: I2f365fdf8e404270f2eed1e172c8d21b48e0aff9
Reviewed-on: https://dart-review.googlesource.com/c/89445
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Jacob Richman <jacobr@google.com>
2019-01-16 18:08:19 +00:00
Ryan Macnak 488d1f375c [vm] Make profiler bailout counters available over the VM service.
Change-Id: I4c0d30b21371e33f66ab142636aa669a46f8a799
Reviewed-on: https://dart-review.googlesource.com/c/85547
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-11-29 21:53:24 +00:00
Ryan Macnak 2535b1e021 [vm] Account for bytecode in profile processing and Observatory.
Change-Id: I220eca1f4a3aadaa271ead4de698c28e4a7b653a
Reviewed-on: https://dart-review.googlesource.com/c/84447
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-15 17:42:13 +00:00
Ben Konyi 07852532e3 [ VM ] Additional cleanup in Dart_Initialize and Dart_Cleanup
Change-Id: I6dc02b3d9de16cc176eb97613bc0c7f0bb9b16eb
Reviewed-on: https://dart-review.googlesource.com/77013
Commit-Queue: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
2018-09-28 23:18:59 +00:00
Ryan Macnak 65d7bf8152 [vm] Align 64-bit atomic variables for 32-bit iOS.
Change-Id: I2bbe637fce59bd5d84f7db8a44960e36fe63d2d9
Reviewed-on: https://dart-review.googlesource.com/53822
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-05-07 18:37:12 +00:00
Ryan Macnak 2e12b5f06b [vm] Adjust the relative sizes of the profile and timeline buffers.
In Flutter, the timeline buffer overflows much more quickly than the profile buffer, but usually timeline events are more helpful than profile ticks for understanding performance. This commit trades profile buffer space for timeline event space.

32-bit:
  profile buffer: 12MB -> 6MB
  timeline buffer: 0.5MB -> 2MB

Also increase the default sample depth to better handle Flutter's deep tree walks.

Change-Id: If092047fa89b2b3e57e57370bc435a591497b566
Reviewed-on: https://dart-review.googlesource.com/5903
Reviewed-by: Todd Turnidge <turnidge@google.com>
2017-09-26 22:01:42 +00:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Ben Konyi cc68a66f28 Updated native memory allocation profiling to use its own sample buffer instead of sharing a sample buffer with the CPU profiler, which did lead to samples being quickly overwritten even if the memory hadn't yet been freed. This will ensure allocations are accurately displayed in Observatory as the CPU profiler will no longer overwrite samples associated with native memory allocations.
BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2966593002 .
2017-07-10 10:31:45 -07:00
Ryan Macnak 881bf01534 Allocate the profiler sample buffer and zone segments with virtual memory instead of malloc.
Allows naming their memory regions.

Add check for failed sample buffer allocation.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2955493002 .
2017-06-23 14:06:44 -07:00
Ryan Macnak 91da7428f3 Add --print_stacktrace_at_api_error.
Should be helpful in tracking down flutter/flutter#8612.

Prefer stack bounds from pthreads when available to be able to see frames below the Dart entry frame.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2813283002 .
2017-04-12 14:09:19 -07:00
Ben Konyi 7c820f4363 Resubmission of native memory allocation info surfacing in Observatory. Fixed crashing tests and stack trace collection skip counts for different configurations.
Fixed missing method referenced when MallocHooks is unsupported.

BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2771293003 .
2017-03-27 13:25:26 -07:00
Ben Konyi 9ea672efc0 Revert "Added page to Observatory to display native memory allocation information."
This reverts commit f30f312b48.

Revert "Fixed missing method referenced when MallocHooks is unsupported."

This reverts commit a0b9c5a178.

TBR=johnmccutchan@google.com

BUG=

Review-Url: https://codereview.chromium.org/2773073003 .
2017-03-24 09:47:29 -07:00
Ben Konyi f30f312b48 Added page to Observatory to display native memory allocation information.
BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2748403002 .
2017-03-24 09:20:25 -07:00
Ben Konyi 68a102cab2 Fixed tests not having MallocHooks initialized for tests in release mode.
Revert "Revert "Fixed issue in MallocHooks where a MallocHookScope was accidentally removed during a merge, causing a deadlock in the hooks. Also turned off stack trace collection in a test that was timing out as a result of the stack trace collection.""

This reverts commit 1a5b555aa9.

BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2711353003 .
2017-02-24 13:56:06 -08:00
Ben Konyi 1a5b555aa9 Revert "Fixed issue in MallocHooks where a MallocHookScope was accidentally removed during a merge, causing a deadlock in the hooks. Also turned off stack trace collection in a test that was timing out as a result of the stack trace collection."
This reverts commit 44a9a4ede3.

BUG=

Review-Url: https://codereview.chromium.org/2714083002 .
2017-02-23 19:21:00 -08:00
Ben Konyi 44a9a4ede3 Fixed issue in MallocHooks where a MallocHookScope was accidentally removed during a merge, causing a deadlock in the hooks. Also turned off stack trace collection in a test that was timing out as a result of the stack trace collection.
Updated MallocHooks to collect stack traces when memory is allocated.

BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2718523003 .
2017-02-23 18:58:50 -08:00
Ben Konyi d4f026c2e0 Revert "Updated MallocHooks to collect stack traces when memory is allocated."
This reverts commit a486a8a26b51dce728373183ab02aeda70e6f2d0.

R=johnmccutchan@google.com
TBR=johnmccutchan@google.com
BUG=

Review-Url: https://codereview.chromium.org/2713803003 .
2017-02-23 13:13:44 -08:00
Ben Konyi 47f0da9cd7 Updated MallocHooks to collect stack traces when memory is allocated.
BUG=
R=johnmccutchan@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2680213002 .
2017-02-23 12:42:18 -08:00
Siva Annamalai 501720c644 Retry landing cl for issue with TSAN.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2525103003 .
2016-11-23 15:40:26 -08:00
Florian Schneider 6cd141def5 Dump stack trace on segfault in the VM.
Install a signal handler in the standalone VM that dumps a backtrace
similar to what we already do on assertion failures.

For now only Linux and MacOS are supported.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/2514113002 .
2016-11-23 10:29:07 -08:00
Siva Annamalai 66cb033ac1 Revert "Fix tsan failure"
This reverts commit 159a5ab366.

This reverts commit aa76de9a8f.

BUG=

Review URL: https://codereview.chromium.org/2510093005 .
2016-11-18 16:44:32 -08:00
Siva Annamalai 159a5ab366 Fix tsan failure
We have a racy read of the object header in the stack frame walker
called from the profiler (in this case the gc marker is running at
the same time).

It is appropriate to avoid this even though we think the access is
safe as the objects are in old space and never forwarded and only
the mark bits are manipulated while marking
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2517473002 .
2016-11-18 14:09:02 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
Florian Schneider 4bd534191a VM: Avoid allocating strings when disassembling code.
For code objects, don't allocate symbol strings when printing the disassembly.

Don't try to make disassembling work with background compilation -- instead make sure that we don't allocate on the Dart heap while disassembling.

Add NoSafepointScope around disassemble functions to assert that no allocation happens.

Also, remove some dead code from object.cc.

BUG=#27430
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2363413004 .
2016-09-27 12:43:05 -07:00
Ryan Macnak 7ff2dd4117 Optimize AOT's switchable calls for the monomorphic case.
The call sequence is very similar to a classic IC call, except the guarded class and the target are loaded indirectly from the constant pool instead of as immediates. In the monomorphic case, we call directly to the expected target with a class check in the callee. In the unlinked, polymorphic and megamorphic cases, we call a stub; these case are now call-through instead of call-and-return.

Every code, except stubs involved in switchable calls, includes the class check sequence at the beginning. So we now distinguish between a checked and an unchecked entry point. Generated code except the switchable call continues to use the unchecked entry point.

PC offsets are calculated relative to the beginning of the instruction stream, rather than either entry point.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2226893002 .
2016-08-12 11:18:35 -07:00
John McCutchan a6e2a7f0cd Add debug only counters to profiler
- [x] Count the reasons why we don't walk the stack.
- [x] Count the reasons why we only sample a single frame.
- [x] Count the stack walkers used.

These counters are returned as part of the profile over the vm-service and can be used to debug profiler failures in the future.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2183993007 .
2016-07-28 09:56:15 -07:00
Ryan Macnak 103e316f6a Reapply "Background finalization."
- Fix double-finalization by marking handles that are in a finalization queue.
 - Remember external size in words instead of bytes.
 - Add SlowFinalizer test.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2084193003 .
2016-06-22 16:26:49 -07:00
Ryan Macnak ae94be3f4d Revert "Background finalization."
This reverts commit d265a3db53.

Review URL: https://codereview.chromium.org/2088923002 .
2016-06-21 13:15:12 -07:00
Ryan Macnak d265a3db53 Reapply "Background finalization."
This reverts commit 7d9e75e0b6.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2080353002 .
2016-06-21 09:27:23 -07:00
Ryan Macnak 7d9e75e0b6 Revert "Background finalization."
This reverts commit 082829a00b.

Review URL: https://codereview.chromium.org/2041373004 .
2016-06-07 17:21:06 -07:00
Ryan Macnak 082829a00b Background finalization.
Flutter gallery app on Nexus 4:
 max weak handle processing (main thread): 17.7ms -> 1.1ms
 max scavenge (main thread): 21.0ms -> 17.1ms

BUG=flutter/flutter#3804
R=asiva@google.com

Review URL: https://codereview.chromium.org/2012973002 .
2016-06-07 14:38:37 -07:00
John McCutchan 7abafbea20 Add Profiler::DumpStackTrace
BUG=
R=regis@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1919743003 .
2016-04-25 13:58:15 -07:00
John McCutchan 35773929e4 Collect a single frame sample in the profiler if we can't validate stack boundaries
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1837023003 .
2016-03-29 10:46:41 -07:00