1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5syntax = "proto2";
6
7option optimize_for = LITE_RUNTIME;
8
9option java_outer_classname = "SampledProfileProtos";
10option java_package = "org.chromium.components.metrics";
11
12package metrics;
13
14import "call_stack_profile.proto";
15import "execution_context.proto";
16import "perf_data.proto";
17import "perf_stat.proto";
18
19// Protocol buffer for collected sample-based profiling data.
20// Contains the parameters and data from a single profile collection event.
21
22// Next tag: 16
23message SampledProfile {
24  // Indicates the event that triggered this collection.
25  enum TriggerEvent {
26    UNKNOWN_TRIGGER_EVENT = 0;
27
28    // The profile was triggered by periodic sampling.  Periodically sampled
29    // profiles are collected once per uniformly sized period interval.  Within
30    // each interval, the sampled data is collected at a random time.  For
31    // example, if the interval is 60 s, then data would be collected at a
32    // random point in each of the intervals [0, 60 s), [60 s, 120 s), etc.
33    PERIODIC_COLLECTION = 1;
34
35    // The profile was collected upon resume from suspend.
36    RESUME_FROM_SUSPEND = 2;
37
38    // The profile was collected upon restoring a previous session.
39    RESTORE_SESSION = 3;
40
41    // The profile was collected at process startup.
42    PROCESS_STARTUP = 4;
43
44    // The profile was collected after jank was detected while executing a task.
45    JANKY_TASK = 5;
46
47    // The profile was collected after a thread was determined to be hung.
48    THREAD_HUNG = 6;
49
50    // The heap profile was triggered by periodic sampling. The time intervals
51    // between trigger events conform to the Poisson process with certain mean
52    // interval between collections.
53    PERIODIC_HEAP_COLLECTION = 7;
54  }
55  optional TriggerEvent trigger_event = 1;
56
57  // The process in which the profile was collected.
58  optional Process process = 11;
59
60  // The thread in which the profile was collected.
61  optional Thread thread = 12;
62
63  // Map of Chrome PIDs running on the system when the profile was collected.
64  // Each Chrome PID is mapped to its process type.
65  // This field and the below thread_types field assume that the PID/TID
66  // information are collected in a short duration for a single session such
67  // that, the PID/TID reuse is highly unlikely.
68  // The information from these two fields is used to map chrome samples
69  // collected for a specific PID/TID to the corresponding process type and
70  // thread type.
71  map<uint32, Process> process_types = 13;
72
73  // Map of Chrome TIDs running on the system when the profile was collected.
74  // Each Chrome TID is mapped to its thread type.
75  map<uint32, Thread> thread_types = 14;
76
77  // Fields 2-3: Time durations are given in ticks, and represent system uptime
78  // rather than wall time.
79
80  // Time after system boot when the collection took place, in milliseconds.
81  optional int64 ms_after_boot = 2;
82
83  // Time after last login when the collection took place, in milliseconds.
84  optional int64 ms_after_login = 3;
85
86  // The duration for which the machine was suspended prior to collecting the
87  // sampled profile. Only set when |trigger_event| is RESUME_FROM_SUSPEND.
88  optional int64 suspend_duration_ms = 5;
89
90  // Number of milliseconds after a resume that profile was collected. Only set
91  // when |trigger_event| is RESUME_FROM_SUSPEND.
92  optional int64 ms_after_resume = 6;
93
94  // Number of tabs restored during a session restore. Only set when
95  // |trigger_event| is RESTORE_SESSION.
96  optional int32 num_tabs_restored = 7;
97
98  // Number of milliseconds after a session restore that a profile was
99  // collected. Only set when |trigger_event| is RESTORE_SESSION.
100  optional int64 ms_after_restore = 8;
101
102  // Sampled profile data collected from Linux perf tool.
103  optional PerfDataProto perf_data = 4;
104
105  // Sampled profile data collected by periodic sampling of call stacks.
106  optional CallStackProfile call_stack_profile = 9;
107
108  // Perf counter data collected using "perf stat".
109  optional PerfStatProto perf_stat = 10;
110
111  // The maximum frequency in MHz reported for each logical CPU on the device.
112  // This is a repeated field, where entry 0 corresponds to core 0, entry 1 to
113  // core 1, and so on. The field is optional and populated only for metrics
114  // that can use the max frequency to compute a CPU utilization metric, e.g.
115  // when measuring CPU cycles.
116  repeated uint32 cpu_max_frequency_mhz = 15;
117}
118