2009-11-10 11:50:58

by Hitoshi Mitake

[permalink] [raw]
Subject: [PATCH 0/3] perf bench: Clean and add document for perf-bench

This patch series cleans bench/bench.h for readability and
adds new document describing perf-bench.

Hitoshi Mitake (3):
perf bench: Clean bench/bench.h
perf bench: Add new document of perf-bench
perf bench: Modify command-list.txt for the entry of perf-bench

tools/perf/Documentation/perf-bench.txt | 120 +++++++++++++++++++++++++++++++
tools/perf/bench/bench.h | 16 ++---
tools/perf/command-list.txt | 1 +
3 files changed, 128 insertions(+), 9 deletions(-)
create mode 100644 tools/perf/Documentation/perf-bench.txt


2009-11-10 11:51:04

by Hitoshi Mitake

[permalink] [raw]
Subject: [PATCH 1/3] perf bench: Clean bench/bench.h

This patch cleans bench/bench.h for readability
according to Ingo's advice.
Actually, this patch is completely same with
one Ingo posted.

| A (very) small detail about initializers in bench.h:
|
| - No need to break the line for function prototypes, they are more
| readable in a single line. (even if checkpatch complains about it)
|
| - We try to align definitions / structure fields vertically, to make it
| all a bit more readable.

Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
tools/perf/bench/bench.h | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index 42167ea..9fbd8d7 100644
--- a/tools/perf/bench/bench.h
+++ b/tools/perf/bench/bench.h
@@ -1,17 +1,15 @@
#ifndef BENCH_H
#define BENCH_H

-extern int bench_sched_messaging(int argc, const char **argv,
- const char *prefix);
-extern int bench_sched_pipe(int argc, const char **argv,
- const char *prefix);
+extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
+extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);

-#define BENCH_FORMAT_DEFAULT_STR "default"
-#define BENCH_FORMAT_DEFAULT 0
-#define BENCH_FORMAT_SIMPLE_STR "simple"
-#define BENCH_FORMAT_SIMPLE 1
+#define BENCH_FORMAT_DEFAULT_STR "default"
+#define BENCH_FORMAT_DEFAULT 0
+#define BENCH_FORMAT_SIMPLE_STR "simple"
+#define BENCH_FORMAT_SIMPLE 1

-#define BENCH_FORMAT_UNKNOWN -1
+#define BENCH_FORMAT_UNKNOWN -1

extern int bench_format;

--
1.6.5.2

2009-11-10 11:51:20

by Hitoshi Mitake

[permalink] [raw]
Subject: [PATCH 2/3] perf bench: Add new document of perf-bench

This patch adds new document of perf-bench.
Man page and html will be provided for user.

Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
tools/perf/Documentation/perf-bench.txt | 120 +++++++++++++++++++++++++++++++
1 files changed, 120 insertions(+), 0 deletions(-)
create mode 100644 tools/perf/Documentation/perf-bench.txt

