-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_rust_only_test.py
365 lines (320 loc) · 10.1 KB
/
run_rust_only_test.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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# cargo test test_isolation --features basic --features local_cc_cfg_occ --no-default-features --release -- --nocapture
import os
import copy
import re
from configure import numa_set, pm_index
k = 0
index_type = "DRAM"
sysname = {
"Falcon": ["n2db_local", "ilog", "clwb_tuple", "hot_unflush"],
"Falcon(All Flush)": ["n2db_local", "ilog", "clwb_tuple"],
"Falcon(No Flush)": ["n2db_local", "ilog"],
"Inp": ["n2db_local", "clwb_delta", "clwb_tuple"],
"Outp": ["n2db_append", "clwb_tuple"],
"ZenS": ["zen_local", "clwb_tuple"],
"ZenS(No Flush)": ["zen_local"],
# "Inp(Small Log Window)": ["n2db_local", "clwb_tuple", "ilog"],
"Inp(No Flush)": ["n2db_local"],
"Inp(Hot Tuple Cache)": ["n2db_local", "clwb_delta", "clwb_tuple", "hot_unflush"],
"Unknown": []
}
def copy(dir, file):
cmd = 'cp ' + file + ' ' + os.path.join(dir, file)
print(cmd)
os.system(cmd)
def set_thread_count(thread_count):
path = './src/mvcc_config/mod.rs'
# print(thread_count)
with open(path, "w") as cfile:
cfile.write("pub mod delta;\n")
cfile.write("pub const THREAD_COUNT: usize = 48;\n")
cfile.write("pub const TEST_THREAD_COUNT: usize = %d;\n" % (thread_count))
cfile.write("pub const TRANSACTION_COUNT: usize = THREAD_COUNT;\n")
def get_sysname(features):
global index_type
global sysname
result = "Unknown"
for key in sysname:
if set(sysname[key]) < set(features) and len(sysname[key]) > len(sysname[result]):
result = key
if result == "Falcon" and index_type == "DRAM":
result = "Falcon(DRAM Index)"
return result
def get_workload(features, result):
if "tpcc" in features:
if "new_order_clock" in features:
return "TPC-C-NP new_order"
if "payment_clock" in features:
return "TPC-C-NP payment"
return "TPC-C-NP"
for ycsb in "abcdef":
workload = "ycsb_"+ycsb
if workload in features:
theta = re.findall("theta = (\d+\.?\d*)", result)
return workload + " zipf_theta = " + str(theta[0])
return "Unknown"
def get_cc(features):
cc = ""
if "mvcc" in features:
cc = "MV"
if "local_cc_cfg_2pl" in features:
cc += '2PL'
elif "local_cc_cfg_to" in features:
cc += 'TO'
elif "local_cc_cfg_occ" in features:
cc += 'OCC'
else:
cc = "Unknown"
return cc
def get_txn(result):
pattern = "txn (\d+) of (\d+) txns"
txns = re.findall(pattern, result)
return txns[0]
def get_latency(result):
pattern = "avg_txn: (\d+\.?\d*), 10.: (\d+\.?\d*), 95.: (\d+\.?\d*), 99.: (\d+\.?\d*)"
latency_group = re.findall(pattern, result)
if latency_group:
return latency_group[0]
return []
# "sysname, workload, threads, cc, commit txns, total txns, avg latency, 10% latency, 95% latency. 99% latency"
def report(features, result, t_cnt):
csv_line = []
csv_line.append(get_sysname(features))
csv_line.append(get_workload(features, result))
csv_line.append(str(t_cnt))
csv_line.append(get_cc(features))
commits, total = get_txn(result)
csv_line.append(str(commits))
csv_line.append(str(total))
latency_group = get_latency(result)
for latency in latency_group:
csv_line.append(str(latency))
return ",".join(csv_line) + "\n"
def TIMEOUT_COMMAND(command, timeout):
"""call shell-command and either return its output or kill it
if it doesn't normally exit within timeout seconds and return None"""
import subprocess, datetime, os, time, signal
start = datetime.datetime.now()
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while process.poll() is None:
time.sleep(0.2)
now = datetime.datetime.now()
if (now - start).seconds > timeout:
os.kill(process.pid, signal.SIGKILL)
os.waitpid(-1, os.WNOHANG)
return None
return process.stdout.read().decode("utf-8")
def run_test(features, workload, result_path):
global k
set_thread_count(16)
k += 1
# test tasks filter
# if k <= 20 and result_path == "tpcc_nvm":
# return ""
# if k <= 18 and result_path == "tpcc_scal":
# return ""
# if k not in [112]:
# return ""
# if "mvcc" in features and "zen_local" in features:
# return ""
result_csv = ""
# txt = "taskset -c 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99 cargo test " + workload
txt = numa_set + " cargo test " + workload
t_cnt = 16
for f in features:
if f == "":
continue
if type(f) == int:
set_thread_count(f)
t_cnt = f
continue
txt += " --features " + f
# result_csv += f + " "
txt += " --no-default-features --release -- --nocapture"
print("test cmd: " + txt)
text = ""
r = os.popen("rm %s"%pm_index)
# r = os.popen(txt)
# text = TIMEOUT_COMMAND(txt, 600)
if text == None:
with open("error.txt", "w") as err_file:
err_file.write(result_path)
err_file.write('\n')
err_file.write(str(k))
err_file.write('\n')
err_file.write(txt)
err_file.write('\n')
r.close()
return ""
r.close()
print(features)
features.remove(t_cnt)
features.append(str(t_cnt))
# print(features)
for line in text.splitlines():
if "total" in line:
result_csv += report(features, line, t_cnt)
try:
os.mkdir("result")
except:
pass
try:
os.mkdir("result/" + result_path)
except:
pass
of = open("result/" + result_path + "/"+ str(k) + ".csv", "w")
of.write(result_csv)
of.close()
of = open("result/" + result_path + "/" + str(k) + ".txt", "w")
of.write(text)
of.close()
features.remove(str(t_cnt))
features.append(t_cnt)
return result_csv
def test(features, props, prop_list, workload, result_path, times = 1):
if len(prop_list) == 0:
for i in range(0, times):
run_test(features, workload, result_path)
# print(features)
return
for f in props[prop_list[0]]:
features += f
test(features, props, prop_list[1:], workload, result_path, times)
for item in f:
features.remove(item)
# ycsb for ycsb-NVM
# tpcc for tpcc-NVM, support multi index without recovery
# dram for DRAM index
def set_index(index_type):
pwd = os.getcwd()
dash_owd = pwd + "/dash/src"
os.chdir(dash_owd)
r = os.popen("git checkout " + index_type)
os.chdir(pwd)
def test_ycsb_dram_only():
global k
global index_type
k = 0
index_type = "DRAM"
props = {
"basic": [["basic_dram"]],
"ycsb": [
["ycsb_a"], ["ycsb_f"],
],
"cc_cfg": [
# ["local_cc_cfg_to"],
# ["local_cc_cfg_2pl"],
["local_cc_cfg_occ"],
],
"mvcc": [
[""],
# ["mvcc"]
],
"buffer": [
sysname["Falcon"], sysname["ZenS"],
sysname["ZenS(No Flush)"], sysname["Falcon(No Flush)"],
sysname["Falcon(All Flush)"], sysname["Inp"],
sysname["Outp"],
],
"clock": [
["txn_clock"],
],
"thread_count": [[48]]
}
test([], props, list(props.keys()), "ycsb_test_sync", "ycsb_dram")
def test_tpcc_dram_only():
global k
global index_type
k = 0
index_type = "DRAM"
# set_index("tpcc")
props = {
"basic": [["basic_dram", "tpcc"]],
"ycsb": [
["ycsb_a"], # only for compile
],
"cc_cfg": [
["local_cc_cfg_to"],
["local_cc_cfg_2pl"],
["local_cc_cfg_occ"],
],
"mvcc": [
[""],
["mvcc"]
],
"buffer": [
sysname["Falcon"], sysname["ZenS"],
sysname["ZenS(No Flush)"], sysname["Falcon(No Flush)"],
sysname["Falcon(All Flush)"], sysname["Inp"],
sysname["Outp"],
],
"clock": [
["txn_clock", "new_order_clock"],
["txn_clock", "payment_clock"],
],
"thread_count": [[48]]
}
test([], props, list(props.keys()), "tpcc_test_sync", "tpcc_dram")
def test_ycsb_scal_dram_only():
global k
global index_type
k = 0
index_type = "DRAM"
# set_index("ycsb")
props = {
"basic": [["basic_dram"]],
"ycsb": [
["ycsb_a"],
],
"cc_cfg": [
# ["local_cc_cfg_to"],
# ["local_cc_cfg_2pl"],
["local_cc_cfg_occ"],
],
"mvcc": [
[""],
# ["mvcc"]
],
"buffer": [
sysname["Falcon"], sysname["Inp"],
sysname["Falcon(All Flush)"],
sysname["Inp(No Flush)"],
sysname["Inp(Hot Tuple Cache)"],
],
"thread_count": [[1],[2],[4],[8],[16],[32],[48]]
}
test([], props, list(props.keys()), "ycsb_test_sync", "ycsb_scal")
def test_tpcc_scal_dram_only():
global k
global index_type
k = 0
index_type = "DRAM"
set_index("tpcc")
props = {
"basic": [["basic_dram", "tpcc"]],
"ycsb": [
["ycsb_a"], # default
],
"cc_cfg": [
# ["local_cc_cfg_to"],
# ["local_cc_cfg_2pl"],
["local_cc_cfg_occ"],
],
"mvcc": [
[""],
# ["mvcc"]
],
"buffer": [
sysname["Falcon"], sysname["Inp"],
sysname["Falcon(All Flush)"],
sysname["Inp(No Flush)"],
sysname["Inp(Hot Tuple Cache)"],
],
"thread_count": [[1],[2],[4],[8],[16],[32],[48]]
}
test([], props, list(props.keys()), "tpcc_test_sync", "tpcc_scal")
if __name__ == "__main__":
test_ycsb_dram_only()
test_tpcc_dram_only()
test_ycsb_scal_dram_only()
test_tpcc_scal_dram_only()