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

Side by Side Diff: Source/platform/TraceEvent.h

Issue 490913002: Adding flow traces for blink scheduler events (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updates based on code review Created 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 #define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ 444 #define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
445 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ 445 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
446 category, name, id, TRACE_EVENT_FLAG_COPY, \ 446 category, name, id, TRACE_EVENT_FLAG_COPY, \
447 arg1_name, arg1_val) 447 arg1_name, arg1_val)
448 #define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ 448 #define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
449 arg2_name, arg2_val) \ 449 arg2_name, arg2_val) \
450 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ 450 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
451 category, name, id, TRACE_EVENT_FLAG_COPY, \ 451 category, name, id, TRACE_EVENT_FLAG_COPY, \
452 arg1_name, arg1_val, arg2_name, arg2_val) 452 arg1_name, arg1_val, arg2_name, arg2_val)
453 453
454
455 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2
456 // associated arguments. If the category is not enabled, then this
457 // does nothing.
458 // - category and name strings must have application lifetime (statics or
alexclarke 2014/09/01 11:24:20 |category|? and |name|?
picksi1 2014/09/01 13:33:47 You are correct, but as this code is cut-and-paste
459 // literals). They may not include " chars.
alexclarke 2014/09/01 11:24:20 inverted commas?
picksi1 2014/09/01 13:33:47 As above
460 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW
461 // events are considered to match if their category_group, name and id values
462 // all match. |id| must either be a pointer or an integer value up to 64 bits.
463 // If it's a pointer, the bits will be xored with a hash of the process ID so
464 // that the same pointer on two different processes will not collide.
465 // FLOW events are different from ASYNC events in how they are drawn by the
466 // tracing UI. A FLOW defines asynchronous data flow, such as posting a task
467 // (FLOW_BEGIN) and later executing that task (FLOW_END). Expect FLOWs to be
468 // drawn as lines or arrows from FLOW_BEGIN scopes to FLOW_END scopes. Similar
469 // to ASYNC, a FLOW can consist of multiple phases. The first phase is defined
470 // by the FLOW_BEGIN calls. Additional phases can be defined using the FLOW_STEP
471 // macros. When the operation completes, call FLOW_END. An async operation can
472 // span threads and processes, but all events in that operation must use the
473 // same |name| and |id|. Each event can have its own args.
474 #define TRACE_EVENT_FLOW_BEGIN0(category_group, name, id) \
475 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
476 category_group, name, id, TRACE_EVENT_FLAG_NONE)
477 #define TRACE_EVENT_FLOW_BEGIN1(category_group, name, id, arg1_name, arg1_val) \
478 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
479 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
480 #define TRACE_EVENT_FLOW_BEGIN2(category_group, name, id, arg1_name, arg1_val, \
481 arg2_name, arg2_val) \
482 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
483 category_group, name, id, TRACE_EVENT_FLAG_NONE, \
484 arg1_name, arg1_val, arg2_name, arg2_val)
485 #define TRACE_EVENT_COPY_FLOW_BEGIN0(category_group, name, id) \
486 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
487 category_group, name, id, TRACE_EVENT_FLAG_COPY)
488 #define TRACE_EVENT_COPY_FLOW_BEGIN1(category_group, name, id, arg1_name, \
489 arg1_val) \
490 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
491 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
492 arg1_name, arg1_val)
493 #define TRACE_EVENT_COPY_FLOW_BEGIN2(category_group, name, id, arg1_name, \
494 arg1_val, arg2_name, arg2_val) \
495 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
496 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
497 arg1_name, arg1_val, arg2_name, arg2_val)
498
499 // Records a single FLOW_STEP event for |step| immediately. If the category
500 // is not enabled, then this does nothing. The |name| and |id| must match the
501 // FLOW_BEGIN event above. The |step| param identifies this step within the
502 // async event. This should be called at the beginning of the next phase of an
503 // asynchronous operation.
504 #define TRACE_EVENT_FLOW_STEP0(category_group, name, id, step) \
505 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
506 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step)
507 #define TRACE_EVENT_FLOW_STEP1(category_group, name, id, step, \
508 arg1_name, arg1_val) \
509 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
510 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \
511 arg1_name, arg1_val)
512 #define TRACE_EVENT_COPY_FLOW_STEP0(category_group, name, id, step) \
513 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
514 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step)
515 #define TRACE_EVENT_COPY_FLOW_STEP1(category_group, name, id, step, \
516 arg1_name, arg1_val) \
517 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
518 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \
519 arg1_name, arg1_val)
520
521 // Records a single FLOW_END event for "name" immediately. If the category
522 // is not enabled, then this does nothing.
523 #define TRACE_EVENT_FLOW_END0(category_group, name, id) \
524 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
525 category_group, name, id, TRACE_EVENT_FLAG_NONE)
526 #define TRACE_EVENT_FLOW_END1(category_group, name, id, arg1_name, arg1_val) \
527 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
528 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
529 #define TRACE_EVENT_FLOW_END2(category_group, name, id, arg1_name, arg1_val, \
530 arg2_name, arg2_val) \
531 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
532 category_group, name, id, TRACE_EVENT_FLAG_NONE, \
533 arg1_name, arg1_val, arg2_name, arg2_val)
534 #define TRACE_EVENT_COPY_FLOW_END0(category_group, name, id) \
535 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
536 category_group, name, id, TRACE_EVENT_FLAG_COPY)
537 #define TRACE_EVENT_COPY_FLOW_END1(category_group, name, id, arg1_name, \
538 arg1_val) \
539 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
540 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
541 arg1_name, arg1_val)
542 #define TRACE_EVENT_COPY_FLOW_END2(category_group, name, id, arg1_name, \
543 arg1_val, arg2_name, arg2_val) \
544 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
545 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
546 arg1_name, arg1_val, arg2_name, arg2_val)
547
548
454 // Creates a scope of a sampling state with the given category and name (both mu st 549 // Creates a scope of a sampling state with the given category and name (both mu st
455 // be constant strings). These states are intended for a sampling profiler. 550 // be constant strings). These states are intended for a sampling profiler.
456 // Implementation note: we store category and name together because we don't 551 // Implementation note: we store category and name together because we don't
457 // want the inconsistency/expense of storing two pointers. 552 // want the inconsistency/expense of storing two pointers.
458 // |thread_bucket| is [0..2] and is used to statically isolate samples in one 553 // |thread_bucket| is [0..2] and is used to statically isolate samples in one
459 // thread from others. 554 // thread from others.
460 // 555 //
461 // { // The sampling state is set within this scope. 556 // { // The sampling state is set within this scope.
462 // TRACE_EVENT_SAMPLING_STATE_SCOPE_FOR_BUCKET(0, "category", "name"); 557 // TRACE_EVENT_SAMPLING_STATE_SCOPE_FOR_BUCKET(0, "category", "name");
463 // ...; 558 // ...;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') 736 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S')
642 #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T') 737 #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T')
643 #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p') 738 #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p')
644 #define TRACE_EVENT_PHASE_ASYNC_END ('F') 739 #define TRACE_EVENT_PHASE_ASYNC_END ('F')
645 #define TRACE_EVENT_PHASE_METADATA ('M') 740 #define TRACE_EVENT_PHASE_METADATA ('M')
646 #define TRACE_EVENT_PHASE_COUNTER ('C') 741 #define TRACE_EVENT_PHASE_COUNTER ('C')
647 #define TRACE_EVENT_PHASE_SAMPLE ('P') 742 #define TRACE_EVENT_PHASE_SAMPLE ('P')
648 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') 743 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N')
649 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O') 744 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O')
650 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') 745 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D')
746 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s')
747 #define TRACE_EVENT_PHASE_FLOW_STEP ('t')
748 #define TRACE_EVENT_PHASE_FLOW_END ('f')
651 749
652 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. 750 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
653 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0)) 751 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0))
654 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0)) 752 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0))
655 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1)) 753 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1))
656 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2)) 754 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2))
657 755
658 // Type values for identifying types in the TraceValue union. 756 // Type values for identifying types in the TraceValue union.
659 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) 757 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
660 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) 758 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 const char* m_categoryGroup; 1103 const char* m_categoryGroup;
1006 const char* m_name; 1104 const char* m_name;
1007 IDType m_id; 1105 IDType m_id;
1008 }; 1106 };
1009 1107
1010 } // namespace TraceEvent 1108 } // namespace TraceEvent
1011 1109
1012 } // namespace blink 1110 } // namespace blink
1013 1111
1014 #endif 1112 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/platform/blink_platform.gypi » ('j') | Source/platform/scheduler/Scheduler.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698