Commit Graph

31 Commits

Author SHA1 Message Date
Ben Konyi b43e89c7f6 [ VM ] Cleanup timeline_test.cc
Updated the timeline cc tests to override Timeline::recorder()
consistently and properly cleanup recorder memory. Fixes some memory
leaks.

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

TEST=timeline_test.cc

Change-Id: I36d69434ec29fa6bf42ffdb06943374b5a412dc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192960
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-03-24 19:46:32 +00:00
Ben Konyi 19b67901f2 [ VM ] Add missing locks in timeline recorder cleanup
Fixes https://github.com/flutter/flutter/issues/78076

Reverts commits ddcb60a3d9 and 3ecbfd927f.

TEST=runtime/vm/timeline_test.cc

Change-Id: I5eeb66e01a1a1b842edf9183fa876fc97e992398
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192500
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
2021-03-23 20:05:11 +00:00
Siva Annamalai ddcb60a3d9 Revert "[ VM ] Update Timeline tests to not use recorder->Clear()"
This reverts commit f06348108a.

Reason for revert: Flutter engine shell tests are timing out

Original change's description:
> [ VM ] Update Timeline tests to not use recorder->Clear()
>
> Also added IsOwnedByCurrentThread() assert for ReclaimCachedBlocksFromThreadsLocked
>
> Follow up to a62e144882
>
> TEST=runtime/vm/timeline_test.cc
>
> Change-Id: Iec3597b407d99ada1894752f7150a9ae4025bf91
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192243
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Id7ba866d7966743bc54659a5d2a632eb31bbf355
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192481
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-03-22 17:42:37 +00:00
Ben Konyi f06348108a [ VM ] Update Timeline tests to not use recorder->Clear()
Also added IsOwnedByCurrentThread() assert for ReclaimCachedBlocksFromThreadsLocked

Follow up to a62e144882

TEST=runtime/vm/timeline_test.cc

Change-Id: Iec3597b407d99ada1894752f7150a9ae4025bf91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192243
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-03-20 01:35:38 +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 a75ded625e [ VM / Service ] Made VM timeline functionality public through the service API.
Change-Id: I8228f0417047af53edc6f570940d452da3155bbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106061
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-06-19 16:06:12 +00:00
Ryan Macnak dc555eb9a7 [vm] On Fuchsia, enable timeline streams based on the state of system trace categories.
Allows categories to be selected through arguments to `trace` instead of changing VM flags and rebuilding.

Change-Id: Ia1ec6b58ca0b765c3d675b7d4938acc5f624b768
Reviewed-on: https://dart-review.googlesource.com/c/91860
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-03-01 18:05:40 +00: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 cbf3eaeb90 Fix various memory leaks in unit tests detected by a new version of ASAN.
R=zra@google.com

Review-Url: https://codereview.chromium.org/2620413002 .
2017-01-11 11:12:40 -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
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 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
John McCutchan a5390e8588 Sleep for more than 1 millisecond in timeline tests
This is an attempt to fix flaky Windows timeline tests.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1687043003 .
2016-02-10 10:20:53 -08:00
John McCutchan d295b9c311 Remove many features when building product mode
Move all JSON printing code from object.cc to object_service.cc.

Not compiled in:

- Service protocol
- Debugger
- Debugger API
- JSONStream
- ObjectIdRing
- Profiler service
- Object JSON printing

Size of dart_bootstrap before: 5670365 bytes
Size of dart_bootstrap after: 5287631 bytes

Reduction in size: 382734 bytes.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1660063002 .
2016-02-05 09:55:51 -08: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
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 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
John McCutchan 979b7868ca Add support to timeline for begin and end events
- Add support for begin and end even kinds.
- Update TimelineAnalysis to properly account for begin and end events as well as duration events.
- Add unit test for analysis of timelines with begin and end events.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1386263002 .
2015-10-07 14:11:44 -07:00
John McCutchan 03b41129a2 Add Timeline to dart:developer
- This CL only adds support for synchronous blocks of time. A follow up CL will add asynchronous blocks of time.
- Reports true thread id to tracing system. This is an improvement over Mojo's tracing helper.
- Dart events are included in individual isolate traces and global traces obtained via the embedders API.
- Dart events are included in the write to disk path (--timeline_dir).

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1377663002 .
2015-10-01 09:30:47 -07:00
John McCutchan 08118282d7 Fix TimelinePauses_Basic test failure
BUG=

Review URL: https://codereview.chromium.org//1368823002 .
2015-09-24 15:31:24 -07:00
Ivan Posva 4bd7cdc75c - Ensure that HandleScope is initialized with a thread. (Remove
deprecated isolate based API.)
- Update all code impacted by this change. E.g. DARTSCOPE
- TEST_CASE now passes the current thread as a parameter to the   unit test.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1310463005 .
2015-09-01 17:18:55 -07:00
John McCutchan 1ff7144c31 Switch to a VM wide timeline recorder
- Initialize and shutdown timeline recorder with VM.
- Allocate global blocks for timeline events without an isolate.
- Stop storing the Stream pointer inside a TimelineEvent.
- Store category name in TimelineEvent.
- Store isolate pointer in TimelineEvent.
- TimelineEventRecorder::WriteTo is full VM dump.
- Allow JSONStream to be used without an isolate.
- When a ThreadRegistry is deleted, Finish all open timeline blocks.
- PrintJSON takes a filter.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1294023009 .
2015-08-18 15:18:02 -07:00
John McCutchan c0b6625d20 Correct inclusive time and start tracking maximum exclusive time
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1287073006 .
2015-08-14 14:47:28 -07:00
John McCutchan 08cc68cc55 Add TimelinePauses analysis and tests
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1289113003 .
2015-08-14 11:11:59 -07:00
John McCutchan 119e72ded2 Improve timeline iterators and tests
- Refactor TimelineEventBlockIterator
- Add TimelineAnalysisThreadEventIterator
- Add test of TimelineAnalysisThreadEventIterator.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1297443002 .
2015-08-13 15:44:04 -07:00
John McCutchan d4fbd8309e Ensure TimelineEventRingRecorder outputs blocks in increasing time order
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1283093004 .
2015-08-13 14:22:46 -07:00
John McCutchan 0ae89cf980 Fix MacOS build
BUG=

Review URL: https://codereview.chromium.org//1286093005 .
2015-08-12 15:01:21 -07:00
John McCutchan 4511599443 Start TimelineAnalysis utility
- Add TimelineEventBlockIterator - iterate over TimelineEventBlocks.
- Add TimelineAnalysisThread - All events for a specific thread.
- Add TimelineAnalysis - Utility for analyzing timeline events.
- Add unit test for TimelineAnalysis thread discovery and block sorting.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1284263002 .
2015-08-12 13:31:31 -07:00
John McCutchan f58029a0cd Refactor some Timeline interfaces to be simpler and support streaming
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1173333007.
2015-06-16 10:52:48 -07:00
John McCutchan c7187924a9 Initial Timeline Events
- Each isolate has its own TimelineEventBuffer
- Each isolate has TimelineEventStreams for API, Compiler, Embedder, Isolate, and GC
- Compiler, Isolate, Embedder, and GC are being inserted into the stream
- Basic unit tests
- Dart API for injecting timeline events
- Arbitrary number of native and Dart arguments can be attached to each event
- JSON printing
- Output can be loaded by about://tracing
- Add --timeline-trace-dir flag

Short term follow up CLS:
- Service protocol requests to enable / disable tracing and retrieve a trace
- UI for Observatory
- Dart code EventStreams and Events

R=asiva@google.com

Review URL: https://codereview.chromium.org//1170503004.
2015-06-16 10:10:14 -07:00