Kaynağa Gözat

Add callgraph examples to README.md (#528)

Add callgraph examples to README.md

Co-authored-by: Maggie Nolan <nolanmar@google.com>
Co-authored-by: Alexey Alexandrov <aalexand@users.noreply.github.com>
Garrett Wang 5 yıl önce
ebeveyn
işleme
e11b8033da
No account linked to committer's email address
2 değiştirilmiş dosya ile 80 ekleme ve 31 silme
  1. 80
    31
      doc/README.md
  2. BIN
      doc/images/callgraph.png

+ 80
- 31
doc/README.md Dosyayı Görüntüle

@@ -24,7 +24,7 @@ pprof operates on data in the profile.proto format. Each profile is a collection
24 24
 of samples, where each sample is associated to a point in a location hierarchy,
25 25
 one or more numeric values, and a set of labels. Often these profiles represents
26 26
 data collected through statistical sampling of a program, so each sample
27
-describes a program call stack and a number or weight of samples collected at a
27
+describes a program call stack and a number or value of samples collected at a
28 28
 location. pprof is agnostic to the profile semantics, so other uses are
29 29
 possible. The interpretation of the reports generated by pprof depends on the
30 30
 semantics defined by the source of the profile.
@@ -66,10 +66,13 @@ in a browser to see the interface.
66 66
 
67 67
 The objective of pprof is to generate a report for a profile. The report is
68 68
 generated from a location hierarchy, which is reconstructed from the profile
69
-samples. Each location contains two values: *flat* is the value of the location
70
-itself, while *cum* is the value of the location plus all its
71
-descendants. Samples that include a location multiple times (eg for recursive
72
-functions) are counted only once per location.
69
+samples. Each location contains two values: 
70
+
71
+* *flat*: the value of the location itself.
72
+* *cum*: the value of the location plus all its descendants. 
73
+
74
+Samples that include a location multiple times (e.g. for recursive functions) 
75
+are counted only once per location.
73 76
 
74 77
 ## Options
75 78
 
@@ -81,19 +84,20 @@ other.
81 84
 Some common pprof options are:
82 85
 
83 86
 * **-flat** [default], **-cum**: Sort entries based on their flat or cumulative
84
-  weight respectively, on text reports.
87
+  value respectively, on text reports.
85 88
 * **-functions** [default], **-filefunctions**, **-files**, **-lines**,
86 89
   **-addresses**: Generate the report using the specified granularity.
87 90
 * **-noinlines**: Attribute inlined functions to their first out-of-line caller.
88 91
   For example, a command like `pprof -list foo -noinlines profile.pb.gz` can be
89 92
   used to produce the annotated source listing attributing the metrics in the
90 93
   inlined functions to the out-of-line calling line.
91
-* **-nodecount= _int_:** Maximum number of entries in the report. pprof will only print
92
-  this many entries and will use heuristics to select which entries to trim.
94
+* **-nodecount= _int_:** Maximum number of entries in the report. pprof will
95
+  only print this many entries and will use heuristics to select which entries
96
+  to trim.
93 97
 * **-focus= _regex_:** Only include samples that include a report entry matching
94 98
   *regex*.
95
-* **-ignore= _regex_:** Do not include samples that include a report entry matching
96
-  *regex*.
99
+* **-ignore= _regex_:** Do not include samples that include a report entry
100
+  matching *regex*.
97 101
 * **-show\_from= _regex_:** Do not show entries above the first one that
98 102
   matches *regex*.
99 103
 * **-show= _regex_:** Only show entries that match *regex*.
@@ -161,8 +165,8 @@ range) match a given sample, then the sample will be discarded.
161 165
 
162 166
 pprof text reports show the location hierarchy in text format.
163 167
 
164
-* **-text:** Prints the location entries, one per line, including the flat and cum
165
-  values.
168
+* **-text:** Prints the location entries, one per line, including the flat and
169
+  cum values.
166 170
 * **-tree:** Prints each location entry with its predecessors and successors.
167 171
 * **-peek= _regex_:** Print the location entry with all its predecessors and
168 172
   successors, without trimming any entries.
@@ -174,23 +178,68 @@ pprof can generate graphical reports on the DOT format, and convert them to
174 178
 multiple formats using the graphviz package.
175 179
 
176 180
 These reports represent the location hierarchy as a graph, with a report entry
177
-represented as a node. Solid edges represent a direct connection between
178
-entries, while dotted edges represent a connection where some intermediate nodes
179
-have been removed. Nodes are removed using heuristics to limit the size of
181
+represented as a node. Nodes are removed using heuristics to limit the size of
180 182
 the graph, controlled by the *nodecount* option.
181 183
 
