Commit Graph

71 Commits

Author SHA1 Message Date
Ryan Macnak bfb9fae597 [vm] Don't keep events in memory when using systrace/traceutil.
Change-Id: Ic784e1f6c95d1c544958ec5510c168d3d58f50fb
Reviewed-on: https://dart-review.googlesource.com/48820
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-04-02 18:34:35 +00:00
Ryan Macnak 8590919ca6 [vm] Add a timeline stream for recording the zone high watermark.
Change-Id: Ic7f899dbb29eb732b54d7164968a176d7b1025b9
Reviewed-on: https://dart-review.googlesource.com/45544
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-03-16 17:43:27 +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
Ryan Macnak 3d21a46b72 Limit preserialized JSON for timeline events from Dart code to the arguments.
Avoids string copies in C++ and map copies in Dart.

Also remove some vestiages of removed feature that allowed an embedder to add pre-encoded events to the timeline.

Change-Id: I962a67093ba461c991d9169b0391c44af1d489db
Bug: https://github.com/dart-lang/sdk/issues/30787
Reviewed-on: https://dart-review.googlesource.com/6762
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-09-19 23:29:55 +00:00
Carlo Bernaschina 62045a4590 Add Logical Frame View to Timeline Dashboard
This version of the Timeline allows the developer to see a logical
view over the operations involved in each frame.
Events are grouped by frame and shifted accordingly to avoid to have
overlapped frame.

See runtime/observatory/web/timeline.js for the undestrand the steps
involded in the process.

Change-Id: I3980a3278a32fe69ed70db07cfa7189dc0c9a643
Reviewed-on: https://dart-review.googlesource.com/5603
Commit-Queue: Carlo Bernaschina <cbernaschina@google.com>
Reviewed-by: Todd Turnidge <turnidge@google.com>
2017-09-14 23:53:57 +00:00
Carlo Bernaschina 0e32851cfd Add Timeline Dashboard hidden page in Observatory
- Refactoring of the TimelinePage in order to remove the
  dependencies from the Service objects.
- Implemented TimelineRepository to abstract the communication layer
- Structured new TimelineDashboardPage with simplified UI and event
  filtering

The VM returns lists of events which are forwarded to Catapult.
Some events are white-listed for the common user.
Due to limitations in the way the events are generated the only way to
attach the white-list flag to the events is by adding an extra argument.
By setting the hash of timeline.html to #basic we inform JavaScript that
we require the activation of the filter which forwards just the events
white-listed to Captapult, while preserving all the others during
dumping operations.

See https://docs.google.com/document/d/1sDKI3ROYM1ORaKhelt063ayfveF_6WC8aq9MiqHjYBs/edit#

Change-Id: I38435d8d32f37305ce3c366daf55f82e8287959d
Reviewed-on: https://dart-review.googlesource.com/3346
Commit-Queue: Carlo Bernaschina <cbernaschina@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-09-07 20:38:19 +00:00
Zachary Anderson 633ed4cf83 [corelib] dart:developer timeline flow events
This change adds an API to dart:developer Timeline for
adding flow events to the timeline. For details see the
changes in:

sdk/lib/developer/timeline.dart

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2985253002 .
2017-07-31 07:46:52 -07:00
Ryan Macnak 00290c3813 Allocate the fixed-size timeline buffer with virtual memory instead of malloc.
Allows naming the memory region; removes some pressure from jemalloc.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2984313002 .
2017-07-27 13:37:41 -07:00
Zachary Anderson 350ad3a4dc Special-case Timeline.{start,finish}Sync for Fuchsia
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2984603002 .
2017-07-21 08:06:36 -07: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
Ryan Macnak 5a02f3819b [vm] Support flow events in Dart_TimelineEvent.
Issue https://github.com/dart-lang/sdk/issues/30142

R=zra@google.com

Review-Url: https://codereview.chromium.org/2977663003 .
2017-07-12 10:18:10 -07:00
Zachary Anderson b3200f4664 [Fuchsia] Routes timeline events to Fuchsia's tracing app
This CL routes timeline events to Fuchsia's tracing app when the
following arguments are passed to the VM:

--systrace_timeline
--timeline_recorder=systrace
--timeline_streams=[some streams here]

I'll add these arguments to the Flutter engine for Fuchsia after this
CL lands.

