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

Side by Side Diff: runtime/vm/timeline.h

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, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/timeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_TIMELINE_H_ 5 #ifndef VM_TIMELINE_H_
6 #define VM_TIMELINE_H_ 6 #define VM_TIMELINE_H_
7 7
8 #include "include/dart_tools_api.h" 8 #include "include/dart_tools_api.h"
9 9
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 intptr_t arguments_length_; 323 intptr_t arguments_length_;
324 uword state_; 324 uword state_;
325 const char* label_; 325 const char* label_;
326 const char* category_; 326 const char* category_;
327 ThreadId thread_; 327 ThreadId thread_;
328 Dart_Port isolate_id_; 328 Dart_Port isolate_id_;
329 329
330 friend class TimelineEventRecorder; 330 friend class TimelineEventRecorder;
331 friend class TimelineEventEndlessRecorder; 331 friend class TimelineEventEndlessRecorder;
332 friend class TimelineEventRingRecorder; 332 friend class TimelineEventRingRecorder;
333 friend class TimelineEventStartupRecorder;
333 friend class TimelineStream; 334 friend class TimelineStream;
334 friend class TimelineTestHelper; 335 friend class TimelineTestHelper;
335 DISALLOW_COPY_AND_ASSIGN(TimelineEvent); 336 DISALLOW_COPY_AND_ASSIGN(TimelineEvent);
336 }; 337 };
337 338
338 339
339 // A stream of timeline events. A stream has a name and can be enabled or 340 // A stream of timeline events. A stream has a name and can be enabled or
340 // disabled (globally and per isolate). 341 // disabled (globally and per isolate).
341 class TimelineStream { 342 class TimelineStream {
342 public: 343 public:
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 568
568 // Only accessed under the recorder's lock. 569 // Only accessed under the recorder's lock.
569 ThreadId thread_id_; 570 ThreadId thread_id_;
570 bool in_use_; 571 bool in_use_;
571 572
572 void Open(); 573 void Open();
573 void Finish(); 574 void Finish();
574 575
575 friend class Thread; 576 friend class Thread;
576 friend class TimelineEventRecorder; 577 friend class TimelineEventRecorder;
578 friend class TimelineEventEndlessRecorder;
577 friend class TimelineEventRingRecorder; 579 friend class TimelineEventRingRecorder;
578 friend class TimelineEventEndlessRecorder; 580 friend class TimelineEventStartupRecorder;
579 friend class TimelineTestHelper; 581 friend class TimelineTestHelper;
580 friend class JSONStream; 582 friend class JSONStream;
581 583
582 private: 584 private:
583 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock); 585 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock);
584 }; 586 };
585 587
586 588
587 class TimelineEventFilter : public ValueObject { 589 class TimelineEventFilter : public ValueObject {
588 public: 590 public:
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 friend class TimelineEventBlockIterator; 684 friend class TimelineEventBlockIterator;
683 friend class TimelineStream; 685 friend class TimelineStream;
684 friend class TimelineTestHelper; 686 friend class TimelineTestHelper;
685 friend class Timeline; 687 friend class Timeline;
686 688
687 private: 689 private:
688 DISALLOW_COPY_AND_ASSIGN(TimelineEventRecorder); 690 DISALLOW_COPY_AND_ASSIGN(TimelineEventRecorder);
689 }; 691 };
690 692
691 693
692 // A recorder that stores events in a ring buffer of fixed capacity. 694 // An abstract recorder that stores events in a buffer of fixed capacity.
693 class TimelineEventRingRecorder : public TimelineEventRecorder { 695 class TimelineEventFixedBufferRecorder : public TimelineEventRecorder {
694 public: 696 public:
695 static const intptr_t kDefaultCapacity = 8192; 697 static const intptr_t kDefaultCapacity = 8192;
696 698
697 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity); 699 explicit TimelineEventFixedBufferRecorder(intptr_t capacity);
698 ~TimelineEventRingRecorder(); 700 ~TimelineEventFixedBufferRecorder();
699 701
700 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); 702 void PrintJSON(JSONStream* js, TimelineEventFilter* filter);
701 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); 703 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter);
702 const char* name() const {
703 return "ring";
704 }
705 704
706 protected: 705 protected:
707 TimelineEvent* StartEvent(); 706 TimelineEvent* StartEvent();
708 void CompleteEvent(TimelineEvent* event); 707 void CompleteEvent(TimelineEvent* event);
709 TimelineEventBlock* GetHeadBlockLocked(); 708 TimelineEventBlock* GetHeadBlockLocked();
710 intptr_t FindOldestBlockIndex() const; 709 intptr_t FindOldestBlockIndex() const;
711 TimelineEventBlock* GetNewBlockLocked();
712 void Clear(); 710 void Clear();
713 711
714 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); 712 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter);
715 713
716 TimelineEventBlock** blocks_; 714 TimelineEventBlock** blocks_;
717 intptr_t capacity_; 715 intptr_t capacity_;
718 intptr_t num_blocks_; 716 intptr_t num_blocks_;
719 intptr_t block_cursor_; 717 intptr_t block_cursor_;
720 }; 718 };
721 719
722 720
721 // A recorder that stores events in a buffer of fixed capacity. When the buffer
722 // is full, new events overwrite old events.
723 class TimelineEventRingRecorder : public TimelineEventFixedBufferRecorder {
724 public:
725 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity)
726 : TimelineEventFixedBufferRecorder(capacity) {}
727 ~TimelineEventRingRecorder() {}
728
729 const char* name() const {
730 return "ring";
731 }
732
733 protected:
734 TimelineEventBlock* GetNewBlockLocked();
735 };
736
737
738 // A recorder that stores events in a buffer of fixed capacity. When the buffer
739 // is full, new events are dropped.
740 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder {
741 public:
742 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity)
743 : TimelineEventFixedBufferRecorder(capacity) {}
744 ~TimelineEventStartupRecorder() {}
745
746 const char* name() const {
747 return "startup";
748 }
749
750 protected:
751 TimelineEventBlock* GetNewBlockLocked();
752 };
753
754
723 // An abstract recorder that calls |OnEvent| whenever an event is complete. 755 // An abstract recorder that calls |OnEvent| whenever an event is complete.
724 // This should only be used for testing. 756 // This should only be used for testing.
725 class TimelineEventCallbackRecorder : public TimelineEventRecorder { 757 class TimelineEventCallbackRecorder : public TimelineEventRecorder {
726 public: 758 public:
727 TimelineEventCallbackRecorder(); 759 TimelineEventCallbackRecorder();
728 ~TimelineEventCallbackRecorder(); 760 ~TimelineEventCallbackRecorder();
729 761
730 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); 762 void PrintJSON(JSONStream* js, TimelineEventFilter* filter);
731 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); 763 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter);
732 764
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 830
799 private: 831 private:
800 TimelineEventBlock* current_; 832 TimelineEventBlock* current_;
801 TimelineEventRecorder* recorder_; 833 TimelineEventRecorder* recorder_;
802 }; 834 };
803 835
804 836
805 } // namespace dart 837 } // namespace dart
806 838
807 #endif // VM_TIMELINE_H_ 839 #endif // VM_TIMELINE_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/timeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698