182
-The size of each node represents the flat weight of the node, and the width of
183
-each edge represents the cumulative weight of all samples going through
184
-it. Nodes are colored according to their cumulative weight, highlighting the
185
-paths with the highest cum weight.
186
-
187
-* **-dot:** Generates a report in .dot format. All other formats are generated from
188
-  this one.
184
+* **-dot:** Generates a report in .dot format. All other formats are generated
185
+  from this one.
189 186
 * **-svg:** Generates a report in SVG format.
190 187
 * **-web:** Generates a report in SVG format on a temp file, and starts a web
191 188
   browser to view it.
192
-* **-png, -jpg, -gif, -pdf:** Generates a report in these formats,
193
-
189
+* **-png, -jpg, -gif, -pdf:** Generates a report in these formats.
190
+
191
+### Interpreting the Callgraph
192
+
193
+* **Flat Value**: the value of a location itself. This is indicated by the font 
194
+  size.
195
+    *   Nodes with larger font sizes have larger flat values.
196
+    *   Nodes with smaller font sizes have smaller flat values.
197
+
198
+* **Cum Value**: the value of a location plus all of its descendants. This is
199
+  indicated by the node's color.
200
+    *   Redder nodes have greater cum values.
201
+    *   Greyer nodes have smaller cum values.
202
+
203
+* **Dashed Edges**: some locations between the two connected locations were
204
+  removed.
205
+
206
+* **Solid Edges**: one location directly calls the other.
207
+
208
+* **Thicker & Redder Edges**: more resources (i.e. larger value) were used
209
+  along that path.
210
+
211
+* **Thinner & Greyer Edges**: fewer resources (i.e. smaller value) were used
212
+  along that path.
213
+
214
+* **"(inline)" Edge Marker**: the call has been inlined into the caller.
215
+
216
+Let's consider the following example graph:
217
+
218
+![callgraph](images/callgraph.png)
219
+
220
+* For nodes:
221
+  * `(*Rand).Read` has a small flat value and a small cum value because the
222
+    the font is small and the node is grey.
223
+  * `(*compressor).deflate` has a large flat value and a large cum value because the font 
224
+    is large and the node is red.
225
+  * `(*Writer).Flush` has a small flat value and a large cum value because the font is
226
+    small and the node is red.
227
+
228
+* For edges:
229
+  * the edge between `(*Writer).Write` and `(*compressor).write`: 
230
+    * Since it is a dashed edge, some nodes were removed between those two.
231
+    * Since it is thick and red, more resources were used in call stacks between
232
+    those two nodes.
233
+  * the edge between `(*Rand).Read` and `read`:
234
+    * Since it is a dashed edge, some nodes were removed between those two.
235
+    * Since it is thin and grey, fewer resources were used in call stacks 
236
+    between those two nodes.
237
+  * the edge between `read` and `(*rngSource).Int63`:
238
+    * Since it is a solid edge, there are no nodes between those two (i.e. it
239
+      was a direct call).
240
+    * Since it is thin and grey, fewer resrouces were used in call stacks
241
+      between those two nodes.
242
+  
194 243
 ## Annotated code
195 244
 
196 245
 pprof can also generate reports of annotated source with samples associated to
@@ -210,7 +259,7 @@ search for them in a directory pointed to by the environment variable
210 259
 `$PPROF_TOOLS`.
211 260
 
212 261
 * **-list= _regex_:** Generates an annotated source listing for functions
213
-  matching *regex*, with flat/cum weights for each source line.
262
+  matching *regex*, with flat/cum values for each source line.
214 263
 * **-disasm= _regex_:** Generates an annotated disassembly listing for
215 264
   functions matching *regex*.
216 265
 * **-weblist= _regex_:** Generates a source/assembly combined annotated listing
@@ -264,12 +313,12 @@ also accept some legacy formats generated by
264 313
 When fetching from a URL handler, pprof accepts options to indicate how much to
265 314
 wait for the profile.
266 315
 
267
-* **-seconds= _int_:** Makes pprof request for a profile with the specified duration
268
-  in seconds. Only makes sense for profiles based on elapsed time, such as CPU
269
-  profiles.
270
-* **-timeout= _int_:** Makes pprof wait for the specified timeout when retrieving a
271
-  profile over http. If not specified, pprof will use heuristics to determine a
272
-  reasonable timeout.
316
+* **-seconds= _int_:** Makes pprof request for a profile with the specified
317
+  duration in seconds. Only makes sense for profiles based on elapsed time, such
318
+  as CPU profiles.
319
+* **-timeout= _int_:** Makes pprof wait for the specified timeout when
320
+  retrieving a profile over http. If not specified, pprof will use heuristics to
321
+  determine a reasonable timeout.
273 322
 
274 323
 pprof also accepts options which allow a user to specify TLS certificates to
275 324
 use when fetching or symbolizing a profile from a protected endpoint. For more

BIN
doc/images/callgraph.png Dosyayı Görüntüle