Commit Graph

22 Commits

Author SHA1 Message Date
Ryan Macnak e58c3ce1ba [vm] Fix some data races with profiler samples.
- Sample collection must acquire or there is a write-write data race with sample processing/clearing.
- Sample processing must release or there is a write-write data race with another sample processing.

Bug: https://github.com/dart-lang/sdk/issues/41242
Change-Id: I57c1f813fc8b38d31e12dd8d7d3b19d96a9c8912
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141466
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-03-28 00:41:51 +00:00
Ryan Macnak 991da7169a [vm, service] Fix data races between sample collection and sample processing.
Bug: https://github.com/dart-lang/sdk/issues/39611
Bug: https://github.com/dart-lang/sdk/issues/30309
Change-Id: I79daec2183be40aa07d652b149d182316df8458c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139025
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-03-11 22:03:50 +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
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
John McCutchan 95a8166523 Disable the profiler when a debugger is attached
Fixes #28702

BUG=
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2682343002 .
2017-02-09 10:11:52 -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
Siva Annamalai 9e19d236ca - Add an OSThread structure which is the generic TLS structure for all C++
fields in a thread (i.e fields that are not Dart VM related)
- Split the Thread structure to be a pure Dart per thread structure and add
  a pointer to os_thread which points to the OSThread structure
- Change Schedule/UnSchedule to set the Dart Thread structure as the TLS of
  the thread when it is inside the Dart world and reset the TLS back to the
  OSThread strcuture when is exits the Dart World.
- Moved the stack_base and few stack size related functions to OSThread from Isolate

R=johnmccutchan@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1439483003 .
2015-11-19 13:45:10 -08:00
Siva Annamalai 9dee5b7a15 Minor cleanup
- remove ThreadInterruptCallback typedef as it is not used anymore
 - move InterruptedThreadState to thread_interrupter.h

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1428373003 .
2015-11-06 14:15:16 -08:00
John McCutchan ceb12c4f69 Switch profiler from isolates to threads
- API breakage: Dart_IsolateBlocked, Dart_IsolateUnblocked -> Dart_ThreadDisableProfiling, Dart_ThreadEnableProfiling.
- Remove IsolateProfilerData.
- Move thread at blocking call count from isolate to thread.
- Always interrupt threads unless they are blocked.
- We can no longer count "idle" ticks.
- Only record sample if thread is the current mutator of an isolate.
- Refactor ThreadInterrupterCallback to ensure that Thread* is valid.

Threads are only ever sent signals if ThreadInterruptsEnabled is true. Which is controlled by two functions:

void DisableThreadInterrupts();
void EnableThreadInterrupts();

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

Review URL: https://codereview.chromium.org/1423473004 .
2015-11-04 07:59:16 -08:00
William Hesse cc4a5d2e7c Revert "Switch profiler from isolates to threads"
Reverts commit 6365c27f81 and
commit 8b9ed6cfb3.

They are causing flaky timeouts (hangs) on all vm cc tests on all Windows vm bots.

R=mit@google.com

Review URL: https://codereview.chromium.org/1425093006 .
2015-11-03 10:42:55 +01:00
John McCutchan 6365c27f81 Switch profiler from isolates to threads
- API breakage: Dart_IsolateBlocked, Dart_IsolateUnblocked -> Dart_ThreadDisableProfiling, Dart_ThreadEnableProfiling.
- Remove IsolateProfilerData.
- Move thread at blocking call count from isolate to thread.
- Always interrupt threads unless they are blocked.
- We can no longer count "idle" ticks.
- Only record sample if thread is the current mutator of an isolate.
- Refactor ThreadInterrupterCallback to ensure that Thread* is valid.

Threads are only ever sent signals if ThreadInterruptsEnabled is true. Which is controlled by two functions:

void DisableThreadInterrupts();
void EnableThreadInterrupts();

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

Review URL: https://codereview.chromium.org/1412733008 .
2015-11-02 12:47:52 -08:00
Zachary Anderson 7093f2996b VM thread shutdown.
BUG=
R=iposva@google.com, turnidge@google.com

Review URL: https://codereview.chromium.org//1275353005 .
2015-09-15 12:49:52 -07:00
John McCutchan 664742f016 Completely remove InterruptableThreadState
- InterruptableThreadState is gone.
- Moved InterruptableThreadState fields directly into Thread.
- Iterate over all threads in an isolate when profiling.
- Still only sample the mutator thread.

Fix ThreadRegistry leak

- When deleting a Thread, iterate over all isolates and remove it from the isolate's thread registry.

R=iposva@google.com

