Commit 923d1c42 authored by Eric Seckler's avatar Eric Seckler Committed by Commit Bot

tracing: Switch to counter tracks for thread time / instruction count

Encode thread time + instruction count using counter tracks in the
proto format. This should also pave the way to add more counters in the
future.

Bug: 928738
Change-Id: I6524aa99d630f7f156606cdde9f0f50a7735c31a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2139822
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757818}
parent 11de47f6
......@@ -135,6 +135,11 @@ constexpr MessageInfo kChromeCompositorSchedulerState = {
constexpr int kChromeUserEventIndices[] = {2, -1};
constexpr MessageInfo kChromeUserEvent = {kChromeUserEventIndices, nullptr};
// Proto Message: ChromeKeyedService
constexpr int kChromeKeyedServiceIndices[] = {1, -1};
constexpr MessageInfo kChromeKeyedService = {kChromeKeyedServiceIndices,
nullptr};
// Proto Message: ChromeLegacyIpc
constexpr int kChromeLegacyIpcIndices[] = {1, 2, -1};
constexpr MessageInfo kChromeLegacyIpc = {kChromeLegacyIpcIndices, nullptr};
......@@ -146,25 +151,18 @@ constexpr MessageInfo kChromeHistogramSample = {kChromeHistogramSampleIndices,
// Proto Message: ComponentInfo
constexpr int kComponentInfoIndices[] = {1, 2, -1};
constexpr MessageInfo kComponentInfo = {
kComponentInfoIndices,
nullptr};
constexpr MessageInfo kComponentInfo = {kComponentInfoIndices, nullptr};
// Proto Message: ChromeLatencyInfo
constexpr int kChromeLatencyInfoIndices[] = {1, 2, 3, 4, 5, -1};
constexpr MessageInfo const* kChromeLatencyInfoComplexMessages[] = {
nullptr,
nullptr,
nullptr,
&kComponentInfo,
nullptr};
nullptr, nullptr, nullptr, &kComponentInfo, nullptr};
constexpr MessageInfo kChromeLatencyInfo = {kChromeLatencyInfoIndices,
kChromeLatencyInfoComplexMessages};
// Proto Message: TrackEvent
// EDIT: Manually whitelisted: 29 (chrome_latency_info).
constexpr int kTrackEventIndices[] = {1, 2, 3, 5, 6, 9, 10, 11,
16, 17, 24, 25, 27, 28, 29, -1};
constexpr int kTrackEventIndices[] = {1, 2, 3, 5, 6, 9, 10, 11, 12, 16,
17, 24, 25, 26, 27, 28, 29, 30, 31, -1};
constexpr MessageInfo const* kTrackEventComplexMessages[] = {
nullptr,
nullptr,
......@@ -176,11 +174,15 @@ constexpr MessageInfo const* kTrackEventComplexMessages[] = {
nullptr,
nullptr,
nullptr,
nullptr,
&kChromeCompositorSchedulerState,
&kChromeUserEvent,
&kChromeKeyedService,
&kChromeLegacyIpc,
&kChromeHistogramSample,
&kChromeLatencyInfo};
&kChromeLatencyInfo,
nullptr,
nullptr};
constexpr MessageInfo kTrackEvent = {kTrackEventIndices,
kTrackEventComplexMessages};
......@@ -303,7 +305,8 @@ constexpr MessageInfo kHeapGraph = {kHeapGraphIndices,
kHeapGraphComplexMessages};
// Proto Message: TrackEventDefaults
constexpr int kTrackEventDefaultsIndices[] = {11, -1};
// Manually whitelisted: 31.
constexpr int kTrackEventDefaultsIndices[] = {11, 31, -1};
constexpr MessageInfo kTrackEventDefaults = {kTrackEventDefaultsIndices,
nullptr};
......@@ -324,11 +327,20 @@ constexpr int kChromeThreadDescriptorIndices[] = {1, 2, -1};
constexpr MessageInfo kChromeThreadDescriptor = {kChromeThreadDescriptorIndices,
nullptr};
// Proto Message: CounterDescriptor
constexpr int kCounterDescriptorIndices[] = {1, 3, 4, 5, -1};
constexpr MessageInfo kCounterDescriptor = {kCounterDescriptorIndices, nullptr};
// Proto Message: TrackDescriptor
constexpr int kTrackDescriptorIndices[] = {1, 3, 4, 5, 6, 7, -1};
constexpr int kTrackDescriptorIndices[] = {1, 3, 4, 5, 6, 7, 8, -1};
constexpr MessageInfo const* kTrackDescriptorComplexMessages[] = {
nullptr, &kProcessDescriptor, &kThreadDescriptor,
nullptr, &kChromeProcessDescriptor, &kChromeThreadDescriptor};
nullptr,
&kProcessDescriptor,
&kThreadDescriptor,
nullptr,
&kChromeProcessDescriptor,
&kChromeThreadDescriptor,
&kCounterDescriptor};
constexpr MessageInfo kTrackDescriptor = {kTrackDescriptorIndices,
kTrackDescriptorComplexMessages};
......
......@@ -22,6 +22,7 @@
#include "third_party/perfetto/include/perfetto/tracing/event_context.h"
#include "third_party/perfetto/protos/perfetto/trace/interned_data/interned_data.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_thread_descriptor.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/counter_descriptor.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/track_event.pbzero.h"
namespace tracing {
......@@ -125,12 +126,16 @@ class COMPONENT_EXPORT(TRACING_CPP) TrackEventThreadLocalEventSink
private:
static constexpr size_t kMaxCompleteEventDepth = 30;
void EmitTrackDescriptor(
protozero::MessageHandle<perfetto::protos::pbzero::TracePacket>*
trace_packet,
base::trace_event::TraceEvent* trace_event,
void EmitThreadTrackDescriptor(base::trace_event::TraceEvent* trace_event,
base::TimeTicks timestamp,
const char* maybe_new_name = nullptr);
void EmitCounterTrackDescriptor(
base::TimeTicks timestamp,
const char* maybe_new_name = nullptr);
uint64_t thread_track_uuid,
uint64_t counter_track_uuid_bit,
perfetto::protos::pbzero::CounterDescriptor::BuiltinCounterType
counter_type,
uint64_t unit_multiplier = 0u);
void DoResetIncrementalState(base::trace_event::TraceEvent* trace_event,
bool explicit_timestamp);
void SetPacketTimestamp(
......
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