diff options
author | hunt <hunt> | 2006-03-15 09:40:44 +0000 |
---|---|---|
committer | hunt <hunt> | 2006-03-15 09:40:44 +0000 |
commit | 14cbcf6ac46e0579228bcc2246382d76a6b9220c (patch) | |
tree | f1283ead0f9aa46f22599322db5181d953aa5a6a | |
parent | f425170459496ec7267751106bc0d0b0f28fc45a (diff) | |
download | systemtap-steved-14cbcf6ac46e0579228bcc2246382d76a6b9220c.tar.gz systemtap-steved-14cbcf6ac46e0579228bcc2246382d76a6b9220c.tar.xz systemtap-steved-14cbcf6ac46e0579228bcc2246382d76a6b9220c.zip |
Added multiple threads and better cpuspeed handling.
-rw-r--r-- | runtime/bench2/README | 1 | ||||
-rw-r--r-- | runtime/bench2/bench.rb | 130 | ||||
-rw-r--r-- | runtime/bench2/results.txt | 61 | ||||
-rwxr-xr-x | runtime/bench2/run_bench | 17 | ||||
-rwxr-xr-x | runtime/bench2/stap_bench | 1 |
5 files changed, 143 insertions, 67 deletions
diff --git a/runtime/bench2/README b/runtime/bench2/README index 626d4675..6bbf2604 100644 --- a/runtime/bench2/README +++ b/runtime/bench2/README @@ -8,6 +8,7 @@ To try the tests: You will need ruby installed. "yum install ruby" or "up2date ruby" to get it. + ---- FILES ---- a.st - sample script test file b.st - sample script test file diff --git a/runtime/bench2/bench.rb b/runtime/bench2/bench.rb index 2c21b381..cf1fb90d 100644 --- a/runtime/bench2/bench.rb +++ b/runtime/bench2/bench.rb @@ -1,16 +1,32 @@ +# Benchmark Class for SystemTap +# Copyright (C) 2006 Red Hat Inc. +# +# This file is part of systemtap, and is free software. You can +# redistribute it and/or modify it under the terms of the GNU General +# Public License (GPL); either version 2, or (at your option) any +# later version. + +# Where to fine laptop frequency files +MAXFILE = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" +MINFILE = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" + +# more constants +PROCFS = 1 +RELAYFS= 2 + +at_exit {Bench.done} + class Bench def initialize(desc) @desc = desc @code = nil @file = nil + @trans = 1 @failures = "" - @results = 0 + @results = [] if @@printed_header == 0 print_header end - if @@ftime == 0 - @@ftime = `./itest 5`.to_i - end if @@stpd.nil? for path in ['/usr/libexec/systemtap/stpd', '/usr/local/libexec/systemtap/stpd'] if File.exist?(path) @@ -27,22 +43,30 @@ class Bench end end end + Signal.trap("INT") do + cleanup + exit + end end - attr_writer :code, :file + attr_writer :code, :file, :trans attr_reader :failures, :results def run - Signal.trap("INT") do - cleanup - exit - end compile load - @results = `./itest 1`.to_i - @@ftime - sleep 5 + @results = [] + @failures = "" + @@num_threads.each do |threads| + bench = []; sum=0 + threads.times {|cpu| fork {exec "./itest 1 > #{@dir}/bench#{cpu}"}} + threads.times {Process.waitpid(-1)} + threads.times {|x| bench[x] = `cat #{@dir}/bench#{x}`.split[0].to_i - @@ftime} + threads.times {|x| sum = sum + bench[x]} + @results[threads-1] = sum / (threads * threads) + end `sudo killall -HUP stpd` - `tail #{@dir}/xxx > #{@dir}/xxx.out` + sleep 5 File.open("#{@dir}/xxx.out") do |file| file.each_line {|line| @failures += line if line =~ /WARNING/} end @@ -52,7 +76,28 @@ class Bench def print if @results - printf("runtime: %-20s\t%d\n", @desc, @results) + if self.kind_of? Stapbench + printf("S") + else + printf("R") + end + if @trans == RELAYFS + printf("*") + else + printf(" ") + end + printf(": %-20s", @desc) + @results.each {|x| printf("\t%d",x) unless x.nil? } + printf("\n") + if @failures != "" + printf("%s\n", @failures) + end + end + end + + def Bench.done + if @@minfreq != 0 + `sudo /bin/sh -c \"echo #{@@minfreq} > #{MINFILE}\"` end end @@ -61,20 +106,24 @@ class Bench protected - # function call overhead @@ftime = 0 @@printed_header = 0 @@stpd = nil @@runtime = nil + @@num_threads = [] + @@minfreq = 0 def cleanup `/bin/rm -f stap.out` if File.exists?("stap.out") `/bin/rm -f bench.stp` if File.exists?("bench.stp") `/bin/rm -rf #{@dir}` unless @dir.nil? + `/bin/rm -f stpd_cpu* probe.out` end def load - fork do exec "sudo #{@@stpd} -rmq #{@dir}/bench.ko > #{@dir}/xxx" end + args = "-rmq" + if @trans == RELAYFS then args = "-mq" end + fork do exec "sudo #{@@stpd} #{args} #{@dir}/bench.ko > #{@dir}/xxx 2> #{@dir}/xxx.out" end sleep 5 end @@ -125,6 +174,17 @@ obj-m := bench.o def print_header @@printed_header = 1 nproc=`grep ^processor /proc/cpuinfo`.count("\n") + if nproc >= 16 + @@num_threads = [1,2,4,16] + elsif nproc >= 8 + @@num_threads = [1,2,4,8] + elsif nproc >= 4 + @@num_threads = [1,2,4] + elsif nproc >= 2 + @@num_threads = [1,2] + else + @@num_threads = [1] + end physical_cpus=`grep "physical id" /proc/cpuinfo`.split("\n").uniq.length model=`grep "model name" /proc/cpuinfo`.match(/(model name\t: )([^\n]*)/)[2] puts "SystemTap BENCH2 \t" + `date` @@ -150,39 +210,35 @@ obj-m := bench.o check_cpuspeed @@ftime = `./itest 5`.to_i puts "For comparison, function call overhead is #@@ftime nsecs." - puts "Times below are in nanoseconds and include kprobe overhead." + puts "Times below are nanoseconds per probe and include kprobe overhead." puts "-"*64 + puts "+--- S = Script, R = Runtime" + puts "|+-- * = Relayfs \tThreads" + printf "|| NAME " + @@num_threads.each {|n| printf("\t%d",n)} + printf "\n" end def check_cpuspeed - maxfile = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" - minfile = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" - if File.exist?(maxfile) - maxfreq = `cat #{maxfile}`.to_i - minfreq = `cat #{minfile}`.to_i - if minfreq != maxfreq - `sudo /bin/sh -c \"echo #{maxfreq} > #{minfile}\"` - puts "CPU frequency scaling detected and disabled." - puts "After testing, enable it again by typing (as root)" - puts "echo #{minfreq} > #{minfile}" - puts "-"*64 - end + if @@minfreq == 0 && File.exist?(MAXFILE) + maxfreq = `cat #{MAXFILE}`.to_i + @@minfreq = `cat #{MINFILE}`.to_i + if @@minfreq != maxfreq + `sudo /bin/sh -c \"echo #{maxfreq} > #{MINFILE}\"` + sleep 1 + end end end end class Stapbench < Bench - def print - if @results - printf("script : %-20s\t%d\n", @desc, @results) - end - end - protected def load # we do this in several steps because the compilation phase can take a long time - `stap -kvvp4 -m bench bench.stp &> stap.out` + args = "-kvvp4" + if @trans == RELAYFS then args = "-bkvvp4" end + `stap #{args} -m bench bench.stp &> stap.out` IO.foreach("stap.out") {|line| @dir = line if line =~ /Created temporary directory/} @dir = @dir.match(/"([^"]*)/)[1] if !File.exist?("#{@dir}/bench.ko") @@ -190,7 +246,9 @@ class Stapbench < Bench cleanup exit end - fork do exec "sudo #{@@stpd} -rmq #{@dir}/bench.ko > #{@dir}/xxx" end + args = "-rmq" + if @trans == RELAYFS then args = "-mq" end + fork do exec "sudo #{@@stpd} #{args} #{@dir}/bench.ko > #{@dir}/xxx 2> #{@dir}/xxx.out" end sleep 5 end diff --git a/runtime/bench2/results.txt b/runtime/bench2/results.txt index a58f45dd..d1deeb40 100644 --- a/runtime/bench2/results.txt +++ b/runtime/bench2/results.txt @@ -1,32 +1,43 @@ -SystemTap BENCH2 Thu Mar 9 00:24:53 PST 2006 -kernel: 2.6.15-1.2025_FC5 i686 -Fedora Core release 4.92 (Pre-FC5) -monkey2: 00:24:53 up 2:48, 3 users, load average: 0.01, 0.05, 0.01 -processors: 1 Intel(R) Pentium(R) M processor 1.70GHz -MemTotal: 515200 kB MemFree: 73264 kB +SystemTap BENCH2 Wed Mar 15 01:00:52 PST 2006 +kernel: 2.6.9-34.ELsmp x86_64 +Red Hat Enterprise Linux WS release 4 (Nahant Update 3) +tiger: 01:00:52 up 51 min, 1 user, load average: 1.46, 1.29, 0.87 +processors: 4 (2 physical) Intel(R) Xeon(TM) CPU 2.80GHz +MemTotal: 1025428 kB MemFree: 750220 kB ---------------------------------------------------------------- -For comparison, function call overhead is 378 nsecs. -Times below are in nanoseconds and include kprobe overhead. +For comparison, function call overhead is 721 nsecs. +Times below are nanoseconds per probe and include kprobe overhead. ---------------------------------------------------------------- -runtime: empty probe 514 -script : empty probe 543 -runtime: printf 100 chars 1932 -script : printf 100 chars 1947 -runtime: printf 5 integers 3078 -script : printf 5 integers 3127 -SystemTap BENCH2 Thu Mar 9 00:30:12 PST 2006 ++--- S = Script, R = Runtime +|+-- * = Relayfs Threads +|| NAME 1 2 4 +R : empty probe 1471 737 559 +S : empty probe 1556 784 594 +S : printf 100 chars 2178 1445 1148 +S*: printf 100 chars 2184 1290 1108 +R : printf 100 chars 2064 1333 1039 +R : printf 5 integers 3793 2006 1589 +S : printf 5 integers 3930 2136 1644 + + +SystemTap BENCH2 Wed Mar 15 01:20:41 PST 2006 kernel: 2.6.15-1.1830_FC4.huntsmp i686 Fedora Core release 4 (Stentz) -dragon: 00:30:12 up 3:02, 3 users, load average: 0.00, 0.00, 0.00 +dragon: 01:20:41 up 17:06, 8 users, load average: 0.01, 0.01, 0.00 processors: 2 (1 physical) Intel(R) Pentium(R) 4 CPU 2.60GHz -MemTotal: 2067716 kB MemFree: 1841188 kB +MemTotal: 2067716 kB MemFree: 1524232 kB ---------------------------------------------------------------- -For comparison, function call overhead is 795 nsecs. -Times below are in nanoseconds and include kprobe overhead. +For comparison, function call overhead is 812 nsecs. +Times below are nanoseconds per probe and include kprobe overhead. ---------------------------------------------------------------- -runtime: empty probe 1178 -script : empty probe 1372 -runtime: printf 100 chars 2408 -script : printf 100 chars 2504 -runtime: printf 5 integers 4048 -script : printf 5 integers 3590 ++--- S = Script, R = Runtime +|+-- * = Relayfs Threads +|| NAME 1 2 +R : empty probe 1172 884 +S : empty probe 1345 1117 +S : printf 100 chars 2515 2522 +S*: printf 100 chars 1996 1834 +R : printf 100 chars 2896 2735 +R : printf 5 integers 4919 4316 +S : printf 5 integers 5094 4501 + diff --git a/runtime/bench2/run_bench b/runtime/bench2/run_bench index 1f868ced..dad8c8ae 100755 --- a/runtime/bench2/run_bench +++ b/runtime/bench2/run_bench @@ -13,18 +13,23 @@ test0.code = "" test0.run test0.print +# script test to print 100 chars +test2a = Stapbench.new("printf 100 chars") +test2a.code = "printf(\"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\\n\")" +test2a.run +test2a.print + +test2a.trans = RELAYFS +test2a.run +test2a.print + # runtime test to print 100 chars test2 = Bench.new("printf 100 chars") -test2.code = "_stp_printf (\"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\\n\"); +test2.code = "(void)_stp_printf (\"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\\n\"); _stp_print_flush();" test2.run test2.print -# script test to print 100 chars -test2a = Stapbench.new("printf 100 chars") -test2a.code = "printf(\"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\\n\")" -test2a.run -test2a.print # runtime test to print 5 integers test3 = Bench.new("printf 5 integers") diff --git a/runtime/bench2/stap_bench b/runtime/bench2/stap_bench index b3b450d8..17b4b505 100755 --- a/runtime/bench2/stap_bench +++ b/runtime/bench2/stap_bench @@ -14,3 +14,4 @@ Dir["*.st"].each do |file| test.print end end + |