• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015 The Chromium Authors
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;
8option java_package = "org.chromium.components.metrics";
9
10option java_outer_classname = "CallStackProfileProtos";
11
12package metrics;
13
14import "execution_context.proto";
15
16// Call stack sample data for a given profiling session.
17// Next tag: 11
18message CallStackProfile {
19  // Uniquely identifies a module.
20  message ModuleIdentifier {
21    // A hash that uniquely identifies a particular program version with high
22    // probability. This is parsed from headers of the loaded module.
23    // For binaries generated by GNU tools:
24    //   Contents of the .note.gnu.build-id field.
25    // On Windows:
26    //   GUID + AGE in the debug image headers of a module.
27    optional string build_id = 1;
28
29    // MD5Sum Prefix of the module name. This is the same hashing scheme as used
30    // to hash UMA histogram names.
31    optional fixed64 name_md5_prefix = 2;
32  }
33
34  // Describes a location within executable code.
35  message Location {
36    // Instruction pointer subtracted by module base.
37    optional uint64 address = 1;
38
39    // Index to the module identifier in |module_ids| of CallStackProfile.
40    optional int32 module_id_index = 2;
41
42    // Currently only used for Java function names. In cases where this is
43    // available, this should be used instead of the address.
44    optional string function_name = 3;
45  }
46
47  // The sampled call stack.
48  message Stack {
49    // The frames in the callstack. The frame[0] entry represents the call on
50    // the top of the stack.
51    repeated Location frame = 1;
52  }
53
54  // An item of metadata associated with either the entire profile or a single
55  // sample.
56  message MetadataItem {
57    // Index of the hash of the metadata name.
58    optional int32 name_hash_index = 1;
59
60    // Optional user-specified key value. Absent if unspecified.
61    optional sint64 key = 3;
62
63    // Value for the item. An absent value indicates the metadata has become
64    // unset since the previous StackSample.
65    optional sint64 value = 2;
66  }
67
68  // Backtrace of locations of async execution requests (e.g. task postings, IPC
69  // message sending, requests over mojo) that led to the current task
70  // execution. Note that these are saved in a fixed length buffer on the client
71  // which as of 2018/08/14 includes only the most recent four entries.
72  message AsyncBacktrace {
73    // The locations saved in the backtrace, with the most recent in
74    // location[0]. Empty if the work was not tied to an async execution request
75    // -- for example, handling a mouse event.
76    repeated Location location = 1;
77  }
78
79  // Deprecated version of a sample consisting of one or more callstacks with
80  // the same stack frames and instruction pointers. Deprecated as of
81  // 2018/08/14.
82  message Sample {
83    // The callstack. Sample.frame[0] represents the call on the top of the
84    // stack.
85    repeated Location frame = 1;
86
87    // Number of times this stack signature occurs.
88    optional int64 count = 2;
89
90    // This repeating field indicates the current phase of the system such as
91    // whether it is in startup, general operation, or shutdown. The first
92    // Sample of a CallStackProfile will list all phases that have been reached;
93    // later samples will list only the new phases that occurred since the
94    // previous one.
95    repeated ProcessPhase process_phase = 3;
96  }
97
98  // A sampled stack, along with associated metadata.
99  message StackSample {
100    // Index into the profile's repeated |stack| field for the stack
101    // corresponding to this sample.
102    optional int32 stack_index = 1;
103
104    // Sample time relative to the first sample.
105    optional int32 sample_time_offset_ms = 2;
106
107    // True if this sample is executing the same item of work (task, event) as
108    // the last sample.
109    optional bool continued_work = 3;
110
111    // Index of the backtrace in the profile of posted task locations that led
112    // to this task execution.
113    optional int32 async_backtrace_index = 4;
114
115    // Metadata items associated with the sample. To minimize memory usage,
116    // metadata items are specified only when their values change from the
117    // previous sample. Items are not guaranteed to be in a particular order.
118    repeated MetadataItem metadata = 5;
119
120    // Weight of the sample. When omitted the sample is presumed to have
121    // a weight of 1.
122    // Not currently used for CPU profiles.
123    // For heap profiles it represents the total number of bytes associated with
124    // the StackSample record.
125    optional int64 weight = 6;
126
127    // Number of events associated with the sample. When omitted the default
128    // value of 1 should be used.
129    // Not currently used for CPU profiles.
130    // For heap profiles it represents the number of allocations associated with
131    // the StackSample record. The following relation holds:
132    //   allocation_size * count == weight.
133    optional int64 count = 7 [default = 1];
134  }
135
136  // The previous sample encoding. Deprecated 2018/08/04 in favor of
137  // stack_sample.
138  repeated Sample DEPRECATED_sample = 1 [deprecated = true];
139
140  // List of module ids found in this sample.
141  repeated ModuleIdentifier module_id = 2;
142
143  // Metadata name hashes used in this profile. Recorded global to the profile
144  // to minimize per-sample memory usage.
145  repeated fixed64 metadata_name_hash = 5;
146
147  // Metadata global to the profile.
148  repeated MetadataItem profile_metadata = 6;
149
150  // The distinct async backtraces for the samples.
151  repeated AsyncBacktrace async_backtrace = 7;
152
153  // The distinct stacks for the samples.
154  repeated Stack stack = 8;
155
156  // The stack samples collected for this profile.
157  repeated StackSample stack_sample = 9;
158
159  // Time of the profile relative to the start of the process being profiled.
160  // For CPU profiles, this is the time of the first sample. For Heap profiles
161  // whose samples don't have defined times, it is the time the profile is
162  // collected.
163  optional int64 profile_time_offset_ms = 10;
164
165  // Duration of this profile.
166  optional int32 profile_duration_ms = 3;
167
168  // Time between samples.
169  optional int32 sampling_period_ms = 4;
170}
171