forked from tellproject/helper_scripts
/
expRunner.py
executable file
·344 lines (309 loc) · 12.5 KB
/
expRunner.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
#!/usr/bin/env python
from argparse import ArgumentParser
from ServerConfig import General
from ServerConfig import Storage
from ServerConfig import TellStore
from ServerConfig import Kudu
from ServerConfig import Hbase
from ServerConfig import Cassandra
from ServerConfig import Ramcloud
from ServerConfig import Microbench
from mbclient import startMBClient
from mbserver import startMBServer
from storage import *
from observer import *
from functools import partial
from unmount_memfs import unmount_memfs
import time
import os
import sys
import signal
import logging
logging.basicConfig()
if 'threading' in sys.modules:
del sys.modules['threading']
import gevent
import gevent.socket
import gevent.monkey
gevent.monkey.patch_all()
def sqliteOut():
storage = Storage.storage().__class__.__name__.lower()
if Storage.storage == TellStore:
storage = storage + "_{0}".format(TellStore.approach)
numStorages = len(Storage.servers) + len(Storage.servers1)
numMBServers = len(Microbench.servers0) + len(Microbench.servers1)
numClients = Microbench.clients
numAnalytical = Microbench.analyticalClients
res = "{0}_{1}storages_{2}clients_{3}scans".format(storage, numStorages, numClients, numAnalytical)
res += "_{0}infinioBatch".format(Microbench.infinioBatch)
return res
def runMBench(outdir, onlyPopulation = False):
# do as for many experiments we have to run
## start storages
storageClients = startStorage()
signal.signal(signal.SIGINT, partial(exitGracefully, storageClients))
print "Storage started"
## start microbenchmark server
mbObserver = Observer("Started mbench server")
serverClients = startMBServer([mbObserver])
mbObserver.waitFor(len(Microbench.servers0) + len(Microbench.servers1))
time.sleep(2)
print "Server started... Continue with population"
clients = Microbench.clients
Microbench.clients = 10*(len(Microbench.servers0) + len(Microbench.servers1)) - 1
res = startMBClient(True, "{0}/{1}_population".format(outdir, sqliteOut()))
Microbench.clients = clients
if res != 0:
print "Population failed"
exit(res)
print "Population done"
if not onlyPopulation:
res = startMBClient(False, "{0}/{1}".format(outdir, sqliteOut()))
if res != 0:
print "Benchmark failed"
exit(res)
for client in serverClients:
client.kill()
for client in storageClients:
client.kill()
for client in serverClients:
client.join()
for client in storageClients:
client.join()
unmount_memfs()
def configForAnalytics():
Microbench.analyticalClients = 1
Microbench.clients = 0
Microbench.infinioBatch = 16
if len(Microbench.servers0) > 0:
Microbench.servers1 = []
while len(Microbench.servers0) > 1:
del Microbench.servers0[-1]
def configGetPut():
Microbench.analyticalClients = 0
Microbench.clientThreads = 4
Microbench.clients = 10*(len(Microbench.servers0) + len(Microbench.servers1)) - 1
Microbench.threads = 1 if Storage.storage == TellStore else 4
Microbench.insertProb = 0.166
Microbench.updateProb = 0.166
Microbench.deleteProb = 0.166
def configGetOnly():
configGetPut()
Microbench.insertProb = 0.0
Microbench.updateProb = 0.0
Microbench.deleteProb = 0.0
def configMixed():
configGetPut()
Microbench.analyticalClients = 1
def experiment1a(outdir):
# edit Microbenchmark class
configGetPut()
runMBench(outdir)
def experiment1a_singlebatch(outdir):
configGetPut()
old = Microbench.infinioBatch
Microbench.infinioBatch = 1
runMBench(outdir)
Microbench.infinioBatch = old
def experiment1b(outdir):
configGetOnly()
runMBench(outdir)
def experiment2a(outdir):
configForAnalytics()
runMBench(outdir)
def experiment3(outdir):
configMixed()
runMBench(outdir)
def experiment3a(outdir):
oldValue = Microbench.oltpWaitTime
Microbench.oltpWaitTime = 3400 * Microbench.txBatch # 35000 per sec for 119 clients
configGetOnly()
Microbench.analyticalClients = 1
runMBench(outdir)
Microbench.oltpWaitTime = oldValue
def experiment3b(outdir):
oldValue = Microbench.oltpWaitTime
Microbench.oltpWaitTime = 3400 * Microbench.txBatch # 35000 per sec for 119 clients
configMixed()
runMBench(outdir)
Microbench.oltpWaitTime = oldValue
def varyBatching(experiment, outdir):
for i in [1,2,4,8,16,32,64]:
Microbench.infinioBatch = i
experiment(outdir)
Microbench.infinioBatch = 16
def scalingExperiment(experiment, outdir, numNodes):
Storage.master = 'euler07'
Storage.servers = []
Storage.servers1 = []
servers = ['euler04', 'euler05', 'euler06', 'euler02']
servers.reverse()
mservers0 = ['euler03', 'euler08', 'euler09', 'euler10', 'euler11', 'euler01']
mservers1 = servers + ['euler03', 'euler08', 'euler09', 'euler10', 'euler11', 'euler01']
mservers0.reverse()
mservers1.reverse()
Microbench.servers0 = []
Microbench.servers1 = []
while len(Storage.servers) < numNodes:
Storage.servers.append(servers.pop())
while 3*len(Storage.servers) > len(Microbench.servers0) + len(Microbench.servers1):
if len(mservers0) != 0:
Microbench.servers0.append(mservers0.pop())
else:
Microbench.servers1.append(mservers1.pop())
experiment(outdir)
def runOnTell(experiment, outdir, numNodes):
Microbench.txBatch = 200
for approach in ["columnmap", "rowstore", "logstructured"]:
TellStore.approach = approach
TellStore.setDefaultMemorySizeAndScanThreads()
for num in numNodes:
experiment(outdir, num)
def runOnOthers(experiment, outdir, numNodes):
Microbench.txBatch = 50
for num in numNodes:
experiment(outdir,num)
def runAllBenchmarks(outdir, experiments, ignore_warnings):
if Storage.storage == TellStore:
runOn = runOnTell
else:
runOn = runOnOthers
if len(experiments) == 0 or "experiment1a" in experiments:
print "#######################################"
print " RUN EXPERIMENT 1a"
print "#######################################"
o = '{0}/experiment1a'.format(outdir)
if os.path.isdir(o):
if ignore_warnings:
print ('[WARNING] {0} exists already and its content might be overwritten now.'.format(o))
else:
raise RuntimeError('{0} exists'.format(o))
else:
os.mkdir(o)
runOn(partial(scalingExperiment, experiment1a), o, [1,2,3,4])
if len(experiments) == 0 or "experiment1b" in experiments:
# Experiment 1b
print "#######################################"
print " RUN EXPERIMENT 1b"
print "#######################################"
o = '{0}/experiment1b'.format(outdir)
if os.path.isdir(o):
if ignore_warnings:
print ('[WARNING] {0} exists already and its content might be overwritten now.'.format(o))
else:
raise RuntimeError('{0} exists'.format(o))
else:
os.mkdir(o)
runOn(partial(scalingExperiment, experiment1b), o, [1,2,3,4])
#if (len(experiments) == 0 or "experiment1c" in experiments) and Storage.storage == TellStore:
# Experiment 1c
# No experiment needed here (inserts are measured for all experiments)
# o = '{0}/experiment1c'.format(outdir)
# if os.path.isdir(o):
# if ignore_warnings:
# print ('[WARNING] {0} exists already and its content might be overwritten now.'.format(o))
# else:
# raise RuntimeError('{0} exists'.format(o))
# else:
# os.mkdir(o)
# runOnTell(partial(scalingExperiment, experiment1c), o, [1,2,3,4])
if len(experiments) == 0 or "experiment1d" in experiments:
# Experiment 1d
print "#######################################"
print " RUN EXPERIMENT 1d"
print "#######################################"
o = '{0}/experiment1d'.format(outdir)
if os.path.isdir(o):
if ignore_warnings:
print ('[WARNING] {0} exists already and its content might be overwritten now.'.format(o))
else:
raise RuntimeError('{0} exists'.format(o))
else:
os.mkdir(o)
runOn(partial(scalingExperiment, partial(varyBatching, experiment1a)), o, [2])
if len(experiments) == 0 or "experiment2a" in experiments:
# Experiment 2a
print "#######################################"
print " RUN EXPERIMENT 2a"
print "#######################################"
o = '{0}/experiment2a'.format(outdir)
if os.path.isdir(o):
if ignore_warnings:
print ('[WARNING] {0} exists already and its content might be overwritten now.'.format(o))
else:
raise RuntimeError('{0} exists'.format(o))
else:
os.mkdir(o)
runOn(partial(scalingExperiment, experiment2a), o, [1,2,3,4])
if len(experiments) == 0 or "experiment3" in experiments:
# Experiment 3
print "#######################################"
print " RUN EXPERIMENT 3"
print "#######################################"
o = '{0}/experiment3'.format(outdir)
if os.path.isdir(o):
if ignore_warnings:
print ('[WARNING] {0} exists already and its content might be overwritten now.'.format(o))
else:
raise RuntimeError('{0} exists'.format(o))
else:
os.mkdir(o)
runOn(partial(scalingExperiment, experiment3), o, [1,2,3,4])
if len(experiments) == 0 or "experiment3a" in experiments:
# Experiment 3a (same as Exp3, but OLTP limited to 40,000 gets per sec)
print "#######################################"
print " RUN EXPERIMENT 3a"
print "#######################################"
o = '{0}/experiment3a'.format(outdir)
if os.path.isdir(o):
if ignore_warnings:
print ('[WARNING] {0} exists already and its content might be overwritten now.'.format(o))
else:
raise RuntimeError('{0} exists'.format(o))
else:
os.mkdir(o)
runOn(partial(scalingExperiment, experiment3a), o, [4])
if len(experiments) == 0 or "experiment3b" in experiments:
# Experiment 3b (same as Exp3, but OLTP limited to 40,000 gets/puts per sec)
print "#######################################"
print " RUN EXPERIMENT 3b"
print "#######################################"
o = '{0}/experiment3b'.format(outdir)
if os.path.isdir(o):
if ignore_warnings:
print ('[WARNING] {0} exists already and its content might be overwritten now.'.format(o))
else:
raise RuntimeError('{0} exists'.format(o))
else:
os.mkdir(o)
runOn(partial(scalingExperiment, experiment3b), o, [4])
if __name__ == "__main__":
out = 'results'
parser = ArgumentParser()
parser.add_argument("-o", dest='out', help="Output directory", default=out)
parser.add_argument("-i", dest='ignore_warnings', help="Ignore warnings", action="store_true")
parser.add_argument('experiments', metavar='E', type=str, nargs='*', help='Experiments to run (none defaults to all)')
parser.add_argument("-a", dest='approaches', type=str, nargs='*', help=' storage approaches to run with (none defaults to Storage.storage)')
args = parser.parse_args()
if not os.path.isdir(args.out):
os.mkdir(args.out)
if args.approaches == None:
args.approaches = [Storage.storage().__class__.__name__.lower()]
for app in args.approaches:
if app == "tellstore":
Storage.storage = TellStore
elif app == "kudu":
Storage.storage = Kudu
elif app == "hbase":
Storage.storage = Hbase
elif app == "cassandra":
Storage.storage = Cassandra
elif app == "ramcloud":
Storage.storage = Ramcloud
else:
print "[WARNING] Approach '" + app + "' is unknown. Will be ignored.\n"
continue
print "#######################################"
print "Running benchmarks for " + Storage.storage().__class__.__name__.upper()
print "#######################################\n"
runAllBenchmarks(args.out, args.experiments, args.ignore_warnings)