-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_experiments.py
178 lines (151 loc) · 5.24 KB
/
run_experiments.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
import argparse
import os
import sys
import multiprocessing
from create_graphs_paper import *
parser = argparse.ArgumentParser()
parser.add_argument("datastructure", choices=['list', 'bst', 'hash', 'skiplist'], help="datastructure to run")
parser.add_argument("threads", help="Number of threads")
parser.add_argument("size", help="Initial size")
parser.add_argument("versions", choices=['auto', 'manual', 'traverse', '[auto,traverse,manual]'], help="type of persistence transformation")
parser.add_argument("ratios", help="Update ratio, number between 0 and 100.")
parser.add_argument("-f", "--flithash", help="Compare flit hashtable sizes",
action="store_true")
parser.add_argument("-n", "--nvram", help="Allocate memory from nvram",
action="store_true")
parser.add_argument("-d", "--VMMALLOC_POOL_DIR", type=str)
parser.add_argument("-s", "--VMMALLOC_POOL_SIZE", type=str)
parser.add_argument("-t", "--test_only", help="test script",
action="store_true")
parser.add_argument("-g", "--graphs_only", help="graphs only",
action="store_true")
# full_ds_name = {
# 'list' : 'List',
# 'bst' : 'Bst',
# 'hash' : 'Hashtable',
# 'skiplist' : 'Skiplist',
# }
args = parser.parse_args()
print("datastructure: " + args.datastructure)
print("threads: " + args.threads)
print("sizes: " + args.size)
print("versions: " + args.versions)
print("ratios: " + args.ratios)
if args.flithash:
print("Comparing flit hashtable sizes")
if args.nvram:
print("allocating memory from NVRAM, VMMALLOC_POOL_DIR=" + args.VMMALLOC_POOL_DIR + ", VMMALLOC_POOL_SIZE=" + args.VMMALLOC_POOL_SIZE)
else:
print("allocating memory from DRAM")
test_only = args.test_only
graphs_only = args.graphs_only
# measured in seconds
runtime = 5
repeats = 5
if test_only:
runtime = 0.1
repeats = 1
#binary location
binary = 'build/bench'
jemalloc='LD_PRELOAD=`jemalloc-config --libdir`/libjemalloc.so.`jemalloc-config --revision`'
nvmmalloc='LD_PRELOAD=libvmmalloc.so.1'
numactl = "numactl --cpubind=0 --membind=0"
persists = ['simple', 'counter', 'hash20', 'link']
if args.datastructure == 'bst':
persists.remove('link')
if args.datastructure == 'skiplist' and int(args.size) > 100000:
persists.remove('simple')
if args.flithash:
persists = ['hash12', 'hash16', 'hash20', 'hash23', 'hash26']
def string_to_list(s):
s = s.strip().strip('[').strip(']').split(',')
return [ss.strip() for ss in s]
def to_list(s):
if type(s) == list:
return s
return [s]
def runtest(ds,th,size,ver,up,per,scriptfile):
cmd = ""
if args.nvram:
cmd += "echo \'running on NVM\'\n"
cmd += nvmmalloc + " " + numactl + " "
else:
cmd += "echo \'running on DRAM\'\n"
cmd += jemalloc + " "
cmd += binary + " "
cmd += "--ds " + ds + " --version " + ver + " --persist " + per + " "
cmd += "--update " + str(up) + " --size " + str(size) + " --threads " + str(th) + " "
cmd += "--runtime " + str(runtime)
for i in range(repeats):
scriptfile.write(cmd + '\n')
datastructure = args.datastructure
exp_type = ""
threads = args.threads
sizes = args.size
versions = args.versions
ratios = args.ratios
if '[' in args.threads:
exp_type = "scalability"
threads = string_to_list(threads)
elif '[' in args.versions:
exp_type = "version"
versions = string_to_list(versions)
elif '[' in args.ratios:
exp_type = "ratio"
ratios = string_to_list(ratios)
else:
print('invalid argument')
exit(1)
outfile = "results/" + "-".join([args.datastructure, args.threads, args.size, args.versions, args.ratios, str(args.flithash), str(args.nvram)]) + ".txt"
if not graphs_only:
scriptfile = open("exp.sh", "w")
if args.nvram:
scriptfile.write('export VMMALLOC_POOL_DIR=' + args.VMMALLOC_POOL_DIR + '\n')
scriptfile.write('export VMMALLOC_POOL_SIZE=' + args.VMMALLOC_POOL_SIZE + '\n')
for th in to_list(threads):
for size in to_list(sizes):
for up in to_list(ratios):
if not args.flithash:
runtest(datastructure,th,size,'original',up,'counter',scriptfile)
for ver in to_list(versions):
for per in persists:
runtest(datastructure,th,size,ver,up,per,scriptfile)
scriptfile.close()
os.system("bash exp.sh > " + outfile)
throughput = {}
stddev = {}
flushes = {}
stddev_flushes = {}
dss = []
updates = []
versions = []
persists = []
sizes = {}
threads = []
readFile(outfile, throughput, stddev, flushes, stddev_flushes, dss, updates, versions, persists, sizes, threads)
threads.sort()
updates.sort()
for key, value in sizes.items():
sizes[key].sort()
print(dss)
print(versions)
print(persists)
print(updates)
print(threads)
print(sizes)
print(exp_type)
# print(throughput)
ds = dss[0]
size = sizes[ds][0]
up = updates[0]
th = threads[0]
ver = versions[0]
if ver == 'Original':
ver = versions[1]
if exp_type == "scalability":
create_graph_thread(outfile, throughput, stddev, ds, size, up, threads, ver, persists, 'throughput')
elif exp_type == "version":
create_graph_ver_per(outfile, throughput, stddev, ds, size, up, th, persists, 'throughput')
create_graph_ver_per(outfile, flushes, stddev_flushes, ds, size, up, th, persists, 'flushes')
elif exp_type == "ratio":
create_graph_updates(outfile, throughput, stddev, ds, size, updates, th, ver, persists, 'throughput', False, args.flithash)