Skip to content

Commit 1826dea

Browse files
committed
Add proto file
1 parent 500d4a4 commit 1826dea

File tree

7 files changed

+486
-0
lines changed

7 files changed

+486
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea/
12
/target/
23
Cargo.lock
34
**/*.rs.bk

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ reqwest = { version = "0.11", features = ["blocking", "rustls-tls-native-roots"]
5858
url = "2.2.2"
5959
libflate = "1.2.0"
6060
libc = "^0.2.124"
61+
prost = "0.10"
6162

6263
[dev-dependencies]
6364
tokio = { version = "1.18", features = ["full"] }

pyroscope_cli/Cargo.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ pub mod timer;
5252

5353
// Private modules
5454
mod utils;
55+
mod pprof;

src/pprof/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod pprof;
2+
pub use pprof::*;

src/pprof/pprof.proto

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
// Copyright 2016 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Profile is a common stacktrace profile format.
16+
//
17+
// Measurements represented with this format should follow the
18+
// following conventions:
19+
//
20+
// - Consumers should treat unset optional fields as if they had been
21+
// set with their default value.
22+
//
23+
// - When possible, measurements should be stored in "unsampled" form
24+
// that is most useful to humans. There should be enough
25+
// information present to determine the original sampled values.
26+
//
27+
// - On-disk, the serialized proto must be gzip-compressed.
28+
//
29+
// - The profile is represented as a set of samples, where each sample
30+
// references a sequence of locations, and where each location belongs
31+
// to a mapping.
32+
// - There is a N->1 relationship from sample.location_id entries to
33+
// locations. For every sample.location_id entry there must be a
34+
// unique Location with that id.
35+
// - There is an optional N->1 relationship from locations to
36+
// mappings. For every nonzero Location.mapping_id there must be a
37+
// unique Mapping with that id.
38+
39+
syntax = "proto3";
40+
41+
//package perftools.profiles;
42+
package pprof;
43+
44+
option java_package = "com.google.perftools.profiles";
45+
option java_outer_classname = "ProfileProto";
46+
47+
message Profile {
48+
// A description of the samples associated with each Sample.value.
49+
// For a cpu profile this might be:
50+
// [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]]
51+
// For a heap profile, this might be:
52+
// [["allocations","count"], ["space","bytes"]],
53+
// If one of the values represents the number of events represented
54+
// by the sample, by convention it should be at index 0 and use
55+
// sample_type.unit == "count".
56+
repeated ValueType sample_type = 1;
57+
// The set of samples recorded in this profile.
58+
repeated Sample sample = 2;
59+
// Mapping from address ranges to the image/binary/library mapped
60+
// into that address range. mapping[0] will be the main binary.
61+
repeated Mapping mapping = 3;
62+
// Useful program location
63+
repeated Location location = 4;
64+
// Functions referenced by locations
65+
repeated Function function = 5;
66+
// A common table for strings referenced by various messages.
67+
// string_table[0] must always be "".
68+
repeated string string_table = 6;
69+
// frames with Function.function_name fully matching the following
70+
// regexp will be dropped from the samples, along with their successors.
71+
int64 drop_frames = 7; // Index into string table.
72+
// frames with Function.function_name fully matching the following
73+
// regexp will be kept, even if it matches drop_frames.
74+
int64 keep_frames = 8; // Index into string table.
75+
76+
// The following fields are informational, do not affect
77+
// interpretation of results.
78+
79+
// Time of collection (UTC) represented as nanoseconds past the epoch.
80+
int64 time_nanos = 9;
81+
// Duration of the profile, if a duration makes sense.
82+
int64 duration_nanos = 10;
83+
// The kind of events between sampled ocurrences.
84+
// e.g [ "cpu","cycles" ] or [ "heap","bytes" ]
85+
ValueType period_type = 11;
86+
// The number of events between sampled occurrences.
87+
int64 period = 12;
88+
// Freeform text associated to the profile.
89+
repeated int64 comment = 13; // Indices into string table.
90+
// Index into the string table of the type of the preferred sample
91+
// value. If unset, clients should default to the last sample value.
92+
int64 default_sample_type = 14;
93+
}
94+
95+
// ValueType describes the semantics and measurement units of a value.
96+
message ValueType {
97+
int64 type = 1; // Index into string table.
98+
int64 unit = 2; // Index into string table.
99+
}
100+
101+
// Each Sample records values encountered in some program
102+
// context. The program context is typically a stack trace, perhaps
103+
// augmented with auxiliary information like the thread-id, some
104+
// indicator of a higher level request being handled etc.
105+
message Sample {
106+
// The ids recorded here correspond to a Profile.location.id.
107+
// The leaf is at location_id[0].
108+
repeated uint64 location_id = 1;
109+
// The type and unit of each value is defined by the corresponding
110+
// entry in Profile.sample_type. All samples must have the same
111+
// number of values, the same as the length of Profile.sample_type.
112+
// When aggregating multiple samples into a single sample, the
113+
// result has a list of values that is the element-wise sum of the
114+
// lists of the originals.
115+
repeated int64 value = 2;
116+
// label includes additional context for this sample. It can include
117+
// things like a thread id, allocation size, etc
118+
repeated Label label = 3;
119+
}
120+
121+
message Label {
122+
int64 key = 1; // Index into string table
123+
124+
// At most one of the following must be present
125+
int64 str = 2; // Index into string table
126+
int64 num = 3;
127+
128+
// Should only be present when num is present.
129+
// Specifies the units of num.
130+
// Use arbitrary string (for example, "requests") as a custom count unit.
131+
// If no unit is specified, consumer may apply heuristic to deduce the unit.
132+
// Consumers may also interpret units like "bytes" and "kilobytes" as memory
133+
// units and units like "seconds" and "nanoseconds" as time units,
134+
// and apply appropriate unit conversions to these.
135+
int64 num_unit = 4; // Index into string table
136+
}
137+
138+
message Mapping {
139+
// Unique nonzero id for the mapping.
140+
uint64 id = 1;
141+
// Address at which the binary (or DLL) is loaded into memory.
142+
uint64 memory_start = 2;
143+
// The limit of the address range occupied by this mapping.
144+
uint64 memory_limit = 3;
145+
// Offset in the binary that corresponds to the first mapped address.
146+
uint64 file_offset = 4;
147+
// The object this entry is loaded from. This can be a filename on
148+
// disk for the main binary and shared libraries, or virtual
149+
// abstractions like "[vdso]".
150+
int64 filename = 5; // Index into string table
151+
// A string that uniquely identifies a particular program version
152+
// with high probability. E.g., for binaries generated by GNU tools,
153+
// it could be the contents of the .note.gnu.build-id field.
154+
int64 build_id = 6; // Index into string table
155+
156+
// The following fields indicate the resolution of symbolic info.
157+
bool has_functions = 7;
158+
bool has_filenames = 8;
159+
bool has_line_numbers = 9;
160+
bool has_inline_frames = 10;
161+
}
162+
163+
// Describes function and line table debug information.
164+
message Location {
165+
// Unique nonzero id for the location. A profile could use
166+
// instruction addresses or any integer sequence as ids.
167+
uint64 id = 1;
168+
// The id of the corresponding profile.Mapping for this location.
169+
// It can be unset if the mapping is unknown or not applicable for
170+
// this profile type.
171+
uint64 mapping_id = 2;
172+
// The instruction address for this location, if available. It
173+
// should be within [Mapping.memory_start...Mapping.memory_limit]
174+
// for the corresponding mapping. A non-leaf address may be in the
175+
// middle of a call instruction. It is up to display tools to find
176+
// the beginning of the instruction if necessary.
177+
uint64 address = 3;
178+
// Multiple line indicates this location has inlined functions,
179+
// where the last entry represents the caller into which the
180+
// preceding entries were inlined.
181+
//
182+
// E.g., if memcpy() is inlined into printf:
183+
// line[0].function_name == "memcpy"
184+
// line[1].function_name == "printf"
185+
repeated Line line = 4;
186+
// Provides an indication that multiple symbols map to this location's
187+
// address, for example due to identical code folding by the linker. In that
188+
// case the line information above represents one of the multiple
189+
// symbols. This field must be recomputed when the symbolization state of the
190+
// profile changes.
191+
bool is_folded = 5;
192+
}
193+
194+
message Line {
195+
// The id of the corresponding profile.Function for this line.
196+
uint64 function_id = 1;
197+
// Line number in source code.
198+
int64 line = 2;
199+
}
200+
201+
message Function {
202+
// Unique nonzero id for the function.
203+
uint64 id = 1;
204+
// Name of the function, in human-readable form if available.
205+
int64 name = 2; // Index into string table
206+
// Name of the function, as identified by the system.
207+
// For instance, it can be a C++ mangled name.
208+
int64 system_name = 3; // Index into string table
209+
// Source file containing the function.
210+
int64 filename = 4; // Index into string table
211+
// Line number in source file.
212+
int64 start_line = 5;
213+
}

0 commit comments

Comments
 (0)