forked from nathanielherman/silo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datacollect.py
208 lines (164 loc) · 5.65 KB
/
datacollect.py
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/python
import os
import sys
import subprocess
try:
FILENAME = sys.argv[1]
except:
print sys.argv[0], 'outputfile [runtime=30] [rounds=5] [optional test arguments]'
sys.exit(0)
RUNTIME=30
ROUNDS=5
OTHER_OPTIONS=''
try:
if sys.argv[1] == '-h' or sys.argv[1] == '--help':
print sys.argv[0], 'outputfile [runtime=30] [rounds=5] [optional test arguments]'
sys.exit(0)
# will set these until we run out of arguments
RUNTIME = int(sys.argv[2])
ROUNDS = int(sys.argv[3])
OTHER_OPTIONS = sys.argv[4]
except: pass
CMD="out-perf.masstree/benchmarks/dbtest --runtime %s %s " % (RUNTIME, OTHER_OPTIONS)
CMD_HASHTABLE="out-perf.ht.masstree/benchmarks/dbtest --runtime %s %s " % (RUNTIME, OTHER_OPTIONS)
CMD_HASHTABLE_RMW="out-perf.ht.rmw.masstree/benchmarks/dbtest --runtime %s %s " % (RUNTIME, OTHER_OPTIONS)
CMD_RMW="out-perf.rmw.masstree/benchmarks/dbtest --runtime %s %s " % (RUNTIME, OTHER_OPTIONS)
MAKE_CMD_TEMPL='MODE=perf CC=gcc CXX=g++\ -std=c++11 %s make -j dbtest'
MAKE_CMD = MAKE_CMD_TEMPL % ''
MAKE_CMD_RMW = MAKE_CMD_TEMPL % 'STO_RMW=1'
MAKE_CMD_HASHTABLE = MAKE_CMD_TEMPL % 'HASHTABLE=1'
MAKE_CMD_HASHTABLE_RMW = MAKE_CMD_TEMPL % 'HASHTABLE=1 STO_RMW=1'
SINGLE_THREADED="--num-threads 1 --scale-factor 1 "
NTHREADS = 24
MANY_THREADS = lambda n: "--num-threads %d --scale-factor %d " % (n, n)
MANY_THREADED= MANY_THREADS(NTHREADS)
MBTA="-dmbta "
SILO="--disable-snapshots "
TPCC = '--bench tpcc '
YCSB = '--bench ycsb '
TYPES = ['neworder', 'payment', 'delivery', 'orderstatus', 'stocklevel']
OUTPUT_DIR="benchmarks/data"
DRY_RUN = False
BEST = False
def basic_test(testtype, impl, threads, rmw=False, hashtable=False):
cmd = CMD
if hashtable and rmw: cmd = CMD_HASHTABLE_RMW
elif hashtable: cmd = CMD_HASHTABLE
elif rmw: cmd = CMD_RMW
cmd += threads + impl + testtype
pts = []
neworders = []
for i in xrange(ROUNDS):
if DRY_RUN:
out = "111 222"
print cmd
else:
out = subprocess.check_output(cmd, shell=True)
outl = out.split(' ')
data = outl[0]
pts.append(float(data))
if len(outl) == 6:
neworders.append(float(outl[5]))
if len(neworders):
return repr((pts, neworders))
return repr(pts)
#sorted(pts)[len(pts)/2]
# return max(pts)
# return sum(pts) / len(pts)
def run_test(testname, testtype, impl, threads, fileobj):
fileobj.write("%s\n%s\n" % (testname, basic_test(testtype, impl, threads, rmw=
(testname=='readmywrites' or testname=='readmywrites_ht'),
hashtable=(testname=='ht' or testname=='readmywrites_ht'))))
def us_and_silo(testtype, threads, fileobj):
run_test('us', testtype, MBTA, threads, fileobj)
# run_test('ht', testtype, MBTA, threads, fileobj)
run_test('silo', testtype, SILO, threads, fileobj)
def simple_run(c):
if DRY_RUN:
print c
else:
os.system(c)
def ignore_run(c):
simple_run(c + ' > /dev/null 2> /dev/null')
def remake():
print MAKE_CMD
simple_run(MAKE_CMD)
print MAKE_CMD_HASHTABLE
simple_run(MAKE_CMD_HASHTABLE)
print MAKE_CMD_HASHTABLE_RMW
simple_run(MAKE_CMD_HASHTABLE_RMW)
print MAKE_CMD_RMW
simple_run(MAKE_CMD_RMW)
def patch_apply(name):
simple_run('patch -p1 < ' + name)
remake()
def patch_revoke(name):
simple_run('patch -p1 -R < ' + name)
def nosort_apply():
# this is kinda dumb, we could just pass a -D flag to make probably
simple_run('patch -p1 < nosort.patch')
remake()
def nosort_revoke():
simple_run('patch -p1 -R < nosort.patch')
def nostablesort_apply():
simple_run('patch -p0 < nostablesort.patch')
remake()
def nostablesort_revoke():
simple_run('patch -p0 -R < nostablesort.patch')
def nosort(testtype, threads, fileobj):
nosort_apply()
run_test('no sort', testtype, MBTA, threads, fileobj)
nosort_revoke()
def nostablesort(testtype, threads, fileobj):
nostablesort_apply()
run_test('no stable sort', testtype, MBTA, threads, fileobj)
nostablesort_revoke()
def rmw(testtype, threads, fileobj):
# patch_apply('rmw.patch')
run_test('readmywrites', testtype, MBTA, threads, fileobj)
# run_test('readmywrites_ht', testtype, MBTA, threads, fileobj)
# patch_revoke('rmw.patch')
def stdtest(f, testtype, threads, testname):
singlethr = threads==SINGLE_THREADED
f.write(testname + '\n')
us_and_silo(testtype, threads, f)
rmw(testtype, threads, f)
# if singlethr:
# for single threaded we also run a no sort test
# nosort(testtype, threads, f)
#remake()
f.write('\n')
def indiv_type(t):
idx = TYPES.index(t)
mix = ''
for i in xrange(len(TYPES)):
mix += '100,' if i==idx else '0,'
mix = mix[:-1] # remove trailing comma
return '-o --workload-mix=' + mix
def indiv_tpcc_tests(f, threads):
singlethr = threads==SINGLE_THREADED
for testname in TYPES:
f.write(testname + '\n')
testtype = TPCC + indiv_type(testname)
us_and_silo(testtype, threads, f)
rmw(testtype, threads, f)
if singlethr:
nosort(testtype, threads, f)
remake()
f.write('\n')
def tpcc():
f = open(OUTPUT_DIR + '/' + FILENAME, 'w')
stdtest(f, TPCC, SINGLE_THREADED, "1 thread")
for i in [4,8,16,24]:
stdtest(f, TPCC, MANY_THREADS(i), "%d threads" % i)
# indiv_tpcc_tests(f, SINGLE_THREADED)
f.close()
def ycsb():
f = open(OUTPUT_DIR + '/' + 'ycsb', 'w')
stdtest(f, YCSB, SINGLE_THREADED, "default")
stdtest(f, YCSB, MANY_THREADED, "%d threads" % NTHREADS)
f.close()
simple_run('mkdir ' + OUTPUT_DIR)
remake()
tpcc()
#ycsb()