Review URL: https://codereview.chromium.org//1293253005 .
2015-08-20 14:38:38 -07:00
Daniel Andersson df448e21da Begin migration of InterruptableThreadState into Thread.
Move the field from Isolate to Thread::state_ to allow using a single thread local key.

Profiling is still only enabled for the Dart mutator thread.

The next step is to migrate the VM tags.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1261923008 .
2015-08-07 10:28:56 -07:00
johnmccutchan@google.com afe774a4c4 Remove profiler signal handler on shutdown
BUG=https://github.com/domokit/mojo/issues/79
R=asiva@google.com

Review URL: https://codereview.chromium.org//1061033005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44943 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-07 18:33:01 +00:00
johnmccutchan@google.com f2333f63a5 Add Function based profile tree
Profiler improvements:
- Track Functions in profile and build Function based trie
- Associate code objects with functions
- Created cpu_profile.dart library
- Major speed improvements for disassembly view
- Fix truncation of disassembly comments
- Ability to get code object ticks from disassembly view
- Inlining mini-map in disassembly view.
- Remove a bunch of unused data from profile service response
- In some cases a caller PC that is better than the PC marker is inserted into the stack trace
- Inlined functions are expanded
- Ability to clear profile
- New flag '--keep_code' which keeps deoptimized code around for use by the profiler.

General fixes:
- Fix caching in service library
- Remove pubspec.yaml before running pub get

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

Review URL: https://codereview.chromium.org//928833003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44067 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-26 18:48:55 +00:00
koda@google.com c7e9e048ed Rename Thread -> OSThread.
It's a collection of static utility methods for primitive operations on OS threads.

Make room in the namespace for upcoming class that will represent all the complex state of a VM thread.

Review URL: https://codereview.chromium.org//796063006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42895 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-15 02:30:07 +00:00
zra@google.com 816bf5af2e Fixes for the profiler on arm64.
On arm64, in Dart code, R18(SP) is the stack pointer.
In C++ code, R31(CSP) is the stack pointer.
The profiler must choose the right one when performing
its bounds checks.

This change also fixes a bug in the InvokeDartCode stub
on arm64 so that CSP is set to the Isolate's stack
limit immediately, rather than a bit later. When it was
set a bit later, if a profiler interrupt came in in the
interim, the stack would be smashed.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//583683002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40502 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-19 16:25:16 +00:00
johnmccutchan@google.com b3f2fb14d0 Reduce CPU usage when no isolates need to be profiled (e.g. when an isolate calls readLineSync or sleep the isolate owns the thread but is blocked).
This CL does the following:

- Introduces two new API entry points: Dart_IsolateBlocked and Dart_IsolateUnblocked.
- The thread interrupter thread goes into a deep sleep if no isolates need to be profiled (not scheduled on a thread or are in a blocking call).
- When an isolate unblocks, the thread interrupter thread resumes regular interrupts.
- dart:io readLineSync and sleep mark that they are making a blocking call.

This fixes https://code.google.com/p/dart/issues/detail?id=18126 reducing CPU usage to 0% when waiting for stdin or sleeping.

R=ajohnsen@google.com, iposva@google.com

Review URL: https://codereview.chromium.org//297183003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36632 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-26 11:53:49 +00:00
johnmccutchan@google.com 182fcd0921 Add isolate tag-profile model and UI.
Distinction between a Dart Error and a ServiceError/ServiceException.
Better Observatory behaviour when a ServiceError/ServiceExceptions occurs.
Display isolate's sticky error.

R=turnidge@google.com

Review URL: https://codereview.chromium.org//205713004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34377 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-25 18:09:02 +00:00
johnmccutchan@google.com 86c55f4fde Keep list of existing isolates.
List is only updated when isolates are created / destroyed.
ThreadInterrupter now walks list of isolates.
Scheduling an isolate for interrupts is now lockless.
Setting a current isolate is now lockless.
Working on Linux, Mac, and Windows.
Assert that the isolate isn't on two threads at once.

R=asiva@google.com

Review URL: https://codereview.chromium.org//128653004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32439 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-07 17:43:21 +00:00
johnmccutchan@google.com 919dc2d6eb * Introduce ThreadInterrupter which calls a TLS set callback when thread is interrupted.
* Threads can only register and unregister themselves with ThreadInterrupter.
* Profiler is no longer involved in interrupting threads. It's just a callback and the buffer.
* Profiler operates lock free using an atomic operation to reserve sample in sample buffer.
* Linux, Mac, and Windows done.

R=asiva@google.com

Review URL: https://codereview.chromium.org//109803002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31170 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-16 18:52:15 +00:00