diff --git a/tools/perf/Documentation/perf-bench.txt b/tools/perf/Documentation/perf-bench.txt
new file mode 100644
index 0000000..ae525ac
--- /dev/null
+++ b/tools/perf/Documentation/perf-bench.txt
@@ -0,0 +1,120 @@
+perf-bench(1)
+============
+
+NAME
+----
+perf-bench - General framework for benchmark suites
+
+SYNOPSIS
+--------
+[verse]
+'perf bench' [<common options>] <subsystem> <suite> [<options>]
+
+DESCRIPTION
+-----------
+This 'perf bench' command is general framework for benchmark suites.
+
+COMMON OPTIONS
+--------------
+-f::
+--format=::
+Specify format style.
+Current available format styles are,
+
+'default'::
+Default style. This is mainly for human reading.
+---------------------
+% perf bench sched pipe # with no style specify
+(executing 1000000 pipe operations between two tasks)
+ Total time:5.855 sec
+ 5.855061 usecs/op
+ 170792 ops/sec
+---------------------
+
+'simple'::
+This simple style is friendly for automated
+processing by scripts.
+---------------------
+% perf bench --format=simple sched pipe # specified simple
+5.988
+---------------------
+
+SUBSYSTEM
+---------
+
+'sched'::
+ Scheduler and IPC mechanisms.
+
+SUITES FOR 'sched'
+~~~~~~~~~~~~~~~~~~
+*messaging*::
+Suite for evaluating performance of scheduler and IPC mechanisms.
+Based on hackbench by Rusty Russell.
+
+Options of *pipe*
+^^^^^^^^^^^^^^^^^
+-p::
+--pipe::
+Use pipe() instead of socketpair()
+
+-t::
+--thread::
+Be multi thread instead of multi process
+
+-g::
+--group=::
+Specify number of groups
+
+-l::
+--loop=::
+Specify number of loops
+
+Example of *messaging*
+^^^^^^^^^^^^^^^^^^^^^^
+
+---------------------
+% perf bench sched messaging # run with default
+options (20 sender and receiver processes per group)
+(10 groups == 400 processes run)
+
+ Total time:0.308 sec
+
+% perf bench sched messaging -t -g 20 # be multi-thread,with 20 groups
+(20 sender and receiver threads per group)
+(20 groups == 800 threads run)
+
+ Total time:0.582 sec
+---------------------
+
+*pipe*::
+Suite for pipe() system call.
+Based on pipe-test-1m.c by Ingo Molnar.
+
+Options of *pipe*
+^^^^^^^^^^^^^^^^^
+-l::
+--loop=::
+Specify number of loops.
+
+Example of *pipe*
+^^^^^^^^^^^^^^^^^
+
+---------------------
+% perf bench sched pipe
+(executing 1000000 pipe operations between two tasks)
+
+ Total time:8.091 sec
+ 8.091833 usecs/op
+ 123581 ops/sec
+
+% perf bench sched pipe -l 1000 # loop 1000
+(executing 1000 pipe operations between two tasks)
+
+ Total time:0.016 sec
+ 16.948000 usecs/op
+ 59004 ops/sec
+---------------------
+
+SEE ALSO
+--------
+linkperf:perf[1]
--
1.6.5.2

2009-11-10 11:51:17

by Hitoshi Mitake

[permalink] [raw]
Subject: [PATCH 3/3] perf bench: Modify command-list.txt for the entry of perf-bench

This patch modifies command-list.txt for the entry of perf-bench.
So perf will show 'bench' in command list.

Example:
% perf

usage: perf [--version] [--help] COMMAND [ARGS]

The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
bench General framework for benchmark suites
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
list List all symbolic event types
probe Define new dynamic tracepoints
record Run a command and record its profile into perf.data
report Read perf.data (created by perf record) and display the profile
sched Tool to trace/measure scheduler properties (latencies)
stat Run a command and gather performance counter statistics
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
trace Read perf.data (created by perf record) and display trace output

See 'perf help COMMAND' for more information on a specific command.

Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
tools/perf/command-list.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/command-list.txt b/tools/perf/command-list.txt
index 6475db4..161322b 100644
--- a/tools/perf/command-list.txt
+++ b/tools/perf/command-list.txt
@@ -12,3 +12,4 @@ perf-timechart mainporcelain common
perf-top mainporcelain common
perf-trace mainporcelain common
perf-probe mainporcelain common
+perf-bench mainporcelain common
--
1.6.5.2

2009-11-10 13:17:50

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 0/3] perf bench: Clean and add document for perf-bench


* Hitoshi Mitake <[email protected]> wrote:

> This patch series cleans bench/bench.h for readability and
> adds new document describing perf-bench.
>
> Hitoshi Mitake (3):
> perf bench: Clean bench/bench.h
> perf bench: Add new document of perf-bench
> perf bench: Modify command-list.txt for the entry of perf-bench
>
> tools/perf/Documentation/perf-bench.txt | 120 +++++++++++++++++++++++++++++++
> tools/perf/bench/bench.h | 16 ++---
> tools/perf/command-list.txt | 1 +
> 3 files changed, 128 insertions(+), 9 deletions(-)
> create mode 100644 tools/perf/Documentation/perf-bench.txt

Applied, thanks!

Btw., a small detail i noticed when running the pipe benchmark:

earth4:~/tip/tools/perf> ./perf bench sched pipe
(executing 1000000 pipe operations between two tasks)

Total time:5.076 sec
5.076232 usecs/op
196996 ops/sec

when i typed 'perf bench sched pipe' nothing happened for several
seconds. The command did not finish and no output was printed.

This might surprise users - it's always good to print a single line that
we are processing a benchmark. Maybe this could be printed from the
generic subcommand, something like:

running sched/pipe benchmark ...

What do you think?

Ingo

2009-11-10 13:25:53

by Ingo Molnar

