[Assorted-commits] SF.net SVN: assorted:[1164] ydb/trunk/tools
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-02-04 10:44:06
|
Revision: 1164 http://assorted.svn.sourceforge.net/assorted/?rev=1164&view=rev Author: yangzhang Date: 2009-02-04 10:44:03 +0000 (Wed, 04 Feb 2009) Log Message: ----------- - Added stperf benchmark, showing no speedup (and in fact some slow-down) as we scale up the number of parallel senders. - Changed nc to the more reliable socat (after encountering problems with bg-ing nc) - Changed the scaling plots to depict speedup rather than time. Modified Paths: -------------- ydb/trunk/tools/analysis.py ydb/trunk/tools/test.bash Added Paths: ----------- ydb/trunk/tools/stperf.cc ydb/trunk/tools/stperf.mk Modified: ydb/trunk/tools/analysis.py =================================================================== --- ydb/trunk/tools/analysis.py 2009-02-04 09:26:12 UTC (rev 1163) +++ ydb/trunk/tools/analysis.py 2009-02-04 10:44:03 UTC (rev 1164) @@ -169,15 +169,37 @@ pngpath.symlink(symlink) def mtcp(datpath): + def xform(d): + d['s'] = 1. / d['t'] + return d res = logextract(datpath, 'n', [ r'=== n=(?P<n>\d+)', - r'real\s+0m(?P<t>[0-9\.]+)s' ]) - errorbar(res['n'], res['t mean'], res['t sd']) - title('Time to send a large message (6888896 bytes)') + r'real\s+0m(?P<t>[0-9\.]+)s' ], + xform) + errorbar(res['n'], + res['s mean']/res['s mean'][0], + res['s sd']/res['s mean'][0]) + title('Scaling of sending large message using socat (6888896 bytes)') xlabel('Number of parallel senders') - ylabel('Time (ms)') + ylabel('Speedup') savefig('mtcp.png') +def stperf(datpath): + def xform(d): + d['s'] = 1. / d['t'] + return d + res = logextract(datpath, 'n', + [ r'=== n=(?P<n>\d+)', + r'real\s+0m(?P<t>[0-9\.]+)s' ], + xform) + errorbar(res['n'], + res['s mean']/res['s mean'][0], + res['s sd']/res['s mean'][0]) + title('Scaling of sending large message using ST (6888896 bytes)') + xlabel('Number of parallel senders') + ylabel('Speedup') + savefig('stperf.png') + def main(argv): if len(argv) <= 1: print >> sys.stderr, 'Must specify a command' @@ -187,6 +209,8 @@ run(*argv[2:] if len(argv) > 2 else ['single-log', 'multi-log']) elif argv[1] == 'mtcp': mtcp('mtcp-log') + elif argv[1] == 'stperf': + stperf('stperf-log') else: print >> sys.stderr, 'Unknown command:', argv[1] Added: ydb/trunk/tools/stperf.cc =================================================================== --- ydb/trunk/tools/stperf.cc (rev 0) +++ ydb/trunk/tools/stperf.cc 2009-02-04 10:44:03 UTC (rev 1164) @@ -0,0 +1,74 @@ +// Simple send/recv client/server demo, transferring a large message. Useful +// for scalability tests. + +#include <boost/bind.hpp> +#include <commons/st/st.h> +#include <cstdlib> +#include <iostream> +#include <st.h> +#include <unistd.h> + +using namespace boost; +using namespace commons; +using namespace std; + +enum { port = 9876, size = 100000000 }; // 100mb +char *rbuf, *sbuf, *host; +bool do_r, do_s; +int n, my_i; + +inline size_t bstart(int i) { return i * size / n; } +inline size_t bend(int i) { return i == n - 1 ? size : (i+1) * size / n; } + +void rr(int i, st_netfd_t c) { + st_read_fully(c, rbuf + bstart(i), bend(i) - bstart(i), -1); +} + +void r() { + if (do_r) { + vector<st_thread_t> ts; + st_netfd_t l = st_tcp_listen(port); + for (int i = 0; i < n; i++) { + st_netfd_t c = st_accept(l, 0, 0, -1); + ts.push_back(st_spawn(boost::bind(rr, i, c))); + } + for (int i = 0; i < n; i++) + st_join(ts[i]); + } +} + +void s() { + if (do_s) { + st_netfd_t s = st_tcp_connect(host, port, -1); + st_write(s, sbuf + bstart(my_i), bend(my_i) - bstart(my_i), -1); + } +} + +int main(int argc, char **argv) { + host = strdup("localhost"); + n = 1; + int opt; + while ((opt = getopt(argc, argv, "i:n:rs:")) != -1) { + switch (opt) { + case 'i': my_i = atoi(optarg); break; + case 'n': n = atoi(optarg); break; + case 'r': do_r = true; break; + case 's': do_s = true; host = strdup(optarg); break; + } + } + cout << "n=" << n << " i=" << my_i + << " start=" << bstart(my_i) << " end=" << bend(my_i) << endl; + if (!(do_r || do_s)) do_r = do_s = true; + rbuf = new char[size]; + sbuf = new char[size]; + memset(rbuf, 0, size); + memset(sbuf, 0, size); + + st_init(); + st_thread_t t0 = st_spawn(r); + if (do_r && do_s) st_usleep(10000); + st_thread_t t1 = st_spawn(s); + st_join(t1); + st_join(t0); + return 0; +} Added: ydb/trunk/tools/stperf.mk =================================================================== --- ydb/trunk/tools/stperf.mk (rev 0) +++ ydb/trunk/tools/stperf.mk 2009-02-04 10:44:03 UTC (rev 1164) @@ -0,0 +1,4 @@ +CXXFLAGS += -Wall +LDFLAGS += -static +LDLIBS += -lst -lstx -lresolv +all: stperf Modified: ydb/trunk/tools/test.bash =================================================================== --- ydb/trunk/tools/test.bash 2009-02-04 09:26:12 UTC (rev 1163) +++ ydb/trunk/tools/test.bash 2009-02-04 10:44:03 UTC (rev 1164) @@ -200,6 +200,11 @@ parremote node-setup-ydb-2 } +setup-stperf() { + parscp stperf.{cc,mk} ^:/tmp/ + parssh make -C /tmp/ -f stperf.mk +} + full-setup() { init-setup setup-deps @@ -345,13 +350,20 @@ mtcp-helper() { local leader=$1 n=$(( $# - 1 )) - tagssh $leader 'pkill nc' + tagssh $leader 'pkill socat' shift - while (( $# > 0 )) ; do - tagssh $1 "sleep .5 ; time seq $((1000000/n)) | nc $leader 9876" & + for i in `seq $n` ; do + tagssh $1 " + sleep .2 + ( time seq $((1000000/n)) | socat - TCP4:$leader:$((9876+i)) ) 2>&1 | + fgrep real" & shift done - tagssh $leader "nc -l 9876 > /dev/null" + tagssh $leader " + for i in \`seq $n\` ; do + socat TCP4-LISTEN:\$((9876+i)),reuseaddr - > /dev/null & + done + wait" wait } @@ -376,6 +388,42 @@ hosts="$orighosts" } +stperf-helper() { + local leader=$1 n=$(( $# - 1 )) + shift + parssh "pkill stperf || true" + tagssh $leader "/tmp/stperf -r -n $n > /dev/null" & + sleep .1 + for i in `seq $n` ; do + tagssh $1 " + ( time /tmp/stperf -s $leader -i $((i-1)) -n $n ) 2>&1 | + fgrep real" & + shift + done + wait +} + +stperf() { + hostargs stperf-helper +} + +exp-stperf() { + local out=stperf-log-$(date +%Y-%m-%d-%H:%M:%S-%N) + local orighosts="$hosts" maxn=$(( $(echo $hosts | wc -w) - 1 )) + ln -sf $out stperf-log + for n in `seq $maxn` ; do # configurations + for i in {1..3} ; do # trials + echo === n=$n i=$i === + echo === n=$n i=$i === > `tty` + stperf + sleep 1 + echo + done + hosts="${hosts% *}" + done >& $out + hosts="$orighosts" +} + stop-helper() { tagssh $1 'pkill -sigint ydb' } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |