Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(939)

Unified Diff: runtime/vm/timeline.cc

Issue 1834383002: Add a timeline recorder that drops new events after its buffer is full. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/timeline.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/timeline.cc
diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc
index 5f3d71956c3a7d561c95740b724dc0e2640794b2..f5b20bf2f5c77806cd78ccac624748f0a70e4faa 100644
--- a/runtime/vm/timeline.cc
+++ b/runtime/vm/timeline.cc
@@ -19,6 +19,7 @@ namespace dart {
#ifndef PRODUCT
DEFINE_FLAG(bool, complete_timeline, false, "Record the complete timeline");
+DEFINE_FLAG(bool, startup_timeline, false, "Record the startup timeline");
DEFINE_FLAG(bool, trace_timeline, false,
"Trace timeline backend");
DEFINE_FLAG(bool, trace_timeline_analysis, false,
@@ -111,7 +112,8 @@ static void FreeEnabledByDefaultTimelineStreams(
// Returns true if |streams| contains |stream| or "all". Not case sensitive.
static bool HasStream(MallocGrowableArray<char*>* streams, const char* stream) {
- if ((FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline) {
+ if ((FLAG_timeline_dir != NULL) ||
+ FLAG_timing || FLAG_complete_timeline || FLAG_startup_timeline) {
return true;
}
for (intptr_t i = 0; i < streams->length(); i++) {
@@ -134,6 +136,8 @@ void Timeline::InitOnce() {
(FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline;
if (use_endless_recorder) {
recorder_ = new TimelineEventEndlessRecorder();
+ } else if (FLAG_startup_timeline) {
+ recorder_ = new TimelineEventStartupRecorder();
} else if (use_ring_recorder) {
recorder_ = new TimelineEventRingRecorder();
}
@@ -1054,7 +1058,8 @@ TimelineEventBlock* TimelineEventRecorder::GetNewBlock() {
}
-TimelineEventRingRecorder::TimelineEventRingRecorder(intptr_t capacity)
+TimelineEventFixedBufferRecorder::TimelineEventFixedBufferRecorder(
+ intptr_t capacity)
: blocks_(NULL),
capacity_(capacity),
num_blocks_(0),
@@ -1077,7 +1082,7 @@ TimelineEventRingRecorder::TimelineEventRingRecorder(intptr_t capacity)
}
-TimelineEventRingRecorder::~TimelineEventRingRecorder() {
+TimelineEventFixedBufferRecorder::~TimelineEventFixedBufferRecorder() {
// Delete all blocks.
for (intptr_t i = 0; i < num_blocks_; i++) {
TimelineEventBlock* block = blocks_[i];
@@ -1087,7 +1092,7 @@ TimelineEventRingRecorder::~TimelineEventRingRecorder() {
}
-void TimelineEventRingRecorder::PrintJSONEvents(
+void TimelineEventFixedBufferRecorder::PrintJSONEvents(
JSONArray* events,
TimelineEventFilter* filter) {
if (!FLAG_support_service) {
@@ -1117,8 +1122,8 @@ void TimelineEventRingRecorder::PrintJSONEvents(
}
-void TimelineEventRingRecorder::PrintJSON(JSONStream* js,
- TimelineEventFilter* filter) {
+void TimelineEventFixedBufferRecorder::PrintJSON(JSONStream* js,
+ TimelineEventFilter* filter) {
if (!FLAG_support_service) {
return;
}
@@ -1132,8 +1137,9 @@ void TimelineEventRingRecorder::PrintJSON(JSONStream* js,
}
-void TimelineEventRingRecorder::PrintTraceEvent(JSONStream* js,
- TimelineEventFilter* filter) {
+void TimelineEventFixedBufferRecorder::PrintTraceEvent(
+ JSONStream* js,
+ TimelineEventFilter* filter) {
if (!FLAG_support_service) {
return;
}
@@ -1142,25 +1148,12 @@ void TimelineEventRingRecorder::PrintTraceEvent(JSONStream* js,
}
-TimelineEventBlock* TimelineEventRingRecorder::GetHeadBlockLocked() {
+TimelineEventBlock* TimelineEventFixedBufferRecorder::GetHeadBlockLocked() {
return blocks_[0];
}
-TimelineEventBlock* TimelineEventRingRecorder::GetNewBlockLocked() {
- // TODO(johnmccutchan): This function should only hand out blocks
- // which have been marked as finished.
- if (block_cursor_ == num_blocks_) {
- block_cursor_ = 0;
- }
- TimelineEventBlock* block = blocks_[block_cursor_++];
- block->Reset();
- block->Open();
- return block;
-}
-
-
-void TimelineEventRingRecorder::Clear() {
+void TimelineEventFixedBufferRecorder::Clear() {
MutexLocker ml(&lock_);
for (intptr_t i = 0; i < num_blocks_; i++) {
TimelineEventBlock* block = blocks_[i];
@@ -1169,7 +1162,7 @@ void TimelineEventRingRecorder::Clear() {
}
-intptr_t TimelineEventRingRecorder::FindOldestBlockIndex() const {
+intptr_t TimelineEventFixedBufferRecorder::FindOldestBlockIndex() const {
int64_t earliest_time = kMaxInt64;
intptr_t earliest_index = -1;
for (intptr_t block_idx = 0; block_idx < num_blocks_; block_idx++) {
@@ -1187,12 +1180,12 @@ intptr_t TimelineEventRingRecorder::FindOldestBlockIndex() const {
}
-TimelineEvent* TimelineEventRingRecorder::StartEvent() {
+TimelineEvent* TimelineEventFixedBufferRecorder::StartEvent() {
return ThreadBlockStartEvent();
}
-void TimelineEventRingRecorder::CompleteEvent(TimelineEvent* event) {
+void TimelineEventFixedBufferRecorder::CompleteEvent(TimelineEvent* event) {
if (event == NULL) {
return;
}
@@ -1200,6 +1193,30 @@ void TimelineEventRingRecorder::CompleteEvent(TimelineEvent* event) {
}
+TimelineEventBlock* TimelineEventRingRecorder::GetNewBlockLocked() {
+ // TODO(johnmccutchan): This function should only hand out blocks
+ // which have been marked as finished.
+ if (block_cursor_ == num_blocks_) {
+ block_cursor_ = 0;
+ }
+ TimelineEventBlock* block = blocks_[block_cursor_++];
+ block->Reset();
+ block->Open();
+ return block;
+}
+
+
+TimelineEventBlock* TimelineEventStartupRecorder::GetNewBlockLocked() {
+ if (block_cursor_ == num_blocks_) {
+ return NULL;
+ }
+ TimelineEventBlock* block = blocks_[block_cursor_++];
+ block->Reset();
+ block->Open();
+ return block;
+}
+
+
TimelineEventCallbackRecorder::TimelineEventCallbackRecorder() {
}
« no previous file with comments | « runtime/vm/timeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698