TO-367

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2977513002 .
2017-07-11 14:12:27 -07:00
Martin Kustermann dd91dd2319 VM: Free [TimelineEventBlock]s before shutting down
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2621163008 .
2017-01-12 14:02:00 +01:00
Martin Kustermann 2b5352890f VM: Make indirect subclasses of StackResource have virtual destructor
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2623113004 .
2017-01-12 12:53:42 +01: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
John McCutchan ed3f4f2dfe Record Timeline to Android Systrace
- [x] Add TimelineEventSystraceRecorder (enabled via --systrace_timeline or --timeline_recoder=systrace)
- [x] Support Begin, End, and Counter events
- [x] Unit test Systrace serialization

BUG=
R=chinmaygarde@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2315353004 .
2016-09-08 11:28:34 -07:00
John McCutchan 84e1fe5cb5 Add an intrinsified early out path for Dart timeline calls
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1985813002 .
2016-05-17 09:45:28 -07:00
John McCutchan d1d3ba587b Cleanup timeline stream enabled flag so that it can be easily tested from an intrinsic
- Drop no-longer used globally enabled stream flags. This leaves just one source of truth.
- Kill 'Enabled()' for 'enabled()'.
- Store pointer to Timeline::DartStream in Thread.
- Store enabled as an uintptr_t instead of a bool to make it easier for generated code to access.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1975203003 .
2016-05-16 10:30:48 -07:00
John McCutchan db07faaa8c Improve Observatory Timeline UI
- [x] Remove Stop / Start buttons and replace with fine grained category control.
- [x] Restrict the cpu profile to the time span of the timeline.
- [x] Display recorder name.
- [x] Show a popup when fetching the timeline from the VM.
- [x] Show a popup when fetching the cpu profile(s) from the VM.

Fixes #26401
Fixes #26394

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1972523003 .
2016-05-12 07:16:19 -07:00
John McCutchan 234cb9cc03 Report 'timeOriginMicros' and 'timeExtentMicros' in Timeline and Profile service responses
These values will be used in the UI soon.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1964163002 .
2016-05-11 14:23:22 -07:00
John McCutchan f6b570aa2a Include thread CPU time in Timeline.
- [x] Refactor old OSThread interface for querying thread CPU time into OS::GetCurrentThreadCPUMicros.
- [x] Add data to TimelineEvent to track thread CPU time.
- [x] Include "tts" and "tdur" properties when converting the timeline to JSON

Fixes #26396

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1960483002 .
2016-05-05 16:34:09 -07:00
Ryan Macnak 0555b799cd Timeline: Copy event labels of embedder events.
Fixes use-after-free of the label for the 'SkyActivity.onSkyReady' event.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1882313002 .
2016-04-15 09:48:07 -07:00
John McCutchan d8df41c483 Add support for async, metadata, and counter timeline events to be reported by the embedder
Fixes #26142

R=chinmaygarde@google.com

Review URL: https://codereview.chromium.org/1849643002 .
2016-03-30 16:45:46 -07:00
Ryan Macnak 1539647e4d Add a timeline recorder that drops new events after its buffer is full.
(With --complete-timeline, my iPod runs of memory processing the
timeline. With the ring recorder, the startup events have already been
bumped out by time I can connect to Observatory.)

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1834383002 .
2016-03-29 11:01:45 -07:00
Siva Annamalai bb62e8c702 Fix to ensure the product mode builds again.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1813053005 .
2016-03-18 14:27:35 -07:00
Ryan Macnak 366f1f1ed1 Collect samples for background threads.
- Don't tick vm tags for background threads so the Observatory's summary pie chart reflects how the mutator spent its time.
 - Similarly, don't factor background samples in the CPU profile view.
 - Do include background samples in the timeline view.

Use a different event name for background compilations.

Add timeline events for the mark and sweep tasks.

Reload the isolate list when refreshing the timeline view so it includes profile ticks when the page is loading directly (e.g., F5) instead of only after visiting the vm page.

Fix loading the timeline when profiling is disabled.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1814813003 .
2016-03-18 10:18:38 -07:00
John McCutchan c65114b6b4 Timeline API fixes for Flutter
API changes:

- Remove isolate specific Timeline APIs.
- Remove Dart_EmbedderTimelineGetTimeline callback.
- Add Dart_TimelineEvent so that arbitrary trace events can be added.

Internal changes:

