summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhunt <hunt>2005-08-22 22:19:57 +0000
committerhunt <hunt>2005-08-22 22:19:57 +0000
commitb5e93a155bcaf04e3b2795a70489a8800eb60e97 (patch)
treef39b8053692ae3fe02f507f0a3ea9bb363701c2d
parentdf8fadee215f81b07f809f4d3ebb016e390f2c9b (diff)
downloadsystemtap-steved-b5e93a155bcaf04e3b2795a70489a8800eb60e97.tar.gz
systemtap-steved-b5e93a155bcaf04e3b2795a70489a8800eb60e97.tar.xz
systemtap-steved-b5e93a155bcaf04e3b2795a70489a8800eb60e97.zip
New benchmark: trans_bench.
-rw-r--r--runtime/probes/bench/Makefile10
-rw-r--r--runtime/probes/bench/bench_io1.c1
-rw-r--r--runtime/probes/bench/bench_io2.c2
-rw-r--r--runtime/probes/bench/bench_io3.c44
-rw-r--r--runtime/probes/bench/bench_io4.c45
-rw-r--r--runtime/probes/bench/itest.c71
-rwxr-xr-xruntime/probes/bench/run_bench47
-rwxr-xr-xruntime/probes/bench/stp46
-rw-r--r--runtime/probes/bench/targets2
-rwxr-xr-xruntime/probes/bench/trans_bench172
10 files changed, 384 insertions, 56 deletions
diff --git a/runtime/probes/bench/Makefile b/runtime/probes/bench/Makefile
new file mode 100644
index 00000000..9154e3dc
--- /dev/null
+++ b/runtime/probes/bench/Makefile
@@ -0,0 +1,10 @@
+all: ttest itest
+
+ttest: ttest.c
+ gcc -Wall -O3 -o ttest ttest.c
+
+itest: itest.c
+ gcc -Wall -O3 -o itest itest.c
+
+clean:
+ /bin/rm -f itest ttest stpd_cpu* xxx*
diff --git a/runtime/probes/bench/bench_io1.c b/runtime/probes/bench/bench_io1.c
index 8a344e4d..8bdc4018 100644
--- a/runtime/probes/bench/bench_io1.c
+++ b/runtime/probes/bench/bench_io1.c
@@ -1,4 +1,3 @@
-#define STP_NETLINK_ONLY
#define STP_NUM_STRINGS 1
#include "runtime.h"
diff --git a/runtime/probes/bench/bench_io2.c b/runtime/probes/bench/bench_io2.c
index f9f51ca3..14216913 100644
--- a/runtime/probes/bench/bench_io2.c
+++ b/runtime/probes/bench/bench_io2.c
@@ -1,4 +1,4 @@
-//#define STP_NETLINK_ONLY
+#define STP_RELAYFS
#define STP_NUM_STRINGS 1
#include "runtime.h"
diff --git a/runtime/probes/bench/bench_io3.c b/runtime/probes/bench/bench_io3.c
new file mode 100644
index 00000000..a491edd9
--- /dev/null
+++ b/runtime/probes/bench/bench_io3.c
@@ -0,0 +1,44 @@
+#define STP_NUM_STRINGS 1
+
+#include "runtime.h"
+#include "probes.c"
+
+MODULE_DESCRIPTION("SystemTap probe: bench_io3");
+MODULE_AUTHOR("Martin Hunt");
+
+static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs)
+{
+ /* print 1000 chars */
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_print_flush();
+ return 0;
+}
+
+
+static struct kprobe kp[] = {
+ {
+ .addr = "sys_getuid",
+ .pre_handler = inst_sys_getuid
+ },
+};
+
+#define NUM_KPROBES (sizeof(kp)/sizeof(struct kprobe))
+
+int probe_start(void)
+{
+ return _stp_register_kprobes (kp, NUM_KPROBES);
+}
+
+void probe_exit (void)
+{
+ _stp_unregister_kprobes (kp, NUM_KPROBES);
+}
diff --git a/runtime/probes/bench/bench_io4.c b/runtime/probes/bench/bench_io4.c
new file mode 100644
index 00000000..a6b19ab5
--- /dev/null
+++ b/runtime/probes/bench/bench_io4.c
@@ -0,0 +1,45 @@
+#define STP_RELAYFS
+#define STP_NUM_STRINGS 1
+
+#include "runtime.h"
+#include "probes.c"
+
+MODULE_DESCRIPTION("SystemTap probe: bench_io3");
+MODULE_AUTHOR("Martin Hunt");
+
+static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs)
+{
+ /* print 1000 chars */
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_printf ("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n");
+ _stp_print_flush();
+ return 0;
+}
+
+
+static struct kprobe kp[] = {
+ {
+ .addr = "sys_getuid",
+ .pre_handler = inst_sys_getuid
+ },
+};
+
+#define NUM_KPROBES (sizeof(kp)/sizeof(struct kprobe))
+
+int probe_start(void)
+{
+ return _stp_register_kprobes (kp, NUM_KPROBES);
+}
+
+void probe_exit (void)
+{
+ _stp_unregister_kprobes (kp, NUM_KPROBES);
+}
diff --git a/runtime/probes/bench/itest.c b/runtime/probes/bench/itest.c
new file mode 100644
index 00000000..8ac11b8f
--- /dev/null
+++ b/runtime/probes/bench/itest.c
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+typedef unsigned long long uint64;
+struct rusage rstart;
+struct timeval tstart, tstop;
+uint64 ttime = 0;
+
+void start()
+{
+ gettimeofday (&tstart, NULL);
+ getrusage (RUSAGE_SELF, &rstart);
+}
+
+uint64 usecs (struct timeval *tv)
+{
+ return tv->tv_sec * 1000000 + tv->tv_usec;
+}
+
+uint64 stop()
+{
+ struct rusage rend;
+ getrusage (RUSAGE_SELF, &rend);
+ gettimeofday (&tstop, NULL);
+ uint64 utime = usecs(&rend.ru_utime) - usecs(&rstart.ru_utime);
+ uint64 stime = usecs(&rend.ru_stime) - usecs(&rstart.ru_stime);
+ ttime = usecs(&tstop) - usecs(&tstart);
+ return utime + stime;
+}
+
+void usage(char *name)
+{
+ printf ("Usage %s [time]\nWhere \"time\" is millions of times to loop.\n", name);
+ exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+ int i, n = 1;
+ uint64 nsecs;
+
+ if (argc > 2)
+ usage(argv[0]);
+
+ if (argc == 2) {
+ n = strtol(argv[1], NULL, 10);
+ if (n == 0)
+ usage(argv[0]);
+ }
+
+
+ start();
+ for (i = 0; i < n * 1000000; i++)
+ getuid();
+
+ nsecs = stop() / (n * 1000);
+
+ /* returns
+ nanosecs per call (user + system time)
+ elapsed usecs (real time)
+ */
+ printf("%lld %.2f\n", nsecs, ttime/1000000.0);
+
+ return 0;
+}
diff --git a/runtime/probes/bench/run_bench b/runtime/probes/bench/run_bench
index 471da231..8bbc2dd4 100755
--- a/runtime/probes/bench/run_bench
+++ b/runtime/probes/bench/run_bench
@@ -2,6 +2,8 @@
# -*- tcl -*-
proc do_time {module n} {
+ global Failures
+
# start kprobes
if {[catch {exec ../../stpd/stpd -mq $module.ko > xxx &} pid]} {
puts $pid
@@ -21,9 +23,29 @@ proc do_time {module n} {
puts $res
}
+ exec sleep 2
+
+ # look for warnings
+ exec tail xxx >xxx.tail
+ if {[catch {open xxx.tail r} fd]} {
+ puts "Cannot open test output\n"
+ exit -1
+ }
+
+ set Failures 0
+ while {[gets $fd line] >= 0} {
+ if {[regexp {^\033\[33mWARNING: \033\[0mThere were ([0-9]*) transport failures.} $line match var]} {
+ set Failures $var
+ break
+ }
+ }
+ close $fd
+ exec /bin/rm -f xxx xxx.out
return $res2
}
+######## START HERE ###########
+
set nproc [exec grep ^processor /proc/cpuinfo | wc -l]
if {![catch {exec grep "physical id" /proc/cpuinfo} phyid]} {
@@ -37,16 +59,21 @@ set model [string range $model [expr [string first : $model]+1] end]
set model [string trimleft $model]
puts "STP BENCH for [exec uname -r] on [exec uname -m]"
-puts "[exec uptime]"
+if {[file exists /etc/redhat-release]} {
+ puts [exec cat /etc/redhat-release]
+}
+puts "[exec uname -n]: [exec uptime]"
if {$nproc > 1} {
puts "processors: $nproc ([array size cpu] physical) $model"
} else {
puts "processors: $nproc $model"
}
+set mem [split [exec cat /proc/meminfo] \n]
+puts "[lindex $mem 0] [lindex $mem 1]"
puts "--------------------------------------"
# load the modules
-if {[catch {exec ./check_modules} res]} {
+if {[catch {exec stp_check} res]} {
puts $res
exit -1
}
@@ -60,6 +87,9 @@ if {[catch {exec ./ttest 4} res1]} {
set r_overhead [lindex $res1 0]
set w_overhead [lindex $res1 1]
+puts "function call overhead = $r_overhead ns"
+puts "--------------------------------------"
+
set res2 [do_time bench 4]
set t_kprobe [expr [lindex $res2 0] - $r_overhead]
set t_jprobe [expr [lindex $res2 1] - $w_overhead]
@@ -91,9 +121,10 @@ set res2 [do_time bench_io1 1]
set t_printf [expr [lindex $res2 0] - $r_overhead - $t_kprobe]
set t_print [expr [lindex $res2 1] - $w_overhead - $t_kprobe]
-puts "NETLINK"
-puts "_stp_printf on 100 chars = $t_printf ns"
-puts "_stp_print on 100 chars = $t_print ns"
+puts "PROCFS"
+puts "_stp_printf on 100 chars = $t_printf ns."
+puts "_stp_print on 100 chars = $t_print ns."
+puts "Transport failures: $Failures"
puts "--------------------------------------"
exec sleep 4
@@ -103,9 +134,9 @@ set t_printf [expr [lindex $res2 0] - $r_overhead - $t_kprobe]
set t_print [expr [lindex $res2 1] - $w_overhead - $t_kprobe]
puts "RELAYFS"
-puts "_stp_printf on 100 chars = $t_printf ns"
-puts "_stp_print on 100 chars = $t_print ns"
+puts "_stp_printf on 100 chars = $t_printf ns."
+puts "_stp_print on 100 chars = $t_print ns."
+puts "Transport failures: $Failures"
puts "--------------------------------------"
-exec rm xxx
exec /bin/rm -f stpd_cpu*
diff --git a/runtime/probes/bench/stp b/runtime/probes/bench/stp
deleted file mode 100755
index c350f4e6..00000000
--- a/runtime/probes/bench/stp
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-if [ -n "$1" ]
-then
- modulename=$1
-else
- echo "Usage: stp modulename"
- exit
-fi
-
-RELAYFS=`grep " relayfs_poll" /boot/System.map-\`uname -r\``
-if [ -z "$RELAYFS" ]
-then
- RELAYFS=`lsmod | grep relayfs`
- if [ -z "$RELAYFS" ]
- then
- /sbin/insmod ../../relayfs/relayfs.ko
- fi
-fi
-
-if [ ! -d "/mnt/relay" ]
-then
- mkdir /mnt/relay
-fi
-
-MOUNT=`mount | grep relayfs |awk '{print $1}'`
-if [ "$MOUNT" != "relayfs" ]
-then
- mount -t relayfs relayfs /mnt/relay
-fi
-
-STP_CONTROL=`lsmod | grep stp_control |awk '{print $1}'`
-if [ "$STP_CONTROL" != "stp_control" ]
-then
- /sbin/insmod ../../transport/stp-control.ko
-fi
-
-#/sbin/insmod $modulename
-
-# print to screen only
-#../../stpd/stpd -p $modulename
-
-# print to screen and log to files (file logging only if #define STP_NETLINK_ONLY commented out in module)
-#../../stpd/stpd $modulename
-
-# no screen, log to files (file logging only if #define STP_NETLINK_ONLY commented out in module)
-../../stpd/stpd -mq $modulename
diff --git a/runtime/probes/bench/targets b/runtime/probes/bench/targets
index b8328f15..6c89c8d7 100644
--- a/runtime/probes/bench/targets
+++ b/runtime/probes/bench/targets
@@ -1,5 +1,7 @@
bench
bench_io1
bench_io2
+bench_io3
+bench_io4
bench_ret
bench_multi
diff --git a/runtime/probes/bench/trans_bench b/runtime/probes/bench/trans_bench
new file mode 100755
index 00000000..bfa368d7
--- /dev/null
+++ b/runtime/probes/bench/trans_bench
@@ -0,0 +1,172 @@
+#!/usr/bin/tclsh
+# -*- tcl -*-
+
+proc do_time {module n buf} {
+ global Failures
+
+ # start kprobes
+ if {[catch {exec ../../stpd/stpd -vb $buf -mq $module.ko > xxx &} pid]} {
+ puts $pid
+ exit -1
+ }
+
+ exec sleep 2
+
+ # get the timings while kprobes running
+ if {[catch {exec ./itest $n} res2]} {
+ puts "itest failed: $res2"
+ exit -1
+ }
+
+ exec sleep 4
+ # terminate kprobes
+ if {[catch {exec kill -s SIGINT $pid} res]} {
+ puts "Kill failed: $res"
+ }
+
+ exec sleep 4
+
+ # look for warnings
+ exec tail xxx >xxx.tail
+ if {[catch {open xxx.tail r} fd]} {
+ puts "Cannot open test output\n"
+ exit -1
+ }
+
+ set Failures 0
+ while {[gets $fd line] >= 0} {
+ if {[regexp {^\033\[33mWARNING: \033\[0mThere were ([0-9]*) transport failures.} $line match var]} {
+ set Failures $var
+ break
+ }
+ }
+ close $fd
+ #exec /bin/rm -f xxx xxx.out
+ return $res2
+}
+
+######## START HERE ###########
+
+
+set nproc [exec grep ^processor /proc/cpuinfo | wc -l]
+if {![catch {exec grep "physical id" /proc/cpuinfo} phyid]} {
+ foreach phy [split $phyid \n] {
+ set cpu($phy) 1
+ }
+}
+set model [exec grep "model name" /proc/cpuinfo]
+set model [lindex [split $model \n] 0]
+set model [string range $model [expr [string first : $model]+1] end]
+set model [string trimleft $model]
+
+puts "TRANS BENCH for [exec uname -r] on [exec uname -m]"
+if {[file exists /etc/redhat-release]} {
+ puts [exec cat /etc/redhat-release]
+}
+puts "[exec uname -n]: [exec uptime]"
+if {$nproc > 1} {
+ puts "processors: $nproc ([array size cpu] physical) $model"
+} else {
+ puts "processors: $nproc $model"
+}
+set mem [split [exec cat /proc/meminfo] \n]
+puts "[lindex $mem 0] [lindex $mem 1]"
+puts "--------------------------------------"
+
+# load the modules
+if {[catch {exec ./check_modules} res]} {
+ puts $res
+ exit -1
+}
+
+# warmup
+exec ./itest 20 > /dev/null
+
+set res1 [do_time bench 1 1]
+set call_overhead [lindex $res1 0]
+
+puts "Function call plus kprobe overhead = $call_overhead ns per call"
+puts "--------------------------------------"
+
+
+set max 5
+set n 1
+set buf 1
+while {$buf <= 64 && $n < $max} {
+ set Failures 0
+ while {!$Failures && $n < $max} {
+ set res2 [do_time bench_io1 $n $buf]
+ set t_printf [expr [lindex $res2 0] - $call_overhead]
+ set total_print [lindex $res2 1]
+ puts "PROCFS with ${buf}MB buffers"
+ puts "_stp_printf on 100 chars = $t_printf ns / call system + user time."
+ if {$t_printf < 0} {
+ puts "res2=$res2"
+ exit
+ }
+ puts "_stp_printf of [expr $n * 100]MB in $total_print secs real time."
+ puts "Transfer rate = [format "%6.2f" [expr ($n * 100)/$total_print]] MB/sec"
+ puts "Transport failures: $Failures"
+ puts "--------------------------------------"
+ if {$Failures == 0} {incr n}
+ }
+ set buf [expr $buf + $buf]
+}
+
+set max 11
+set n 1
+set buf 1
+while {$buf <= 64 && $n < $max} {
+ set Failures 0
+ while {!$Failures && $n < $max} {
+ set res2 [do_time bench_io2 $n $buf]
+ set t_printf [expr [lindex $res2 0] - $call_overhead]
+ set total_print [lindex $res2 1]
+ puts "RELAYFS with ${buf}MB buffers"
+ puts "_stp_printf on 100 chars = $t_printf ns / call system + user time."
+ if {$t_printf < 0} {
+ puts "res2=$res2"
+ exit
+ }
+ puts "_stp_printf of [expr $n * 100]MB in $total_print secs real time."
+ puts "Transfer rate = [format "%6.2f" [expr ($n * 100)/$total_print]] MB/sec"
+ puts "Transport failures: $Failures"
+ puts "--------------------------------------"
+ if {$Failures == 0} {incr n}
+ }
+ set buf [expr $buf + $buf]
+}
+
+set Failures 0
+set buf 1
+set res2 [do_time bench_io3 1 $buf]
+set t_printf [expr [lindex $res2 0] - $call_overhead]
+set total_print [lindex $res2 1]
+puts "PROCFS with ${buf}MB buffers"
+puts "_stp_printf on 1000 chars = $t_printf ns / call system + user time."
+if {$t_printf < 0} {
+ puts "res2=$res2"
+ exit
+}
+puts "_stp_printf of 1GB in $total_print secs real time."
+puts "Transfer rate = [format "%6.2f" [expr 1000/$total_print]] MB/sec"
+puts "Transport failures: $Failures"
+puts "--------------------------------------"
+
+set Failures 0
+set buf 1
+set res2 [do_time bench_io4 1 $buf]
+set t_printf [expr [lindex $res2 0] - $call_overhead]
+set total_print [lindex $res2 1]
+puts "RELAYFS with ${buf}MB buffers"
+puts "_stp_printf on 1000 chars = $t_printf ns / call system + user time."
+if {$t_printf < 0} {
+ puts "res2=$res2"
+ exit
+}
+puts "_stp_printf of 1GB in $total_print secs real time."
+puts "Transfer rate = [format "%6.2f" [expr 1000/$total_print]] MB/sec"
+puts "Transport failures: $Failures"
+puts "--------------------------------------"
+
+exec /bin/rm -f stpd_cpu*