Skip to contentSkip to conversation

perf script: Add a python script to statistic direct io behavior

PATCH Superseded [email protected] 3 participants 3 messages Jan 31, 2013 – Feb 1, 2013 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf script: Add a python script to statistic direct io behavior

From: [email protected]

This patch depends on a prev patch: https://lkml.org/lkml/2013/1/29/47

If the engineers want to analyze the direct io behavior of some applications without source code, perf tools with some appropriate tracepoints events in the VFS subsystem are excellent choice.

Many database systems use their own page cache subsystems and use the direct IO to access the disks. Sometimes, the system engineers need to know the misses rate of the database system's page cache. This requirements can be satisfied by recording the database's file access behavior through the way of direct IO. So, we use 2 tracepoint events to record the system wide's direct IO behavior. The 2 tracepoint events are:
1) vfs:direct_io_read
2) vfs:direct_io_write
they were introduced by the patch: https://lkml.org/lkml/2013/1/29/47
The script direct-io.py are introduced by this patch can record the 2 tracepoint events, analyse the sample data, and give a concise report.

usage:
"perf script record direct-io\n" "perf script report direct-io [comm|pid]\n"

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc David Ahern <[email protected]>
Cc Arjan van de Ven <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Yanmin Zhang <[email protected]>
Cc Wu Fengguang <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Andrew Morton <[email protected]>
---
 tools/perf/scripts/python/bin/direct-io-record |    2 +
 tools/perf/scripts/python/bin/direct-io-report |   21 +++
 tools/perf/scripts/python/direct-io.py         |  185 ++++++++++++++++++++++++
 3 files changed, 208 insertions(+)
 create mode 100755 tools/perf/scripts/python/bin/direct-io-record
 create mode 100644 tools/perf/scripts/python/bin/direct-io-report
 create mode 100644 tools/perf/scripts/python/direct-io.py
tools/perf/scripts/python/bin/direct-io-record new file +2 -0
new file mode 100755
index 0000000..4857097
@@ -0,0 +1,2 @@
+#!/bin/bash
+perf record -e vfs:direct_io_read -e vfs:direct_io_write $@
tools/perf/scripts/python/bin/direct-io-report new file +21 -0
new file mode 100644
index 0000000..828d9c6
@@ -0,0 +1,21 @@
+#!/bin/bash
+# description: direct_io statistic
+# args: [comm|pid]
+n_args=0
+for i in "$@"
+do
+    if expr match "$i" "-" > /dev/null ; then
+	break
+    fi
+    n_args=$(( $n_args + 1 ))
+done
+if [ "$n_args" -gt 1 ] ; then
+    echo "usage: perf script report direct-io [comm|pid]"
+    exit
+fi
+
+if [ "$n_args" -gt 0 ] ; then
+    comm=$1
+    shift
+fi
+perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/direct-io.py $comm
tools/perf/scripts/python/direct-io.py new file +185 -0

185 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

Hi

Quoted 8 lines · On 1/31/13 2:08 AM, [email protected] wrote:

From: [email protected]

This patch depends on a prev patch: https://lkml.org/lkml/2013/1/29/47

If the engineers want to analyze the direct io behavior of some applications without source code, perf tools with some appropriate tracepoints events in the VFS subsystem are excellent choice.

Quoted 11 lines

Many database systems use their own page cache subsystems and use the direct IO to access the disks. Sometimes, the system engineers need to know the misses rate of the database system's page cache. This requirements can be satisfied by recording the database's file access behavior through the way of direct IO. So, we use 2 tracepoint events to record the system wide's direct IO behavior. The 2 tracepoint events are:
1) vfs:direct_io_read
2) vfs:direct_io_write
they were introduced by the patch: https://lkml.org/lkml/2013/1/29/47
The script direct-io.py are introduced by this patch can record the 2 tracepoint events, analyse the sample data, and give a concise report.

What does this option provide that the I/O accounting with taskstats (e.g., iotop) does not provide?

David

maintainer
#2 lore raw

Hi,

Quoted 23 lines · David Ahern

Hi

Quoted 8 lines · On 1/31/13 2:08 AM, [email protected] wrote:

From: [email protected]

This patch depends on a prev patch: https://lkml.org/lkml/2013/1/29/47

If the engineers want to analyze the direct io behavior of some applications without source code, perf tools with some appropriate tracepoints events in the VFS subsystem are excellent choice.

Quoted 11 lines

Many database systems use their own page cache subsystems and use the direct IO to access the disks. Sometimes, the system engineers need to know the misses rate of the database system's page cache. This requirements can be satisfied by recording the database's file access behavior through the way of direct IO. So, we use 2 tracepoint events to record the system wide's direct IO behavior. The 2 tracepoint events are:
1) vfs:direct_io_read
2) vfs:direct_io_write
they were introduced by the patch: https://lkml.org/lkml/2013/1/29/47
The script direct-io.py are introduced by this patch can record the 2 tracepoint events, analyse the sample data, and give a concise report.

Quoted 2 lines

What does this option provide that the I/O accounting with taskstats (e.g., iotop) does not provide?

Maybe it's better to put this into 'blktrace' tool once the TPs are accepted.

Thanks,
Namhyung