linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* perf, tools: Refactor and support interval and CSV metrics
@ 2016-01-30 17:06 Andi Kleen
  2016-01-30 17:06 ` [PATCH 1/8] perf, tools, stat: Abstract stat metrics printing Andi Kleen
                   ` (7 more replies)
  0 siblings, 8 replies; 18+ messages in thread
From: Andi Kleen @ 2016-01-30 17:06 UTC (permalink / raw)
  To: acme; +Cc: jolsa, eranian, mingo, linux-kernel

Rebased tree and fixed Jiri's last feedback.

[v5: Fix mainly bisect problems. No regressions introduced by one
patch and fixed again later. Some minor fixes in addition]
[v6: Fix running/noise printing patch.]
[v7: Reorder and merge two patches to avoid a bisect hole where unsupported was
printed as 0]
[v8: Minor fixes for review feedback. See changelog in patches.]
[v9: Fix newline bug. Add support for -A for --metric-only]
[v10: Remove extra "noise" printing (Jiri)
      Fix fields in documentation (Jiri)]
[v11: Fix manpage again. Avoid extra metric output in CSV mode.]

Currently perf stat does not support printing computed metrics for interval (-I xxx)
or CSV (-x,) mode. For example IPC or TSX metrics over time are quite useful to know.

This patch implements them. The main obstacle was that the
metrics printing was all open coded all over the metrics computation code.
The second patch refactors the metrics printing to work through call backs that
can be more easily changed. This also cleans up the metrics printing significantly.
The indentation is now handled through printf, no more need to manually count spaces.

Then based on that it implements metrics printing for CSV and interval mode,
and finally a --metric-only mode.

Example output:

% perf stat  -I1000 -a sleep 1
#          time              counts unit events                    metric                              multiplex
     1.001301370       12020.049593      task-clock (msec)                                             (100.00%)
     1.001301370              3,952      context-switches          #    0.329 K/sec                    (100.00%)
     1.001301370                 69      cpu-migrations            #    0.006 K/sec                    (100.00%)
     1.001301370                 76      page-faults               #    0.006 K/sec                  
     1.001301370        386,582,789      cycles                    #    0.032 GHz                      (100.00%)
     1.001301370        716,441,544      stalled-cycles-frontend   #  185.33% frontend cycles idle     (100.00%)
     1.001301370    <not supported>      stalled-cycles-backend   
     1.001301370        101,751,678      instructions              #    0.26  insn per cycle         
     1.001301370                                                   #    7.04  stalled cycles per insn  (100.00%)
     1.001301370         20,914,692      branches                  #    1.740 M/sec                    (100.00%)
     1.001301370          1,943,630      branch-misses             #    9.29% of all branches        

CSV mode:

% perf stat  -x, -I1000 -a sleep 1
     1.000852081,12016.143006,,task-clock
     1.000852081,4457,,context-switches,12015168277,100.00,0.371,K/sec
     1.000852081,50,,cpu-migrations,12014024424,100.00,0.004,K/sec
     1.000852081,76,,page-faults,12013076716,100.00,0.006,K/sec
     1.000852081,515854373,,cycles,12011235336,100.00,0.043,GHz
     1.000852081,1030742150,,stalled-cycles-frontend,12010984057,100.00,199.81,frontend cycles idle
     1.000852081,<not supported>,,stalled-cycles-backend,0,100.00
     1.000852081,116782495,,instructions,12011130729,100.00,0.23,insn per cycle
     1.000852081,,,,12011130729,100.00,8.83,stalled cycles per insn
     1.000852081,23748237,,branches,12010745125,100.00,1.976,M/sec
     1.000852081,1976560,,branch-misses,12010501884,100.00,8.32,of all branches

Now includes metrics

Metric only mode:

Concicse information if you only care about computed metrics, not raw values

% perf stat --metric-only  -a -I 1000
     1.001750901 frontend cycles idle backend cycles idle  insn per cycle       stalled cycles per insn branch-misses of all branches 
     1.001750901  188.78%                                   0.53                3.56                    4.19%                      
     2.002625926  233.68%                                   0.86                2.30                    2.84%                      
     3.003296456  236.16%                                   1.18                1.58                    2.87%                      
     4.004095913  129.87%                                   0.24                7.82                    2.08%                      
     5.004964861  116.26%                                   0.17               11.35                    1.43%                      
     6.005802242  148.16%                                   0.19               10.05                    1.54%                      
     7.006485273  151.76%                                   0.18               11.25                    1.88%                     

Metric only mode in CSV (flat format, easy to plot and analyze in statistical tools like JMP, R, pandas, gnuplot):

% perf stat -x, --metric-only  -a -I 1000
     1.001381652,frontend cycles idle,backend cycles idle,insn per cycle,stalled cycles per insn,branch-misses of all branches,
     1.001381652,173.32,,0.83,2.09,1.73,
     2.002073343,199.47,,1.07,1.60,2.14,
     3.002875524,109.52,,0.22,7.83,1.63,
     4.003970059,132.10,,0.17,10.85,1.51,
     5.004818754,181.60,,0.22,8.87,2.22,


Available in
git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc-2.6 perf/stat-metrics-15

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-02-17 19:27 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-30 17:06 perf, tools: Refactor and support interval and CSV metrics Andi Kleen
2016-01-30 17:06 ` [PATCH 1/8] perf, tools, stat: Abstract stat metrics printing Andi Kleen
2016-02-16 19:33   ` Arnaldo Carvalho de Melo
2016-02-17 12:09   ` [tip:perf/core] perf " tip-bot for Andi Kleen
2016-01-30 17:06 ` [PATCH 2/8] perf, tools, stat: Add support for metrics in interval mode Andi Kleen
2016-02-16 19:57   ` Arnaldo Carvalho de Melo
2016-02-17 12:09   ` [tip:perf/core] perf " tip-bot for Andi Kleen
2016-01-30 17:06 ` [PATCH 3/8] perf, tools, stat: Move noise/running printing into printout Andi Kleen
2016-02-16 20:02   ` Arnaldo Carvalho de Melo
2016-02-17 19:27     ` Andi Kleen
2016-02-17 12:10   ` [tip:perf/core] perf stat: Move noise/ running " tip-bot for Andi Kleen
2016-01-30 17:06 ` [PATCH 4/8] perf, tools, stat: Implement CSV metrics output Andi Kleen
2016-02-02  9:50   ` Jiri Olsa
2016-02-02 14:02     ` Andi Kleen
2016-01-30 17:06 ` [PATCH 5/8] perf, tools, stat: Support metrics in --per-core/socket mode Andi Kleen
2016-01-30 17:06 ` [PATCH 6/8] perf, tools, stat: Document CSV format in manpage Andi Kleen
2016-01-30 17:06 ` [PATCH 7/8] perf, tools, stat: Implement --metric-only mode Andi Kleen
2016-01-30 17:06 ` [PATCH 8/8] perf, tools: Add --metric-only support for -A Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).