Commit 039bf813 authored by xunjieli's avatar xunjieli Committed by Commit bot

This CL adds NESTABLE_ASYNC APIs to tracing.

This is a part of the effort to get NetLog data into
tracing. The reason to add these new APIs for logging
NetLog events is that NetLog events are logged
asynchronously and can have multiple nested levels of
inner events. The current ASYNC_STEP APIs only allow
one level of nested events.

In general, it would be useful if we could can have an
async event broken into sub steps, each sub step has an
explicitly defined beginning and end within that overall
event, with additional arguments.

Design Doc:
https://docs.google.com/document/d/1Z2uqj59UEts5IiXX78mkdU4kd6e7kE3JUKPoDK97bVs/edit?usp=sharing
BUG=399701

Review URL: https://codereview.chromium.org/536503002

Cr-Commit-Position: refs/heads/master@{#293940}
parent 0f21991b
...@@ -510,7 +510,9 @@ ...@@ -510,7 +510,9 @@
value1_name, static_cast<int>(value1_val), \ value1_name, static_cast<int>(value1_val), \
value2_name, static_cast<int>(value2_val)) value2_name, static_cast<int>(value2_val))
// ASYNC_STEP_* APIs should be only used by legacy code. New code should
// consider using NESTABLE_ASYNC_* APIs to describe substeps within an async
// event.
// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
// associated arguments. If the category is not enabled, then this // associated arguments. If the category is not enabled, then this
// does nothing. // does nothing.
...@@ -634,6 +636,45 @@ ...@@ -634,6 +636,45 @@
static_cast<int>(base::PlatformThread::CurrentId()), \ static_cast<int>(base::PlatformThread::CurrentId()), \
timestamp, TRACE_EVENT_FLAG_NONE) timestamp, TRACE_EVENT_FLAG_NONE)
// NESTABLE_ASYNC_* APIs are used to describe an async operation, which can
// be nested within a NESTABLE_ASYNC event and/or have inner NESTABLE_ASYNC
// events.
// - category and name strings must have application lifetime (statics or
// literals). They may not include " chars.
// - |id| is used to match the NESTABLE_ASYNC_BEGIN event with the
// NESTABLE_ASYNC_END event. Events are considered to match if their
// category_group, name and id values all match. |id| must either be a
// pointer or an integer value up to 64 bits. If it's a pointer, the bits
// will be xored with a hash of the process ID so that the same pointer on two
// different processes will not collide.
//
// Unmatched NESTABLE_ASYNC_END event will be parsed as an instant event,
// and unmatched NESTABLE_ASYNC_BEGIN event will be parsed as an event that
// ends at the last NESTABLE_ASYNC_END event of that |id|.
// Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with 2
// associated arguments. If the category is not enabled, then this does nothing.
#define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
arg1_val, arg2_name, arg2_val) \
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
arg2_name, arg2_val)
// Records a single NESTABLE_ASYNC_END event called "name" immediately, with 2
// associated arguments. If the category is not enabled, then this does nothing.
#define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \
arg1_val, arg2_name, arg2_val) \
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
arg2_name, arg2_val)
// Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately,
// with 2 associated arguments. If the category is not enabled, then this
// does nothing.
#define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(category_group, name, id, \
arg1_name, arg1_val, arg2_name, arg2_val) \
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \
category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
arg2_name, arg2_val)
// Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2
// associated arguments. If the category is not enabled, then this // associated arguments. If the category is not enabled, then this
// does nothing. // does nothing.
...@@ -963,6 +1004,9 @@ TRACE_EVENT_API_CLASS_EXPORT extern \ ...@@ -963,6 +1004,9 @@ TRACE_EVENT_API_CLASS_EXPORT extern \
#define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T') #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T')
#define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p') #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p')
#define TRACE_EVENT_PHASE_ASYNC_END ('F') #define TRACE_EVENT_PHASE_ASYNC_END ('F')
#define TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN ('b')
#define TRACE_EVENT_PHASE_NESTABLE_ASYNC_END ('e')
#define TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT ('n')
#define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s')
#define TRACE_EVENT_PHASE_FLOW_STEP ('t') #define TRACE_EVENT_PHASE_FLOW_STEP ('t')
#define TRACE_EVENT_PHASE_FLOW_END ('f') #define TRACE_EVENT_PHASE_FLOW_END ('f')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment