perf-diff.txt 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. perf-diff(1)
  2. ============
  3. NAME
  4. ----
  5. perf-diff - Read perf.data files and display the differential profile
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'perf diff' [baseline file] [data file1] [[data file2] ... ]
  10. DESCRIPTION
  11. -----------
  12. This command displays the performance difference amongst two or more perf.data
  13. files captured via perf record.
  14. If no parameters are passed it will assume perf.data.old and perf.data.
  15. The differential profile is displayed only for events matching both
  16. specified perf.data files.
  17. If no parameters are passed the samples will be sorted by dso and symbol.
  18. As the perf.data files could come from different binaries, the symbols addresses
  19. could vary. So perf diff is based on the comparison of the files and
  20. symbols name.
  21. OPTIONS
  22. -------
  23. -D::
  24. --dump-raw-trace::
  25. Dump raw trace in ASCII.
  26. --kallsyms=<file>::
  27. kallsyms pathname
  28. -m::
  29. --modules::
  30. Load module symbols. WARNING: use only with -k and LIVE kernel
  31. -d::
  32. --dsos=::
  33. Only consider symbols in these dsos. CSV that understands
  34. file://filename entries. This option will affect the percentage
  35. of the Baseline/Delta column. See --percentage for more info.
  36. -C::
  37. --comms=::
  38. Only consider symbols in these comms. CSV that understands
  39. file://filename entries. This option will affect the percentage
  40. of the Baseline/Delta column. See --percentage for more info.
  41. -S::
  42. --symbols=::
  43. Only consider these symbols. CSV that understands
  44. file://filename entries. This option will affect the percentage
  45. of the Baseline/Delta column. See --percentage for more info.
  46. -s::
  47. --sort=::
  48. Sort by key(s): pid, comm, dso, symbol, cpu, parent, srcline.
  49. Please see description of --sort in the perf-report man page.
  50. -t::
  51. --field-separator=::
  52. Use a special separator character and don't pad with spaces, replacing
  53. all occurrences of this separator in symbol names (and other output)
  54. with a '.' character, that thus it's the only non valid separator.
  55. -v::
  56. --verbose::
  57. Be verbose, for instance, show the raw counts in addition to the
  58. diff.
  59. -q::
  60. --quiet::
  61. Do not show any message. (Suppress -v)
  62. -f::
  63. --force::
  64. Don't do ownership validation.
  65. --symfs=<directory>::
  66. Look for files with symbols relative to this directory.
  67. -b::
  68. --baseline-only::
  69. Show only items with match in baseline.
  70. -c::
  71. --compute::
  72. Differential computation selection - delta, ratio, wdiff, cycles,
  73. delta-abs (default is delta-abs). Default can be changed using
  74. diff.compute config option. See COMPARISON METHODS section for
  75. more info.
  76. --cycles-hist::
  77. Report a histogram and the standard deviation for cycles data.
  78. It can help us to judge if the reported cycles data is noisy or
  79. not. This option should be used with '-c cycles'.
  80. -p::
  81. --period::
  82. Show period values for both compared hist entries.
  83. -F::
  84. --formula::
  85. Show formula for given computation.
  86. -o::
  87. --order::
  88. Specify compute sorting column number. 0 means sorting by baseline
  89. overhead and 1 (default) means sorting by computed value of column 1
  90. (data from the first file other base baseline). Values more than 1
  91. can be used only if enough data files are provided.
  92. The default value can be set using the diff.order config option.
  93. --percentage::
  94. Determine how to display the overhead percentage of filtered entries.
  95. Filters can be applied by --comms, --dsos and/or --symbols options.
  96. "relative" means it's relative to filtered entries only so that the
  97. sum of shown entries will be always 100%. "absolute" means it retains
  98. the original value before and after the filter is applied.
  99. --time::
  100. Analyze samples within given time window. It supports time
  101. percent with multiple time ranges. Time string is 'a%/n,b%/m,...'
  102. or 'a%-b%,c%-%d,...'.
  103. For example:
  104. Select the second 10% time slice to diff:
  105. perf diff --time 10%/2
  106. Select from 0% to 10% time slice to diff:
  107. perf diff --time 0%-10%
  108. Select the first and the second 10% time slices to diff:
  109. perf diff --time 10%/1,10%/2
  110. Select from 0% to 10% and 30% to 40% slices to diff:
  111. perf diff --time 0%-10%,30%-40%
  112. It also supports analyzing samples within a given time window
  113. <start>,<stop>. Times have the format seconds.nanoseconds. If 'start'
  114. is not given (i.e. time string is ',x.y') then analysis starts at
  115. the beginning of the file. If stop time is not given (i.e. time
  116. string is 'x.y,') then analysis goes to the end of the file.
  117. Multiple ranges can be separated by spaces, which requires the argument
  118. to be quoted e.g. --time "1234.567,1234.789 1235,"
  119. Time string is'a1.b1,c1.d1:a2.b2,c2.d2'. Use ':' to separate timestamps
  120. for different perf.data files.
  121. For example, we get the timestamp information from 'perf script'.
  122. perf script -i perf.data.old
  123. mgen 13940 [000] 3946.361400: ...
  124. perf script -i perf.data
  125. mgen 13940 [000] 3971.150589 ...
  126. perf diff --time 3946.361400,:3971.150589,
  127. It analyzes the perf.data.old from the timestamp 3946.361400 to
  128. the end of perf.data.old and analyzes the perf.data from the
  129. timestamp 3971.150589 to the end of perf.data.
  130. --cpu:: Only diff samples for the list of CPUs provided. Multiple CPUs can
  131. be provided as a comma-separated list with no space: 0,1. Ranges of
  132. CPUs are specified with -: 0-2. Default is to report samples on all
  133. CPUs.
  134. --pid=::
  135. Only diff samples for given process ID (comma separated list).
  136. --tid=::
  137. Only diff samples for given thread ID (comma separated list).
  138. --stream::
  139. Enable hot streams comparison. Stream can be a callchain which is
  140. aggregated by the branch records from samples.
  141. COMPARISON
  142. ----------
  143. The comparison is governed by the baseline file. The baseline perf.data
  144. file is iterated for samples. All other perf.data files specified on
  145. the command line are searched for the baseline sample pair. If the pair
  146. is found, specified computation is made and result is displayed.
  147. All samples from non-baseline perf.data files, that do not match any
  148. baseline entry, are displayed with empty space within baseline column
  149. and possible computation results (delta) in their related column.
  150. Example files samples:
  151. - file A with samples f1, f2, f3, f4, f6
  152. - file B with samples f2, f4, f5
  153. - file C with samples f1, f2, f5
  154. Example output:
  155. x - computation takes place for pair
  156. b - baseline sample percentage
  157. - perf diff A B C
  158. baseline/A compute/B compute/C samples
  159. ---------------------------------------
  160. b x f1
  161. b x x f2
  162. b f3
  163. b x f4
  164. b f6
  165. x x f5
  166. - perf diff B A C
  167. baseline/B compute/A compute/C samples
  168. ---------------------------------------
  169. b x x f2
  170. b x f4
  171. b x f5
  172. x x f1
  173. x f3
  174. x f6
  175. - perf diff C B A
  176. baseline/C compute/B compute/A samples
  177. ---------------------------------------
  178. b x f1
  179. b x x f2
  180. b x f5
  181. x f3
  182. x x f4
  183. x f6
  184. COMPARISON METHODS
  185. ------------------
  186. delta
  187. ~~~~~
  188. If specified the 'Delta' column is displayed with value 'd' computed as:
  189. d = A->period_percent - B->period_percent
  190. with:
  191. - A/B being matching hist entry from data/baseline file specified
  192. (or perf.data/perf.data.old) respectively.
  193. - period_percent being the % of the hist entry period value within
  194. single data file
  195. - with filtering by -C, -d and/or -S, period_percent might be changed
  196. relative to how entries are filtered. Use --percentage=absolute to
  197. prevent such fluctuation.
  198. delta-abs
  199. ~~~~~~~~~
  200. Same as 'delta` method, but sort the result with the absolute values.
  201. ratio
  202. ~~~~~
  203. If specified the 'Ratio' column is displayed with value 'r' computed as:
  204. r = A->period / B->period
  205. with:
  206. - A/B being matching hist entry from data/baseline file specified
  207. (or perf.data/perf.data.old) respectively.
  208. - period being the hist entry period value
  209. wdiff:WEIGHT-B,WEIGHT-A
  210. ~~~~~~~~~~~~~~~~~~~~~~~
  211. If specified the 'Weighted diff' column is displayed with value 'd' computed as:
  212. d = B->period * WEIGHT-A - A->period * WEIGHT-B
  213. - A/B being matching hist entry from data/baseline file specified
  214. (or perf.data/perf.data.old) respectively.
  215. - period being the hist entry period value
  216. - WEIGHT-A/WEIGHT-B being user supplied weights in the the '-c' option
  217. behind ':' separator like '-c wdiff:1,2'.
  218. - WEIGHT-A being the weight of the data file
  219. - WEIGHT-B being the weight of the baseline data file
  220. cycles
  221. ~~~~~~
  222. If specified the '[Program Block Range] Cycles Diff' column is displayed.
  223. It displays the cycles difference of same program basic block amongst
  224. two perf.data. The program basic block is the code between two branches.
  225. '[Program Block Range]' indicates the range of a program basic block.
  226. Source line is reported if it can be found otherwise uses symbol+offset
  227. instead.
  228. SEE ALSO
  229. --------
  230. linkperf:perf-record[1], linkperf:perf-report[1]