forked from facebook/wdt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wdt_max_send_test.sh
executable file
·125 lines (100 loc) · 3.38 KB
/
wdt_max_send_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#! /bin/bash
# This is to regress/test the max ~22000Mbytes/sec transfer rate
# to get the highest (> 20G) rates you need:
# a) /dev/shm to be almost empty
# b) nothing else much running on your dev server
# c) run this a couple times
# modified from wdt_e2e_test.sh and fbonly/wdt_prof.sh
echo "Run this sender performance test from fbcode/ directory"
echo "or give full path to wdt binary to use and staging directory"
if [ -z "$1" ]; then
WDTBIN="_bin/wdt/wdt"
else
WDTBIN="$1"
fi
if [ -z "$2" ]; then
BASEDIR=/dev/shm/tmpWDT$USER
else
BASEDIR=$2
fi
AWK=gawk
# TEST_COUNT is an environment variable. It is set up by the python benchmarking
# script.
if [ -z $TEST_COUNT ]; then
TEST_COUNT=2
fi
if [ -z "$HOSTNAME" ] ; then
echo "HOSTNAME not set, will try with 'localhost'"
HOSTNAME=localhost
else
echo "Will self connect to HOSTNAME=$HOSTNAME"
fi
REMOTE=$HOSTNAME
SKIP_WRITES="true"
# TODO: switch to url
# Without throttling:
#WDTBIN_OPTS="-sleep_millis 1 -max_retries 3 -num_sockets 13"
# With, still gets almost same max (21G) with throttling set high enough
WDTBIN_OPTS="-sleep_millis 1 -max_retries 3 -num_ports 13 -transfer_id=$$
--avg_mbytes_per_sec=26000 --max_mbytes_per_sec=26001 --enable_checksum=false"
CLIENT_PROFILE_FORMAT="%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata \
%Mmax)k\n%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps\nCLIENT_PROFILE %U \
%S %e"
SERVER_PROFILE_FORMAT="%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata \
%Mmax)k\n%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps\nSERVER_PROFILE %U \
%S %e"
WDTNAME=`basename $WDTBIN`
WDTCMD="$WDTBIN $WDTBIN_OPTS"
mkdir -p $BASEDIR
DIR=`mktemp -d --tmpdir=$BASEDIR`
echo "Testing $WDTBIN in $DIR"
if [ -z "$DIR" ]; then
echo "Unable to create dir in $BASEDIR"
exit 1
fi
pkill -x $WDTNAME
mkdir $DIR/src
for size in 1k 64K 512K 1M 16M 256M 512M
do
base=inp$size
echo dd if=/dev/... of=$DIR/src/$base.1 bs=$size count=1
dd if=/dev/zero of=$DIR/src/$base.1 bs=$size count=1
for i in {2..32}
do
cp $DIR/src/$base.1 $DIR/src/$base.$i
done
done
echo "Done with staging src test files"
/usr/bin/time -f "$SERVER_PROFILE_FORMAT" $WDTCMD -directory $DIR/dst -run_as_daemon=true -skip_writes=$SKIP_WRITES > \
$DIR/server.log 2>&1 &
# wait for server to be up
#while [ `/bin/true | nc $REMOTE 22356; echo $?` -eq 1 ]
#do
# echo "Server not up yet...`date`..."
# sleep 0.5
#done
#echo "Server is up on $REMOTE 22356 - `date` - starting client run"
for ((i = 1; i <= TEST_COUNT; i++))
do
echo "starting ${i}th run"
TWO_PHASE_ARG=""
# every other run will be two_phases
[ $(($i % 2)) -eq 0 ] && TWO_PHASE_ARG="-two_phases"
/usr/bin/time -f "$CLIENT_PROFILE_FORMAT" $WDTCMD -directory $DIR/src \
-destination $REMOTE $TWO_PHASE_ARG |& tee $DIR/client$i.log
THROUGHPUT=`$AWK 'match($0, /.*Total sender throughput = ([0-9.]+)/, res) \
{print res[1]} END {}' $DIR/client$i.log`
echo "THROUGHPUT $THROUGHPUT"
TRANSFER_TIME=`$AWK 'match($0, /.*Total sender time = ([0-9.]+)/, res) \
{print res[1]} END {}' $DIR/client$i.log`
echo "TRANSFER_TIME $TRANSFER_TIME"
done
echo -n e | nc $REMOTE 22356
echo "Server logs:"
cat $DIR/server.log
MAXRATE=`$AWK 'match($0, /.*Total sender throughput = ([0-9.]+)/, res) {rate=res[1]; if (rate>max) max=rate} END {print max}' $DIR/client?.log`
echo "Deleting logs and staging in $DIR"
rm -rf $DIR
echo "Rate for $WDTBIN"
echo $MAXRATE
# all done