- Remove isolate specific streams which were never used or controllable from outside the VM.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1811613002 .
2016-03-16 12:18:46 -07:00
John McCutchan 9bc7398eb8 Ensure embedder timeline callbacks are called for service protocol requests
BUG=
R=chinmaygarde@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/1799933002 .
2016-03-15 07:59:04 -07:00
John McCutchan 53cae0aed9 Add ability for embedder to provide private timeline trace data
- Add three new embedder hooks registered with Dart_SetEmbedderTimelineCallbacks
  - Dart_EmbedderTimelineStartRecording
  - Dart_EmbedderTimelineStopRecording
  - Dart_EmbedderTimelineGetTimeline

- Add unit test for record start / stop notification.
- Add unit test for get timeline.

This should allow Flutter to remove their hacked up timeline service RPCs.

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

Review URL: https://codereview.chromium.org/1783953002 .
2016-03-10 13:32:48 -08:00
John McCutchan 32abe2ce55 Stream blocks of timeline events over the service protocol. Can be used to monitor long running programs without buffering all events inside the VM.
- Rename TimelineEventStreamingRecorder to TimelineEventCallbackRecorder. Note that this should only be used for tests.

- Add 'Timeline' service event stream.
- Send a 'TimelineEvents' event on the 'Timeline' stream whenever a TimelineEventBlock is finished and the 'Timeline' stream is subscribed to.

- Simple service protocol test.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1765563002 .
2016-03-04 12:30:50 -08:00
Ivan Posva c822c34af6 - Add DEBUG_ONLY and NOT_IN_PRODUCT macros.
- Remove user_name_ field from RawClass using macros.
- Consolidate "#ifndef PRODUCT" and "#ifdef DEBUG" code using macros.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1715123003 .
2016-02-19 17:48:08 -08:00
John McCutchan cda760915c Add fine grained command line and service protocol control over timeline streams recording
- Add --timeline-streams= flag which takes a comma separated list of streams to record.
- Send "availableStreams" and "recordedStreams" in the _getVMTimelineFlags RPC. Also include the type of recorder we are using.
- Enable setting of "recordedStreams" in the _setVMTimelineFlags RPC.

R=zra@google.com

Review URL: https://codereview.chromium.org/1690333002 .
2016-02-12 13:18:25 -08:00
John McCutchan e2e7af1229 Remove more feature in product mode
- Remove Timeline.
- Remove more vmservice code.
- Remove AST printing.
- Remove IL printing.
- Remove profiler.
- Remove thread interrupter.
- Remove disassembler.
- Remove Library::CheckFunctionFingerprints.

- Update test status files for product mode.

Size of dart_bootstrap before: 5287631
Size of dart_bootstrap after: 5112783

Reduction in size: 174848 bytes.

Total reduction in size (382734 + 174848): 557582 bytes.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1678203002 .
2016-02-09 08:45:32 -08:00
Ivan Posva 4f392df85e Fix some more shorten-64-to-32 warnings:
- Remove duplicate check for javascript integer overflow.
- Make sure the BitField class knows the type it is
  encoding into.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1644223006 .