[permalink] [raw]
Subject: [tip:perf/bench] perf bench: Clean up bench/bench.h

Commit-ID: 606bc1e18d346fc7d7fb333909cc95b06b1ca5b1
Gitweb: http://git.kernel.org/tip/606bc1e18d346fc7d7fb333909cc95b06b1ca5b1
Author: Ingo Molnar <[email protected]>
AuthorDate: Tue, 10 Nov 2009 20:50:53 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 10 Nov 2009 14:14:35 +0100

perf bench: Clean up bench/bench.h

Clean up initializers in bench.h:

- No need to break the line for function prototypes, they are more
readable in a single line. (even if checkpatch complains about it

- We try to align definitions / structure fields vertically,
to make it all a bit more readable.

Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
---
tools/perf/bench/bench.h | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index 42167ea..9fbd8d7 100644
--- a/tools/perf/bench/bench.h
+++ b/tools/perf/bench/bench.h
@@ -1,17 +1,15 @@
#ifndef BENCH_H
#define BENCH_H

-extern int bench_sched_messaging(int argc, const char **argv,
- const char *prefix);
-extern int bench_sched_pipe(int argc, const char **argv,
- const char *prefix);
+extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
+extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);

-#define BENCH_FORMAT_DEFAULT_STR "default"
-#define BENCH_FORMAT_DEFAULT 0
-#define BENCH_FORMAT_SIMPLE_STR "simple"
-#define BENCH_FORMAT_SIMPLE 1
+#define BENCH_FORMAT_DEFAULT_STR "default"
+#define BENCH_FORMAT_DEFAULT 0
+#define BENCH_FORMAT_SIMPLE_STR "simple"
+#define BENCH_FORMAT_SIMPLE 1

-#define BENCH_FORMAT_UNKNOWN -1
+#define BENCH_FORMAT_UNKNOWN -1

extern int bench_format;

2009-11-10 13:25:59

by Hitoshi Mitake

[permalink] [raw]
Subject: [tip:perf/bench] perf bench: Add new document about perf-bench

Commit-ID: 9fbc04f2493929a69fd9e53b5fb53c127d7950d5
Gitweb: http://git.kernel.org/tip/9fbc04f2493929a69fd9e53b5fb53c127d7950d5
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Tue, 10 Nov 2009 20:50:54 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 10 Nov 2009 14:14:36 +0100

perf bench: Add new document about perf-bench

This patch adds new document about perf-bench.
Man page and html will be provided for user.

Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Documentation/perf-bench.txt | 120 +++++++++++++++++++++++++++++++
1 files changed, 120 insertions(+), 0 deletions(-)

diff --git a/tools/perf/Documentation/perf-bench.txt b/tools/perf/Documentation/perf-bench.txt
new file mode 100644
index 0000000..ae525ac
--- /dev/null
+++ b/tools/perf/Documentation/perf-bench.txt
@@ -0,0 +1,120 @@
+perf-bench(1)
+============
+
+NAME
+----
+perf-bench - General framework for benchmark suites
+
+SYNOPSIS
+--------
+[verse]
+'perf bench' [<common options>] <subsystem> <suite> [<options>]
+
+DESCRIPTION
+-----------
+This 'perf bench' command is general framework for benchmark suites.
+
+COMMON OPTIONS
+--------------
+-f::
+--format=::
+Specify format style.
+Current available format styles are,
+
+'default'::
+Default style. This is mainly for human reading.
+---------------------
+% perf bench sched pipe # with no style specify
+(executing 1000000 pipe operations between two tasks)
+ Total time:5.855 sec
+ 5.855061 usecs/op
+ 170792 ops/sec
+---------------------
+
+'simple'::
+This simple style is friendly for automated
+processing by scripts.
+---------------------
+% perf bench --format=simple sched pipe # specified simple
+5.988
+---------------------
+
+SUBSYSTEM
+---------
+
+'sched'::
+ Scheduler and IPC mechanisms.
+
+SUITES FOR 'sched'
+~~~~~~~~~~~~~~~~~~
+*messaging*::
+Suite for evaluating performance of scheduler and IPC mechanisms.
+Based on hackbench by Rusty Russell.
+
+Options of *pipe*
+^^^^^^^^^^^^^^^^^
+-p::
+--pipe::
+Use pipe() instead of socketpair()
+
+-t::
+--thread::
+Be multi thread instead of multi process
+
+-g::
+--group=::
+Specify number of groups
+
+-l::
+--loop=::
+Specify number of loops
+
+Example of *messaging*
+^^^^^^^^^^^^^^^^^^^^^^
+
+---------------------
+% perf bench sched messaging # run with default
+options (20 sender and receiver processes per group)
+(10 groups == 400 processes run)
+
+ Total time:0.308 sec
+
+% perf bench sched messaging -t -g 20 # be multi-thread,with 20 groups
+(20 sender and receiver threads per group)
+(20 groups == 800 threads run)
+
+ Total time:0.582 sec
+---------------------
+
+*pipe*::
+Suite for pipe() system call.
+Based on pipe-test-1m.c by Ingo Molnar.
+
+Options of *pipe*
+^^^^^^^^^^^^^^^^^
+-l::
+--loop=::
+Specify number of loops.
+
+Example of *pipe*
+^^^^^^^^^^^^^^^^^
+
+---------------------
+% perf bench sched pipe
+(executing 1000000 pipe operations between two tasks)
+
+ Total time:8.091 sec
+ 8.091833 usecs/op
+ 123581 ops/sec
+
+% perf bench sched pipe -l 1000 # loop 1000
+(executing 1000 pipe operations between two tasks)
+
+ Total time:0.016 sec
+ 16.948000 usecs/op
+ 59004 ops/sec
+---------------------
+
+SEE ALSO
+--------
+linkperf:perf[1]

