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

Side by Side Diff: src/counters.cc

Issue 2483583002: [Tracing] Fix inaccurate time accumulation in runtime statistics. (Closed)
Patch Set: Created 4 years, 1 month 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 | src/tracing/trace-event.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 "src/counters.h" 5 #include "src/counters.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 // static 295 // static
296 void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) { 296 void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) {
297 if (stats->current_timer_.Value() == timer) { 297 if (stats->current_timer_.Value() == timer) {
298 stats->current_timer_.SetValue(timer->Stop()); 298 stats->current_timer_.SetValue(timer->Stop());
299 } else { 299 } else {
300 // Must be a Threading cctest. Walk the chain of Timers to find the 300 // Must be a Threading cctest. Walk the chain of Timers to find the
301 // buried one that's leaving. We don't care about keeping nested timings 301 // buried one that's leaving. We don't care about keeping nested timings
302 // accurate, just avoid crashing by keeping the chain intact. 302 // accurate, just avoid crashing by keeping the chain intact.
303 RuntimeCallTimer* next = stats->current_timer_.Value(); 303 RuntimeCallTimer* next = stats->current_timer_.Value();
304 while (next->parent() != timer) next = next->parent(); 304 while (next && next->parent() != timer) next = next->parent();
305 if (next == nullptr) return;
305 next->parent_.SetValue(timer->Stop()); 306 next->parent_.SetValue(timer->Stop());
306 } 307 }
307 } 308 }
308 309
309 // static 310 // static
310 void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats, 311 void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats,
311 CounterId counter_id) { 312 CounterId counter_id) {
312 DCHECK_NOT_NULL(stats->current_timer_.Value()); 313 DCHECK_NOT_NULL(stats->current_timer_.Value());
313 RuntimeCallCounter* counter = &(stats->*counter_id); 314 RuntimeCallCounter* counter = &(stats->*counter_id);
314 stats->current_timer_.Value()->counter_ = counter; 315 stats->current_timer_.Value()->counter_ = counter;
(...skipping 24 matching lines...) Expand all
339 #define PRINT_COUNTER(name) entries.Add(&this->Handler_##name); 340 #define PRINT_COUNTER(name) entries.Add(&this->Handler_##name);
340 FOR_EACH_HANDLER_COUNTER(PRINT_COUNTER) 341 FOR_EACH_HANDLER_COUNTER(PRINT_COUNTER)
341 #undef PRINT_COUNTER 342 #undef PRINT_COUNTER
342 343
343 entries.Print(os); 344 entries.Print(os);
344 } 345 }
345 346
346 void RuntimeCallStats::Reset() { 347 void RuntimeCallStats::Reset() {
347 if (V8_LIKELY(FLAG_runtime_stats == 0)) return; 348 if (V8_LIKELY(FLAG_runtime_stats == 0)) return;
348 349
350 // In tracing, we only what to trace the time spent on top level trace events,
351 // if runtime counter stack is not empty, we should clear the whole runtime
352 // counter stack, and then reset counters so that we can dump counters into
353 // top level trace events accurately.
354 while (current_timer_.Value()) {
355 current_timer_.SetValue(current_timer_.Value()->Stop());
356 }
357
349 #define RESET_COUNTER(name) this->name.Reset(); 358 #define RESET_COUNTER(name) this->name.Reset();
350 FOR_EACH_MANUAL_COUNTER(RESET_COUNTER) 359 FOR_EACH_MANUAL_COUNTER(RESET_COUNTER)
351 #undef RESET_COUNTER 360 #undef RESET_COUNTER
352 361
353 #define RESET_COUNTER(name, nargs, result_size) this->Runtime_##name.Reset(); 362 #define RESET_COUNTER(name, nargs, result_size) this->Runtime_##name.Reset();
354 FOR_EACH_INTRINSIC(RESET_COUNTER) 363 FOR_EACH_INTRINSIC(RESET_COUNTER)
355 #undef RESET_COUNTER 364 #undef RESET_COUNTER
356 365
357 #define RESET_COUNTER(name) this->Builtin_##name.Reset(); 366 #define RESET_COUNTER(name) this->Builtin_##name.Reset();
358 BUILTIN_LIST_C(RESET_COUNTER) 367 BUILTIN_LIST_C(RESET_COUNTER)
359 #undef RESET_COUNTER 368 #undef RESET_COUNTER
360 369
361 #define RESET_COUNTER(name) this->API_##name.Reset(); 370 #define RESET_COUNTER(name) this->API_##name.Reset();
362 FOR_EACH_API_COUNTER(RESET_COUNTER) 371 FOR_EACH_API_COUNTER(RESET_COUNTER)
363 #undef RESET_COUNTER 372 #undef RESET_COUNTER
364 373
365 #define RESET_COUNTER(name) this->Handler_##name.Reset(); 374 #define RESET_COUNTER(name) this->Handler_##name.Reset();
366 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER) 375 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER)
367 #undef RESET_COUNTER 376 #undef RESET_COUNTER
368 377
369 in_use_ = true; 378 in_use_ = true;
370 } 379 }
371 380
372 void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) { 381 void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) {
373 if (current_timer_.Value() != nullptr) {
374 current_timer_.Value()->Elapsed();
375 }
376 #define DUMP_COUNTER(name) \ 382 #define DUMP_COUNTER(name) \
377 if (this->name.count > 0) this->name.Dump(value); 383 if (this->name.count > 0) this->name.Dump(value);
378 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER) 384 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER)
379 #undef DUMP_COUNTER 385 #undef DUMP_COUNTER
380 386
381 #define DUMP_COUNTER(name, nargs, result_size) \ 387 #define DUMP_COUNTER(name, nargs, result_size) \
382 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(value); 388 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(value);
383 FOR_EACH_INTRINSIC(DUMP_COUNTER) 389 FOR_EACH_INTRINSIC(DUMP_COUNTER)
384 #undef DUMP_COUNTER 390 #undef DUMP_COUNTER
385 391
(...skipping 10 matching lines...) Expand all
396 #define DUMP_COUNTER(name) \ 402 #define DUMP_COUNTER(name) \
397 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(value); 403 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(value);
398 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) 404 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
399 #undef DUMP_COUNTER 405 #undef DUMP_COUNTER
400 406
401 in_use_ = false; 407 in_use_ = false;
402 } 408 }
403 409
404 } // namespace internal 410 } // namespace internal
405 } // namespace v8 411 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/tracing/trace-event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698