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

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

Issue 1140843003: Reduce overhead of Chrome's ETW tracing to make it more usable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | 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_event_etw_export_win.h" 5 #include "base/trace_event/trace_event_etw_export_win.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 int num_args, 125 int num_args,
126 const char** arg_names, 126 const char** arg_names,
127 const unsigned char* arg_types, 127 const unsigned char* arg_types,
128 const unsigned long long* arg_values, 128 const unsigned long long* arg_values,
129 const scoped_refptr<ConvertableToTraceFormat>* convertable_values) { 129 const scoped_refptr<ConvertableToTraceFormat>* convertable_values) {
130 // We bail early in case exporting is disabled or no consumer is listening. 130 // We bail early in case exporting is disabled or no consumer is listening.
131 if (!GetInstance() || !GetInstance()->ETWExportEnabled_ || 131 if (!GetInstance() || !GetInstance()->ETWExportEnabled_ ||
132 !EventEnabledChromeEvent()) 132 !EventEnabledChromeEvent())
133 return; 133 return;
134 134
135 std::string phase_string; 135 const char* phase_string = nullptr;
136 // Space to store the phase identifier and null-terminator, when needed.
137 char phase_buffer[2];
136 switch (phase) { 138 switch (phase) {
137 case TRACE_EVENT_PHASE_BEGIN: 139 case TRACE_EVENT_PHASE_BEGIN:
138 phase_string = "Begin"; 140 phase_string = "Begin";
139 break; 141 break;
140 case TRACE_EVENT_PHASE_END: 142 case TRACE_EVENT_PHASE_END:
141 phase_string = "End"; 143 phase_string = "End";
142 break; 144 break;
143 case TRACE_EVENT_PHASE_COMPLETE: 145 case TRACE_EVENT_PHASE_COMPLETE:
144 phase_string = "Complete"; 146 phase_string = "Complete";
145 break; 147 break;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 case TRACE_EVENT_PHASE_CREATE_OBJECT: 190 case TRACE_EVENT_PHASE_CREATE_OBJECT:
189 phase_string = "Phase Create Object"; 191 phase_string = "Phase Create Object";
190 break; 192 break;
191 case TRACE_EVENT_PHASE_SNAPSHOT_OBJECT: 193 case TRACE_EVENT_PHASE_SNAPSHOT_OBJECT:
192 phase_string = "Phase Snapshot Object"; 194 phase_string = "Phase Snapshot Object";
193 break; 195 break;
194 case TRACE_EVENT_PHASE_DELETE_OBJECT: 196 case TRACE_EVENT_PHASE_DELETE_OBJECT:
195 phase_string = "Phase Delete Object"; 197 phase_string = "Phase Delete Object";
196 break; 198 break;
197 default: 199 default:
198 phase_string.push_back(phase); 200 phase_buffer[0] = phase;
201 phase_buffer[1] = 0;
202 phase_string = phase_buffer;
199 break; 203 break;
200 } 204 }
201 205
202 std::string arg_values_string[3]; 206 std::string arg_values_string[3];
203 for (int i = 0; i < num_args; i++) { 207 for (int i = 0; i < num_args; i++) {
204 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) { 208 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) {
205 convertable_values[i]->AppendAsTraceFormat(arg_values_string + i); 209 // Temporarily do nothing here. This function consumes 1/3 to 1/2 of
210 // *total* process CPU time when ETW tracing, and many of the strings
211 // created exceed WPA's 4094 byte limit and are shown as:
212 // "Unable to parse data".
Primiano Tucci (use gerrit) 2015/05/14 22:12:52 Can you copy and paste the (excellent) commit mess
brucedawson 2015/05/14 22:50:06 Done.
213 //convertable_values[i]->AppendAsTraceFormat(arg_values_string + i);
206 } else { 214 } else {
207 TraceEvent::TraceValue trace_event; 215 TraceEvent::TraceValue trace_event;
208 trace_event.as_uint = arg_values[i]; 216 trace_event.as_uint = arg_values[i];
209 TraceEvent::AppendValueAsJSON(arg_types[i], trace_event, 217 TraceEvent::AppendValueAsJSON(arg_types[i], trace_event,
210 arg_values_string + i); 218 arg_values_string + i);
211 } 219 }
212 } 220 }
213 221
214 EventWriteChromeEvent( 222 EventWriteChromeEvent(
215 name, phase_string.c_str(), num_args > 0 ? arg_names[0] : "", 223 name, phase_string, num_args > 0 ? arg_names[0] : "",
216 arg_values_string[0].c_str(), num_args > 1 ? arg_names[1] : "", 224 arg_values_string[0].c_str(), num_args > 1 ? arg_names[1] : "",
217 arg_values_string[1].c_str(), num_args > 2 ? arg_names[2] : "", 225 arg_values_string[1].c_str(), num_args > 2 ? arg_names[2] : "",
218 arg_values_string[2].c_str()); 226 arg_values_string[2].c_str());
219 } 227 }
220 228
221 // static 229 // static
222 void TraceEventETWExport::AddCustomEvent(const char* name, 230 void TraceEventETWExport::AddCustomEvent(const char* name,
223 char const* phase, 231 char const* phase,
224 const char* arg_name_1, 232 const char* arg_name_1,
225 const char* arg_value_1, 233 const char* arg_value_1,
226 const char* arg_name_2, 234 const char* arg_name_2,
227 const char* arg_value_2, 235 const char* arg_value_2,
228 const char* arg_name_3, 236 const char* arg_name_3,
229 const char* arg_value_3) { 237 const char* arg_value_3) {
230 if (!GetInstance() || !GetInstance()->ETWExportEnabled_ || 238 if (!GetInstance() || !GetInstance()->ETWExportEnabled_ ||
231 !EventEnabledChromeEvent()) 239 !EventEnabledChromeEvent())
232 return; 240 return;
233 241
234 EventWriteChromeEvent(name, phase, arg_name_1, arg_value_1, arg_name_2, 242 EventWriteChromeEvent(name, phase, arg_name_1, arg_value_1, arg_name_2,
235 arg_value_2, arg_name_3, arg_value_3); 243 arg_value_2, arg_name_3, arg_value_3);
236 } 244 }
237 245
238 void TraceEventETWExport::Resurrect() { 246 void TraceEventETWExport::Resurrect() {
239 StaticMemorySingletonTraits<TraceEventETWExport>::Resurrect(); 247 StaticMemorySingletonTraits<TraceEventETWExport>::Resurrect();
240 } 248 }
241 249
242 } // namespace trace_event 250 } // namespace trace_event
243 } // namespace base 251 } // namespace base
OLDNEW
« 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