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

Side by Side Diff: base/trace_event/trace_log.cc

Issue 1276163003: Increase number of bits for trace buffer chunk index (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Correct number of bits Created 5 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
« no previous file with comments | « base/trace_event/trace_event_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/trace_event/trace_log.h" 5 #include "base/trace_event/trace_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; 51 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
52 52
53 namespace base { 53 namespace base {
54 namespace trace_event { 54 namespace trace_event {
55 55
56 namespace { 56 namespace {
57 57
58 // Controls the number of trace events we will buffer in-memory 58 // Controls the number of trace events we will buffer in-memory
59 // before throwing them away. 59 // before throwing them away.
60 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; 60 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize;
61
61 const size_t kTraceEventVectorBigBufferChunks = 62 const size_t kTraceEventVectorBigBufferChunks =
62 512000000 / kTraceBufferChunkSize; 63 512000000 / kTraceBufferChunkSize;
64 static_assert(
65 kTraceEventVectorBigBufferChunks <= TraceBufferChunk::kMaxChunkIndex,
66 "Too many big buffer chunks");
63 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize; 67 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize;
68 static_assert(
69 kTraceEventVectorBufferChunks <= TraceBufferChunk::kMaxChunkIndex,
70 "Too many vector buffer chunks");
64 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; 71 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4;
72
65 // Can store results for 30 seconds with 1 ms sampling interval. 73 // Can store results for 30 seconds with 1 ms sampling interval.
66 const size_t kMonitorTraceEventBufferChunks = 30000 / kTraceBufferChunkSize; 74 const size_t kMonitorTraceEventBufferChunks = 30000 / kTraceBufferChunkSize;
67 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. 75 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events.
68 const size_t kEchoToConsoleTraceEventBufferChunks = 256; 76 const size_t kEchoToConsoleTraceEventBufferChunks = 256;
69 77
70 // The overhead of TraceEvent above this threshold will be reported in the 78 // The overhead of TraceEvent above this threshold will be reported in the
71 // trace. 79 // trace.
72 const int kOverheadReportThresholdInMicroseconds = 50; 80 const int kOverheadReportThresholdInMicroseconds = 50;
73 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; 81 const size_t kTraceEventBufferSizeInBytes = 100 * 1024;
74 const int kThreadFlushTimeoutMs = 3000; 82 const int kThreadFlushTimeoutMs = 3000;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 DISALLOW_COPY_AND_ASSIGN(AutoThreadLocalBoolean); 168 DISALLOW_COPY_AND_ASSIGN(AutoThreadLocalBoolean);
161 }; 169 };
162 170
163 // Use this function instead of TraceEventHandle constructor to keep the 171 // Use this function instead of TraceEventHandle constructor to keep the
164 // overhead of ScopedTracer (trace_event.h) constructor minimum. 172 // overhead of ScopedTracer (trace_event.h) constructor minimum.
165 void MakeHandle(uint32 chunk_seq, 173 void MakeHandle(uint32 chunk_seq,
166 size_t chunk_index, 174 size_t chunk_index,
167 size_t event_index, 175 size_t event_index,
168 TraceEventHandle* handle) { 176 TraceEventHandle* handle) {
169 DCHECK(chunk_seq); 177 DCHECK(chunk_seq);
170 DCHECK(chunk_index < (1u << 16)); 178 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex);
171 DCHECK(event_index < (1u << 16)); 179 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize);
172 handle->chunk_seq = chunk_seq; 180 handle->chunk_seq = chunk_seq;
173 handle->chunk_index = static_cast<uint16>(chunk_index); 181 handle->chunk_index = static_cast<uint16>(chunk_index);
174 handle->event_index = static_cast<uint16>(event_index); 182 handle->event_index = static_cast<uint16>(event_index);
175 } 183 }
176 184
177 } // namespace 185 } // namespace
178 186
179 // A helper class that allows the lock to be acquired in the middle of the scope 187 // A helper class that allows the lock to be acquired in the middle of the scope
180 // and unlocks at the end of scope if locked. 188 // and unlocks at the end of scope if locked.
181 class TraceLog::OptionalAutoLock { 189 class TraceLog::OptionalAutoLock {
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 } 1746 }
1739 1747
1740 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1748 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1741 if (*category_group_enabled_) { 1749 if (*category_group_enabled_) {
1742 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1750 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1743 event_handle_); 1751 event_handle_);
1744 } 1752 }
1745 } 1753 }
1746 1754
1747 } // namespace trace_event_internal 1755 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698