2009-11-10 13:26:11

by Hitoshi Mitake

[permalink] [raw]
Subject: [tip:perf/bench] perf bench: Modify command-list.txt for the entry of perf-bench

Commit-ID: 8d8d61aadb9d8cce07f7dcdb77a4c20a25d36d07
Gitweb: http://git.kernel.org/tip/8d8d61aadb9d8cce07f7dcdb77a4c20a25d36d07
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Tue, 10 Nov 2009 20:50:55 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 10 Nov 2009 14:14:36 +0100

perf bench: Modify command-list.txt for the entry of perf-bench

This patch modifies command-list.txt for the entry of
perf-bench. So perf will show 'bench' in command list.

Example:
% perf

usage: perf [--version] [--help] COMMAND [ARGS]

The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
bench General framework for benchmark suites
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
list List all symbolic event types
probe Define new dynamic tracepoints
record Run a command and record its profile into perf.data
report Read perf.data (created by perf record) and display the profile
sched Tool to trace/measure scheduler properties (latencies)
stat Run a command and gather performance counter statistics
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
trace Read perf.data (created by perf record) and display trace output

See 'perf help COMMAND' for more information on a specific command.

Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/command-list.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/command-list.txt b/tools/perf/command-list.txt
index 00326e2..981c40b 100644
--- a/tools/perf/command-list.txt
+++ b/tools/perf/command-list.txt
@@ -3,6 +3,7 @@
# command name category [deprecated] [common]
#
perf-annotate mainporcelain common
+perf-bench mainporcelain common
perf-list mainporcelain common
perf-sched mainporcelain common
perf-record mainporcelain common

2009-11-10 14:43:06

by Hitoshi Mitake

[permalink] [raw]
Subject: Re: [PATCH 0/3] perf bench: Clean and add document for perf-bench

From: Ingo Molnar <[email protected]>
Subject: Re: [PATCH 0/3] perf bench: Clean and add document for perf-bench
Date: Tue, 10 Nov 2009 14:17:38 +0100

> Applied, thanks!
>
> Btw., a small detail i noticed when running the pipe benchmark:
>
> earth4:~/tip/tools/perf> ./perf bench sched pipe
> (executing 1000000 pipe operations between two tasks)
>
> Total time:5.076 sec
> 5.076232 usecs/op
> 196996 ops/sec
>
> when i typed 'perf bench sched pipe' nothing happened for several
> seconds. The command did not finish and no output was printed.
>
> This might surprise users - it's always good to print a single line that
> we are processing a benchmark. Maybe this could be printed from the
> generic subcommand, something like:
>
> running sched/pipe benchmark ...
>
> What do you think?

Yeah, I have to admit that. Current style, keeping user wait
and print everything suddenly after finish, is not good.
I'll fix it.

And I also want to fix

> Total time:5.076 sec
> 5.076232 usecs/op
> 196996 ops/sec

this style. This is too bad.
So I'll imitate style of perf-stat for making this format better.

Hitoshi