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

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

Issue 1850603002: [tracing] Use trace event profiling for heap profiling Base URL: https://chromium.googlesource.com/chromium/src.git@all_categories
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 | « base/trace_event/trace_event.h ('k') | gin/public/v8_platform.h » ('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 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 #include <utility> 9 #include <utility>
10 10
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 category_group_enabled, name, scope, id, num_args, arg_names, 1316 category_group_enabled, name, scope, id, num_args, arg_names,
1317 arg_types, arg_values, flags); 1317 arg_types, arg_values, flags);
1318 } 1318 }
1319 } 1319 }
1320 1320
1321 // TODO(primiano): Add support for events with copied name crbug.com/581078 1321 // TODO(primiano): Add support for events with copied name crbug.com/581078
1322 // TODO(ssid): Move push to ScopedTracer after adding profiling support in 1322 // TODO(ssid): Move push to ScopedTracer after adding profiling support in
1323 // Blink and skia crbug.com/598426. 1323 // Blink and skia crbug.com/598426.
1324 if (!(flags & TRACE_EVENT_FLAG_COPY)) { 1324 if (!(flags & TRACE_EVENT_FLAG_COPY)) {
1325 if (AllocationContextTracker::capture_enabled()) { 1325 if (AllocationContextTracker::capture_enabled()) {
1326 if (phase == TRACE_EVENT_PHASE_BEGIN || 1326 if (phase == TRACE_EVENT_PHASE_BEGIN) {
1327 phase == TRACE_EVENT_PHASE_COMPLETE) {
1328 AllocationContextTracker::GetInstanceForCurrentThread() 1327 AllocationContextTracker::GetInstanceForCurrentThread()
1329 ->PushPseudoStackFrame(name); 1328 ->PushPseudoStackFrame(name);
1330 } else if (phase == TRACE_EVENT_PHASE_END) { 1329 } else if (phase == TRACE_EVENT_PHASE_END) {
1331 // The pop for |TRACE_EVENT_PHASE_COMPLETE| events
1332 // is in |TraceLog::UpdateTraceEventDuration|.
1333 AllocationContextTracker::GetInstanceForCurrentThread() 1330 AllocationContextTracker::GetInstanceForCurrentThread()
1334 ->PopPseudoStackFrame(name); 1331 ->PopPseudoStackFrame(name);
1335 } 1332 }
1336 } 1333 }
1337 } 1334 }
1338 1335
1339 return handle; 1336 return handle;
1340 } 1337 }
1341 1338
1342 void TraceLog::AddMetadataEvent( 1339 void TraceLog::AddMetadataEvent(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 trace_event->UpdateDuration(now, thread_now); 1443 trace_event->UpdateDuration(now, thread_now);
1447 #if defined(OS_ANDROID) 1444 #if defined(OS_ANDROID)
1448 trace_event->SendToATrace(); 1445 trace_event->SendToATrace();
1449 #endif 1446 #endif
1450 } 1447 }
1451 1448
1452 if (trace_options() & kInternalEchoToConsole) { 1449 if (trace_options() & kInternalEchoToConsole) {
1453 console_message = 1450 console_message =
1454 EventToConsoleMessage(TRACE_EVENT_PHASE_END, now, trace_event); 1451 EventToConsoleMessage(TRACE_EVENT_PHASE_END, now, trace_event);
1455 } 1452 }
1456
1457 if (base::trace_event::AllocationContextTracker::capture_enabled()) {
1458 // The corresponding push is in |AddTraceEventWithThreadIdAndTimestamp|.
1459 base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread()
1460 ->PopPseudoStackFrame(name);
1461 }
1462 } 1453 }
1463 1454
1464 if (console_message.size()) 1455 if (console_message.size())
1465 LOG(ERROR) << console_message; 1456 LOG(ERROR) << console_message;
1466 1457
1467 if (category_group_enabled_local & ENABLED_FOR_EVENT_CALLBACK) { 1458 if (category_group_enabled_local & ENABLED_FOR_EVENT_CALLBACK) {
1468 EventCallback event_callback = reinterpret_cast<EventCallback>( 1459 EventCallback event_callback = reinterpret_cast<EventCallback>(
1469 subtle::NoBarrier_Load(&event_callback_)); 1460 subtle::NoBarrier_Load(&event_callback_));
1470 if (event_callback) { 1461 if (event_callback) {
1471 event_callback( 1462 event_callback(
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 ScopedTraceBinaryEfficient::ScopedTraceBinaryEfficient( 1708 ScopedTraceBinaryEfficient::ScopedTraceBinaryEfficient(
1718 const char* category_group, 1709 const char* category_group,
1719 const char* name) { 1710 const char* name) {
1720 // The single atom works because for now the category_group can only be "gpu". 1711 // The single atom works because for now the category_group can only be "gpu".
1721 DCHECK_EQ(strcmp(category_group, "gpu"), 0); 1712 DCHECK_EQ(strcmp(category_group, "gpu"), 0);
1722 static TRACE_EVENT_API_ATOMIC_WORD atomic = 0; 1713 static TRACE_EVENT_API_ATOMIC_WORD atomic = 0;
1723 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES( 1714 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES(
1724 category_group, atomic, category_group_enabled_); 1715 category_group, atomic, category_group_enabled_);
1725 name_ = name; 1716 name_ = name;
1726 if (*category_group_enabled_ & 1717 if (*category_group_enabled_ &
1727 base::trace_event::TraceLog::ENABLED_FOR_NON_PROFILING_MODE) { 1718 (base::trace_event::TraceLog::ENABLED_FOR_HEAP_PROFILING |
1728 event_handle_ = 1719 base::trace_event::TraceLog::ENABLED_FOR_NON_PROFILING_MODE)) {
1729 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1720 if (*category_group_enabled_ &
1730 TRACE_EVENT_PHASE_COMPLETE, 1721 base::trace_event::TraceLog::ENABLED_FOR_HEAP_PROFILING) {
1731 category_group_enabled_, 1722 base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread()
1732 name, 1723 ->PushPseudoStackFrame(name);
1733 trace_event_internal::kGlobalScope, // scope 1724 }
1734 trace_event_internal::kNoId, // id 1725 if (*category_group_enabled_ &
1735 static_cast<int>(base::PlatformThread::CurrentId()), // thread_id 1726 base::trace_event::TraceLog::ENABLED_FOR_NON_PROFILING_MODE) {
1736 base::TimeTicks::Now(), 1727 event_handle_ =
1737 trace_event_internal::kZeroNumArgs, 1728 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1738 nullptr, 1729 TRACE_EVENT_PHASE_COMPLETE, category_group_enabled_, name,
1739 nullptr, 1730 trace_event_internal::kGlobalScope, // scope
1740 nullptr, 1731 trace_event_internal::kNoId, // id
1741 nullptr, 1732 static_cast<int>(base::PlatformThread::CurrentId()), // thread_id
1742 TRACE_EVENT_FLAG_NONE); 1733 base::TimeTicks::Now(), trace_event_internal::kZeroNumArgs,
1734 nullptr, nullptr, nullptr, nullptr, TRACE_EVENT_FLAG_NONE);
1735 }
1743 } 1736 }
1744 } 1737 }
1745 1738
1746 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1739 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1747 if (*category_group_enabled_ & 1740 if (*category_group_enabled_ &
1748 base::trace_event::TraceLog::ENABLED_FOR_NON_PROFILING_MODE) { 1741 (base::trace_event::TraceLog::ENABLED_FOR_HEAP_PROFILING |
1749 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1742 base::trace_event::TraceLog::ENABLED_FOR_NON_PROFILING_MODE)) {
1750 event_handle_); 1743 if (*category_group_enabled_ &
1744 base::trace_event::TraceLog::ENABLED_FOR_HEAP_PROFILING) {
1745 base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread()
1746 ->PopPseudoStackFrame(name_);
1747 }
1748 if (*category_group_enabled_ &
1749 base::trace_event::TraceLog::ENABLED_FOR_NON_PROFILING_MODE) {
1750 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
1751 name_, event_handle_);
1752 }
1751 } 1753 }
1752 } 1754 }
1753 1755
1754 } // namespace trace_event_internal 1756 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/trace_event/trace_event.h ('k') | gin/public/v8_platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698