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

Unified Diff: base/trace_event/trace_log.cc

Issue 1345223004: Remove trace event overhead reporting feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ThreadLocalEventBuffer::event_count_ Created 5 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_log.cc
diff --git a/base/trace_event/trace_log.cc b/base/trace_event/trace_log.cc
index eed24118a48ff9be7cc79901d5545d7568aa1d33..13815b306cb15911c43ed98453094c7916e783db 100644
--- a/base/trace_event/trace_log.cc
+++ b/base/trace_event/trace_log.cc
@@ -79,9 +79,6 @@ const size_t kMonitorTraceEventBufferChunks = 30000 / kTraceBufferChunkSize;
// ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events.
const size_t kEchoToConsoleTraceEventBufferChunks = 256;
-// The overhead of TraceEvent above this threshold will be reported in the
-// trace.
-const int kOverheadReportThresholdInMicroseconds = 50;
const size_t kTraceEventBufferSizeInBytes = 100 * 1024;
const int kThreadFlushTimeoutMs = 3000;
@@ -102,9 +99,7 @@ const char* g_category_groups[MAX_CATEGORY_GROUPS] = {
"toplevel",
"tracing already shutdown",
"tracing categories exhausted; must increase MAX_CATEGORY_GROUPS",
- "__metadata",
- // For reporting trace_event overhead. For thread local event buffers only.
- "trace_event_overhead"};
+ "__metadata"};
// The enabled flag is char instead of bool so that the API can be used from C.
unsigned char g_category_group_enabled[MAX_CATEGORY_GROUPS] = {0};
@@ -112,8 +107,7 @@ unsigned char g_category_group_enabled[MAX_CATEGORY_GROUPS] = {0};
const int g_category_already_shutdown = 1;
const int g_category_categories_exhausted = 2;
const int g_category_metadata = 3;
-const int g_category_trace_event_overhead = 4;
-const int g_num_builtin_categories = 5;
+const int g_num_builtin_categories = 4;
// Skip default categories.
base::subtle::AtomicWord g_category_index = g_num_builtin_categories;
@@ -221,9 +215,6 @@ class TraceLog::ThreadLocalEventBuffer
TraceEvent* AddTraceEvent(TraceEventHandle* handle);
- void ReportOverhead(const TraceTicks& event_timestamp,
- const ThreadTicks& event_thread_timestamp);
-
TraceEvent* GetEventByHandle(TraceEventHandle handle) {
if (!chunk_ || handle.chunk_seq != chunk_->seq() ||
handle.chunk_index != chunk_index_)
@@ -253,8 +244,6 @@ class TraceLog::ThreadLocalEventBuffer
TraceLog* trace_log_;
scoped_ptr<TraceBufferChunk> chunk_;
size_t chunk_index_;
- int event_count_;
- TimeDelta overhead_;
int generation_;
DISALLOW_COPY_AND_ASSIGN(ThreadLocalEventBuffer);
@@ -263,7 +252,6 @@ class TraceLog::ThreadLocalEventBuffer
TraceLog::ThreadLocalEventBuffer::ThreadLocalEventBuffer(TraceLog* trace_log)
: trace_log_(trace_log),
chunk_index_(0),
- event_count_(0),
generation_(trace_log->generation()) {
// ThreadLocalEventBuffer is created only if the thread has a message loop, so
// the following message_loop won't be NULL.
@@ -283,17 +271,6 @@ TraceLog::ThreadLocalEventBuffer::~ThreadLocalEventBuffer() {
MessageLoop::current()->RemoveDestructionObserver(this);
MemoryDumpManager::GetInstance()->UnregisterDumpProvider(this);
- // Zero event_count_ happens in either of the following cases:
- // - no event generated for the thread;
- // - the thread has no message loop;
- // - trace_event_overhead is disabled.
- if (event_count_) {
- InitializeMetadataEvent(AddTraceEvent(NULL),
- static_cast<int>(base::PlatformThread::CurrentId()),
- "overhead", "average_overhead",
- overhead_.InMillisecondsF() / event_count_);
- }
-
{
AutoLock lock(trace_log_->lock_);
FlushWhileLocked();
@@ -327,43 +304,6 @@ TraceEvent* TraceLog::ThreadLocalEventBuffer::AddTraceEvent(
return trace_event;
}
-void TraceLog::ThreadLocalEventBuffer::ReportOverhead(
- const TraceTicks& event_timestamp,
- const ThreadTicks& event_thread_timestamp) {
- if (!g_category_group_enabled[g_category_trace_event_overhead])
- return;
-
- CheckThisIsCurrentBuffer();
-
- event_count_++;
- ThreadTicks thread_now = ThreadNow();
- TraceTicks now = trace_log_->OffsetNow();
- TimeDelta overhead = now - event_timestamp;
- if (overhead.InMicroseconds() >= kOverheadReportThresholdInMicroseconds) {
- TraceEvent* trace_event = AddTraceEvent(NULL);
- if (trace_event) {
- trace_event->Initialize(
- static_cast<int>(PlatformThread::CurrentId()),
- event_timestamp,
- event_thread_timestamp,
- TRACE_EVENT_PHASE_COMPLETE,
- &g_category_group_enabled[g_category_trace_event_overhead],
- "overhead",
- trace_event_internal::kNoId, // id
- trace_event_internal::kNoId, // context_id
- trace_event_internal::kNoId, // bind_id
- ::trace_event_internal::kZeroNumArgs,
- nullptr,
- nullptr,
- nullptr,
- nullptr,
- TRACE_EVENT_FLAG_NONE);
- trace_event->UpdateDuration(now, thread_now);
- }
- }
- overhead_ += overhead;
-}
-
void TraceLog::ThreadLocalEventBuffer::WillDestroyCurrentMessageLoop() {
delete this;
}
@@ -634,8 +574,6 @@ const unsigned char* TraceLog::GetCategoryGroupEnabledInternal(
void TraceLog::GetKnownCategoryGroups(
std::vector<std::string>* category_groups) {
AutoLock lock(lock_);
- category_groups->push_back(
- g_category_groups[g_category_trace_event_overhead]);
size_t category_index = base::subtle::NoBarrier_Load(&g_category_index);
for (size_t i = g_num_builtin_categories; i < category_index; i++)
category_groups->push_back(g_category_groups[i]);
@@ -1257,9 +1195,6 @@ TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
}
TraceTicks offset_event_timestamp = OffsetTimestamp(timestamp);
- TraceTicks now = flags & TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP
- ? OffsetNow()
- : offset_event_timestamp;
ThreadTicks thread_now = ThreadNow();
// |thread_local_event_buffer_| can be null if the current thread doesn't have
@@ -1385,9 +1320,6 @@ TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
}
}
- if (thread_local_event_buffer)
- thread_local_event_buffer->ReportOverhead(now, thread_now);
-
return handle;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698