2016-02-02 13:58:06 -08:00
John McCutchan 33aaf940e5 Output TimelineEventBlocks in sorted order
- Before outputting to JSON sort TimelineEventBlocks by earliest event time.
- Output using sorted block order.
- Works around a bug in mojo (https://github.com/domokit/mojo/issues/649)

R=zra@google.com

Review URL: https://codereview.chromium.org/1657843003 .
2016-02-01 13:12:34 -08:00
Siva Annamalai e72c1fb47d Implement safepointing of threads :
- uses thread execution status transition to track when a thread is in a safepoint or needs to block for a safepoint
 - introduces a monitor per Thread object
 - uses a per thread safepoint handshake between the thread requesting a safepoint and the requested thread.

The ThreadRegistry class now contains only the thread list for an isolate and the functionality of scheduling a thread onto an Isolate and unscheduling it from teh isolate. We could fold this functionality into the Isolate class in a different CL.

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

Review URL: https://codereview.chromium.org/1541073002 .
2016-02-01 10:57:34 -08:00
John McCutchan e06ad0b01c Re-enable Dart_Api Timeline tracing
BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1584003002 .
2016-01-15 13:38:02 -08:00
John McCutchan c580f7f393 Don't conflate Timeline serialized json with event type
- Makes event setup (event type, timestamps, etc) regular.
- Allows any event type to have pre-serialized JSON.

R=asiva@google.com

Review URL: https://codereview.chromium.org/1554623003 .
2015-12-30 12:48:23 -08:00
John McCutchan ccfd7a8c08 Handle duration events when filtering the timeline for a time range
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1545853002 .
2015-12-28 14:49:06 -08:00
John McCutchan bedd2cbf25 Support narrowing a timeline to a given time window
- Assign correct timestamps for timeline events from Dart code.
- Support optional 'timeOriginMicros' and 'timeExtentMicros' to _getVMTimeline service RPC.
- Relax time extent check in profiler.

R=asiva@google.com

Review URL: https://codereview.chromium.org/1533323004 .
2015-12-22 09:18:45 -08:00
John McCutchan 2ff1c28978 Emit Timeline events for most Dart_API calls
- Remove --trace-api and related macros.
- Emit Timeline events on the API stream for Dart_API calls.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1526463005 .
2015-12-15 10:27:22 -08:00
Florian Schneider fbdce6a59e VM: Const-correctness fixes.
Three types of fixes:
1. Remove redundant const_cast
2. Remove const_cast by adding const when appropiate.
3. Remove const_cast by removing const (e.g. places where we call free with it)

For now I only fixed places where the fix is local enough - i.e. does not require
changed a large amount of code.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1526123002 .
2015-12-15 19:24:40 +01:00
John McCutchan cc9b72411d Add TimelineBeginEndScope helper class
- Refactor TimelineDurationScope into TimelineEventScope.
- Reintroduce TimelineDurationScope based on TimelineEventScope.
- Add TimelineBeginEndScope.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1529613002 .
2015-12-14 12:45:39 -08:00
Ivan Posva f887b03b5b - Assert that we do not hold the timeline lock while entering
potential safepoints.
- Enable timeline for existing test as a regression test.
- Fix allocation with timeline lock held during deoptimization to
  prevent deadlock.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1514653002 .
2015-12-09 13:41:42 -08:00
Ryan Macnak c99df050b1 Use a monotonic clock in the implementation of Stopwatch.
Rename OS::GetCurrentTraceMicros() to OS::GetCurrentMonotonicMicros().

BUG=http://dartbug.com/477
BUG=http://dartbug.com/12383
R=iposva@google.com

Review URL: https://codereview.chromium.org/1504523002 .
2015-12-08 10:12:05 -08:00
John McCutchan 43b0ae00e7 Timeline service protocol support with Observatory UI
Service Protocol:
- _clearVMTimeline (clear timeline)
- _getVMTimeline (fetch timeline)
- _setVMTimelineFlag (control recording)
- _getVMTimelineFlag (...)
- _getVMTimeline service unit test

Observatory:
- timeline page with record on/off, clear timeline, and refresh buttons.
- trace-viewer based timeline view that runs in an iframe driven by a small javascript program

Misc:
- Fix default enable logic bugs
- Add 'Debugger Pause' timeline event
- Threads can have a name and that name will be displayed in Observatory
- Tighten up locking when printing JSON

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1406413006 .
2015-11-10 08:02:22 -08:00
John McCutchan f55de246ec More timeline cleanups
- Blocks are associated with threads and not isolates.
- Fix isolate filters when iterating over blocks and events.
- Always add the isolateNumber argument when serializing events.
- Add new (kSerializedJSON) EventType for events already serialized to JSON.
- Have events coming from Dart code use the standard event structure w/ type = kSerializedJSON.
- Remove now unused DartTimelineEvent and machinary.
- Dart and C++ events now use the same structures and system.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1411783004 .
2015-10-20 09:14:23 -07:00
John McCutchan da946fbf99 Simplify timeline backend
Now that we have a central list of all threads that are interacting with the VM we can stop relying on the Isolate's thread registry to cache timeline blocks.

- Move from caching blocks in the Isolate's thread registry and caching them in the Thread directly.
- This allows cached blocks to have events from multiple isolates, increasing usage density and reducing the number of blocks being cached at any given time.
- We no longer need a distinct global block, this allows me to remove a bunch of dead code.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1402383003 .
2015-10-16 13:36:58 -07:00
John McCutchan 7137f9ef06 Stop holding onto TimelineEvents
Due to the need to reclaim TimelineEventBlocks from the system, it is not safe to hold onto a TimelineEvent other than briefly to fill it out.

- Switch TimelineDurationScope to emit two events (begin, end) instead of one duration event.
- When setting duration arguments, hold them in the TimelineDurationScope and then emit them with the end event.

The above two changes allows TimelineDurationScope to work without holding onto a TimelineEvent.

To stop the block from being reclaimed while we are filling out an event, calls to StartEvent return with a lock held that is unlocked when CompleteEvent is called.

- Update tests.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1395803002 .
2015-10-08 14:56:25 -07:00