Browse Source

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 years ago
parent
commit
e11b8033da
No account linked to committer's email address
2 changed files with 80 additions and 31 deletions
  1. 80
    31
      doc/README.md
  2. BIN
      doc/images/callgraph.png

+ 80
- 31
doc/README.md View File

24
 of samples, where each sample is associated to a point in a location hierarchy,
24
 of samples, where each sample is associated to a point in a location hierarchy,
25
 one or more numeric values, and a set of labels. Often these profiles represents
25
 one or more numeric values, and a set of labels. Often these profiles represents
26
 data collected through statistical sampling of a program, so each sample
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
 location. pprof is agnostic to the profile semantics, so other uses are
28
 location. pprof is agnostic to the profile semantics, so other uses are
29
 possible. The interpretation of the reports generated by pprof depends on the
29
 possible. The interpretation of the reports generated by pprof depends on the
30
 semantics defined by the source of the profile.
30
 semantics defined by the source of the profile.
66
 
66
 
67
 The objective of pprof is to generate a report for a profile. The report is
67
 The objective of pprof is to generate a report for a profile. The report is
68
 generated from a location hierarchy, which is reconstructed from the profile
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
 ## Options
77
 ## Options
75
 
78
 
81
 Some common pprof options are:
84
 Some common pprof options are:
82
 
85
 
83
 * **-flat** [default], **-cum**: Sort entries based on their flat or cumulative
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
 * **-functions** [default], **-filefunctions**, **-files**, **-lines**,
88
 * **-functions** [default], **-filefunctions**, **-files**, **-lines**,
86
   **-addresses**: Generate the report using the specified granularity.
89
   **-addresses**: Generate the report using the specified granularity.
87
 * **-noinlines**: Attribute inlined functions to their first out-of-line caller.
90
 * **-noinlines**: Attribute inlined functions to their first out-of-line caller.
88
   For example, a command like `pprof -list foo -noinlines profile.pb.gz` can be
91
   For example, a command like `pprof -list foo -noinlines profile.pb.gz` can be
89
   used to produce the annotated source listing attributing the metrics in the
92
   used to produce the annotated source listing attributing the metrics in the
90
   inlined functions to the out-of-line calling line.
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
 * **-focus= _regex_:** Only include samples that include a report entry matching
97
 * **-focus= _regex_:** Only include samples that include a report entry matching
94
   *regex*.
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
 * **-show\_from= _regex_:** Do not show entries above the first one that
101
 * **-show\_from= _regex_:** Do not show entries above the first one that
98
   matches *regex*.
102
   matches *regex*.
99
 * **-show= _regex_:** Only show entries that match *regex*.
103
 * **-show= _regex_:** Only show entries that match *regex*.
161
 
165
 
162
 pprof text reports show the location hierarchy in text format.
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
 * **-tree:** Prints each location entry with its predecessors and successors.
170
 * **-tree:** Prints each location entry with its predecessors and successors.
167
 * **-peek= _regex_:** Print the location entry with all its predecessors and
171
 * **-peek= _regex_:** Print the location entry with all its predecessors and
168
   successors, without trimming any entries.
172
   successors, without trimming any entries.
174
 multiple formats using the graphviz package.
178
 multiple formats using the graphviz package.
175
 
179
 
176
 These reports represent the location hierarchy as a graph, with a report entry
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
 the graph, controlled by the *nodecount* option.
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
 * **-svg:** Generates a report in SVG format.
186
 * **-svg:** Generates a report in SVG format.
190
 * **-web:** Generates a report in SVG format on a temp file, and starts a web
187
 * **-web:** Generates a report in SVG format on a temp file, and starts a web
191
   browser to view it.
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
 ## Annotated code
243
 ## Annotated code
195
 
244
 
196
 pprof can also generate reports of annotated source with samples associated to
245
 pprof can also generate reports of annotated source with samples associated to
210
 `$PPROF_TOOLS`.
259
 `$PPROF_TOOLS`.
211
 
260
 
212
 * **-list= _regex_:** Generates an annotated source listing for functions
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
 * **-disasm= _regex_:** Generates an annotated disassembly listing for
263
 * **-disasm= _regex_:** Generates an annotated disassembly listing for
215
   functions matching *regex*.
264
   functions matching *regex*.
216
 * **-weblist= _regex_:** Generates a source/assembly combined annotated listing
265
 * **-weblist= _regex_:** Generates a source/assembly combined annotated listing
264
 When fetching from a URL handler, pprof accepts options to indicate how much to
313
 When fetching from a URL handler, pprof accepts options to indicate how much to
265
 wait for the profile.
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
 pprof also accepts options which allow a user to specify TLS certificates to
323
 pprof also accepts options which allow a user to specify TLS certificates to
275
 use when fetching or symbolizing a profile from a protected endpoint. For more
324
 use when fetching or symbolizing a profile from a protected endpoint. For more

BIN
doc/images/callgraph.png View File