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

Side by Side Diff: base/debug/trace_event_impl.cc

Issue 440903003: Add RECORD_AS_MUCH_AS_POSSIBLE mode to TraceOptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/debug/trace_event_impl.h" 5 #include "base/debug/trace_event_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 namespace { 55 namespace {
56 56
57 // The overhead of TraceEvent above this threshold will be reported in the 57 // The overhead of TraceEvent above this threshold will be reported in the
58 // trace. 58 // trace.
59 const int kOverheadReportThresholdInMicroseconds = 50; 59 const int kOverheadReportThresholdInMicroseconds = 50;
60 60
61 // String options that can be used to initialize TraceOptions. 61 // String options that can be used to initialize TraceOptions.
62 const char kRecordUntilFull[] = "record-until-full"; 62 const char kRecordUntilFull[] = "record-until-full";
63 const char kRecordContinuously[] = "record-continuously"; 63 const char kRecordContinuously[] = "record-continuously";
64 const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible";
64 const char kTraceToConsole[] = "trace-to-console"; 65 const char kTraceToConsole[] = "trace-to-console";
65 const char kEnableSampling[] = "enable-sampling"; 66 const char kEnableSampling[] = "enable-sampling";
66 const char kEnableSystrace[] = "enable-systrace"; 67 const char kEnableSystrace[] = "enable-systrace";
67 68
68 // Controls the number of trace events we will buffer in-memory 69 // Controls the number of trace events we will buffer in-memory
69 // before throwing them away. 70 // before throwing them away.
70 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; 71 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize;
72 const size_t kTraceEventVectorBigBufferChunks =
73 512000000 / kTraceBufferChunkSize;
71 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize; 74 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize;
72 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; 75 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4;
73 const size_t kTraceEventBatchChunks = 1000 / kTraceBufferChunkSize; 76 const size_t kTraceEventBatchChunks = 1000 / kTraceBufferChunkSize;
74 // Can store results for 30 seconds with 1 ms sampling interval. 77 // Can store results for 30 seconds with 1 ms sampling interval.
75 const size_t kMonitorTraceEventBufferChunks = 30000 / kTraceBufferChunkSize; 78 const size_t kMonitorTraceEventBufferChunks = 30000 / kTraceBufferChunkSize;
76 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. 79 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events.
77 const size_t kEchoToConsoleTraceEventBufferChunks = 256; 80 const size_t kEchoToConsoleTraceEventBufferChunks = 256;
78 81
79 const int kThreadFlushTimeoutMs = 3000; 82 const int kThreadFlushTimeoutMs = 3000;
80 83
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 std::vector<std::string>::iterator iter; 992 std::vector<std::string>::iterator iter;
990 993
991 base::SplitString(options_string, ',', &split); 994 base::SplitString(options_string, ',', &split);
992 for (iter = split.begin(); iter != split.end(); ++iter) { 995 for (iter = split.begin(); iter != split.end(); ++iter) {
993 if (*iter == kRecordUntilFull) { 996 if (*iter == kRecordUntilFull) {
994 record_mode = RECORD_UNTIL_FULL; 997 record_mode = RECORD_UNTIL_FULL;
995 } else if (*iter == kRecordContinuously) { 998 } else if (*iter == kRecordContinuously) {
996 record_mode = RECORD_CONTINUOUSLY; 999 record_mode = RECORD_CONTINUOUSLY;
997 } else if (*iter == kTraceToConsole) { 1000 } else if (*iter == kTraceToConsole) {
998 record_mode = ECHO_TO_CONSOLE; 1001 record_mode = ECHO_TO_CONSOLE;
1002 } else if (*iter == kRecordAsMuchAsPossible) {
1003 record_mode = RECORD_AS_MUCH_AS_POSSIBLE;
999 } else if (*iter == kEnableSampling) { 1004 } else if (*iter == kEnableSampling) {
1000 enable_sampling = true; 1005 enable_sampling = true;
1001 } else if (*iter == kEnableSystrace) { 1006 } else if (*iter == kEnableSystrace) {
1002 enable_systrace = true; 1007 enable_systrace = true;
1003 } else { 1008 } else {
1004 NOTREACHED(); 1009 NOTREACHED();
1005 } 1010 }
1006 } 1011 }
1007 } 1012 }
1008 1013
1009 std::string TraceOptions::ToString() const { 1014 std::string TraceOptions::ToString() const {
1010 std::string ret; 1015 std::string ret;
1011 switch (record_mode) { 1016 switch (record_mode) {
1012 case RECORD_UNTIL_FULL: 1017 case RECORD_UNTIL_FULL:
1013 ret = kRecordUntilFull; 1018 ret = kRecordUntilFull;
1014 break; 1019 break;
1015 case RECORD_CONTINUOUSLY: 1020 case RECORD_CONTINUOUSLY:
1016 ret = kRecordContinuously; 1021 ret = kRecordContinuously;
1017 break; 1022 break;
1018 case ECHO_TO_CONSOLE: 1023 case ECHO_TO_CONSOLE:
1019 ret = kTraceToConsole; 1024 ret = kTraceToConsole;
1020 break; 1025 break;
1026 case RECORD_AS_MUCH_AS_POSSIBLE:
1027 ret = kRecordAsMuchAsPossible;
1028 break;
1021 default: 1029 default:
1022 NOTREACHED(); 1030 NOTREACHED();
1023 } 1031 }
1024 if (enable_sampling) 1032 if (enable_sampling)
1025 ret = ret + "," + kEnableSampling; 1033 ret = ret + "," + kEnableSampling;
1026 if (enable_systrace) 1034 if (enable_systrace)
1027 ret = ret + "," + kEnableSystrace; 1035 ret = ret + "," + kEnableSystrace;
1028 return ret; 1036 return ret;
1029 } 1037 }
1030 1038
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 const TraceOptions& options) { 1479 const TraceOptions& options) {
1472 InternalTraceOptions ret = 1480 InternalTraceOptions ret =
1473 options.enable_sampling ? kInternalEnableSampling : kInternalNone; 1481 options.enable_sampling ? kInternalEnableSampling : kInternalNone;
1474 switch (options.record_mode) { 1482 switch (options.record_mode) {
1475 case RECORD_UNTIL_FULL: 1483 case RECORD_UNTIL_FULL:
1476 return ret | kInternalRecordUntilFull; 1484 return ret | kInternalRecordUntilFull;
1477 case RECORD_CONTINUOUSLY: 1485 case RECORD_CONTINUOUSLY:
1478 return ret | kInternalRecordContinuously; 1486 return ret | kInternalRecordContinuously;
1479 case ECHO_TO_CONSOLE: 1487 case ECHO_TO_CONSOLE:
1480 return ret | kInternalEchoToConsole; 1488 return ret | kInternalEchoToConsole;
1489 case RECORD_AS_MUCH_AS_POSSIBLE:
1490 return ret | kInternalRecordAsMuchAsPossible;
1481 } 1491 }
1482 NOTREACHED(); 1492 NOTREACHED();
1483 return kInternalNone; 1493 return kInternalNone;
1484 } 1494 }
1485 1495
1486 CategoryFilter TraceLog::GetCurrentCategoryFilter() { 1496 CategoryFilter TraceLog::GetCurrentCategoryFilter() {
1487 AutoLock lock(lock_); 1497 AutoLock lock(lock_);
1488 return category_filter_; 1498 return category_filter_;
1489 } 1499 }
1490 1500
1491 TraceOptions TraceLog::GetCurrentTraceOptions() const { 1501 TraceOptions TraceLog::GetCurrentTraceOptions() const {
1492 TraceOptions ret; 1502 TraceOptions ret;
1493 InternalTraceOptions option = trace_options(); 1503 InternalTraceOptions option = trace_options();
1494 ret.enable_sampling = (option & kInternalEnableSampling) != 0; 1504 ret.enable_sampling = (option & kInternalEnableSampling) != 0;
1495 if (option & kInternalRecordUntilFull) 1505 if (option & kInternalRecordUntilFull)
1496 ret.record_mode = RECORD_UNTIL_FULL; 1506 ret.record_mode = RECORD_UNTIL_FULL;
1497 else if (option & kInternalRecordContinuously) 1507 else if (option & kInternalRecordContinuously)
1498 ret.record_mode = RECORD_CONTINUOUSLY; 1508 ret.record_mode = RECORD_CONTINUOUSLY;
1499 else if (option & kInternalEchoToConsole) 1509 else if (option & kInternalEchoToConsole)
1500 ret.record_mode = ECHO_TO_CONSOLE; 1510 ret.record_mode = ECHO_TO_CONSOLE;
1511 else if (option & kInternalRecordAsMuchAsPossible)
1512 ret.record_mode = RECORD_AS_MUCH_AS_POSSIBLE;
1501 else 1513 else
1502 NOTREACHED(); 1514 NOTREACHED();
1503 return ret; 1515 return ret;
1504 } 1516 }
1505 1517
1506 void TraceLog::SetDisabled() { 1518 void TraceLog::SetDisabled() {
1507 AutoLock lock(lock_); 1519 AutoLock lock(lock_);
1508 SetDisabledWhileLocked(); 1520 SetDisabledWhileLocked();
1509 } 1521 }
1510 1522
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 } 1604 }
1593 1605
1594 TraceBuffer* TraceLog::CreateTraceBuffer() { 1606 TraceBuffer* TraceLog::CreateTraceBuffer() {
1595 InternalTraceOptions options = trace_options(); 1607 InternalTraceOptions options = trace_options();
1596 if (options & kInternalRecordContinuously) 1608 if (options & kInternalRecordContinuously)
1597 return new TraceBufferRingBuffer(kTraceEventRingBufferChunks); 1609 return new TraceBufferRingBuffer(kTraceEventRingBufferChunks);
1598 else if ((options & kInternalEnableSampling) && mode_ == MONITORING_MODE) 1610 else if ((options & kInternalEnableSampling) && mode_ == MONITORING_MODE)
1599 return new TraceBufferRingBuffer(kMonitorTraceEventBufferChunks); 1611 return new TraceBufferRingBuffer(kMonitorTraceEventBufferChunks);
1600 else if (options & kInternalEchoToConsole) 1612 else if (options & kInternalEchoToConsole)
1601 return new TraceBufferRingBuffer(kEchoToConsoleTraceEventBufferChunks); 1613 return new TraceBufferRingBuffer(kEchoToConsoleTraceEventBufferChunks);
1614 else if (options & kInternalRecordAsMuchAsPossible)
1615 return CreateTraceBufferVectorOfSize(kTraceEventVectorBigBufferChunks);
1602 return CreateTraceBufferVectorOfSize(kTraceEventVectorBufferChunks); 1616 return CreateTraceBufferVectorOfSize(kTraceEventVectorBufferChunks);
1603 } 1617 }
1604 1618
1605 TraceBuffer* TraceLog::CreateTraceBufferVectorOfSize(size_t max_chunks) { 1619 TraceBuffer* TraceLog::CreateTraceBufferVectorOfSize(size_t max_chunks) {
1606 return new TraceBufferVector(max_chunks); 1620 return new TraceBufferVector(max_chunks);
1607 } 1621 }
1608 1622
1609 TraceEvent* TraceLog::AddEventToThreadSharedChunkWhileLocked( 1623 TraceEvent* TraceLog::AddEventToThreadSharedChunkWhileLocked(
1610 TraceEventHandle* handle, bool check_buffer_is_full) { 1624 TraceEventHandle* handle, bool check_buffer_is_full) {
1611 lock_.AssertAcquired(); 1625 lock_.AssertAcquired();
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 } 2561 }
2548 2562
2549 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2563 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2550 if (*category_group_enabled_) { 2564 if (*category_group_enabled_) {
2551 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2565 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2552 name_, event_handle_); 2566 name_, event_handle_);
2553 } 2567 }
2554 } 2568 }
2555 2569
2556 } // namespace trace_event_internal 2570 } // namespace trace_event_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698