-
Notifications
You must be signed in to change notification settings - Fork 0
/
runEval_manyColumns.py
200 lines (159 loc) · 8.16 KB
/
runEval_manyColumns.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
import subprocess
from math import *
import sys
import os
from multiprocessing.pool import ThreadPool
import numpy as np
import os.path
import sqlite3
import psutil
import time
use_oram=True
useGamma=True
power=[16]
numDatapoints=[2**p-2**(p-16) for p in power] # each osm can store 2**16-1 datapoints by default
numQueries=10
aggFunctions= ["SUM" ]
runPointQuery=0
logLevel="INFO"
logToFile=True
columnOptions=[10,20,30,40,50]
dataSourceString= "GENERATED"#"FROM_FILE" # Alternatives FROM_REAL or GENERATED
#dataSetString="./data/covid-data-adjusted.csv" #only used if FROM_REAL is set
insertBulkFlag=0#1 # insertion is done in a non-oblivious way to facilitate measurements
controlSelectivityFlag=1
valueSizes=[0]#[16*25-60,16*50-60,16*100-60, 16*300-60] #total block size needs to be devisable by 16, 60 is the default size with one column and no additional data stored
seeds=range(0,10)
from itertools import chain
domainSizes=[1000]#[1000,2000,4000,8000,16000,32000,64000,128000,256000] # domainsizes of less than 1000 so range(100,1000,100)
selectivities=[0.1]#[0.04,0.05,0.06,0.07,0.08,0.09] #0.5
rangequery_ranges=[10]#[4,8,16,32,64,128]
outdir="./results/ManyColumns-selectivity:0.1-size:2^16-NumCols:10,50-BlockSize:0"
maxNumThreads=1
waitDuration=5 #150min für 1 col bei 2^26
def run_with_seed(s):
createNewData=True
#print("Running one thread with seed "+str(s))
fdir="~/tmp/storage-files-thread"+str(s)
seed="--seed "+str(s)+" "
numOptions=len(numDatapoints)*len(aggFunctions)*len(columnOptions)+len(domainSizes)+len(selectivities)
# only integer columns
i=0
for nC in sorted(columnOptions,reverse=True):
cols="i,"*nC
cols=cols[0:-1]
cols="-c "+cols+" "
res="1,"*nC
res=res[0:-1]
res="-r '"+res+"' "
for nD in sorted(numDatapoints,reverse=True):
#logCapacity=ceil(log(nD)/log(2))
datapoints="--datapoints "+str(nD)+" "
for a in aggFunctions:
agg="--agg "+a+" "
#for nQ in sorted(numQueries,reverse=True):
for domainSize in domainSizes:
minVals="--minVals '"
maxVals="--maxVals '"
for i in range(nC):
minVals=minVals+"10000,"
maxVals=maxVals+str(10000+domainSize)+","
minVals=minVals[0:-1]
maxVals=maxVals[0:-1]
minVals=minVals+"' "
maxVals=maxVals+"' "
if(1==1):
for maxSelectivityValue in selectivities:
maxSelectivityString="--maxSensitivity "+str(maxSelectivityValue)+" "
for vs in valueSizes:
for rangequeryrange in rangequery_ranges:
rangequeryrangeString=""
if not runPointQuery:
rangequeryrangeString="--rangeQueryRange "+str(rangequeryrange)+" "
i=i+1
queries="--numQueries "+str(numQueries)+" "
valueSize="--valueSize "+str(vs)+" "
pointQueries="--pointQueries "+str(runPointQuery)+" "
queryIndex="--queryIndex "+str(0)+" "
whereIndex="--whereIndex "+str(0)+" "
verbosityStr="--verbosity "+str(logLevel)+" "
outdirStr="--outdir "+str(outdir)+" "
fileLoggingStr="--fileLogging "+str(logToFile)+" "
insertBulk="--insertBulk "+str(insertBulkFlag)+" "
controlSelectivity="--controlSelectivity "+str(controlSelectivityFlag)+" "
useGammaString="--useGamma "+str(useGamma)+" "
use_oramFlag="--useOram "+str(use_oram)+" "
thisfDir=str(fdir)+"-seed:"+str(s)
filesExists= os.path.isdir(thisfDir)
useExisting=(filesExists and (not createNewData))
if dataSourceString=="FROM_FILE" and useExisting:
dataSource="--datasource "+str(dataSourceString)+" "
dataSource+="--filesDir "+thisfDir+" "
elif dataSourceString=="FROM_REAL":
dataSource="--datasource "+str(dataSourceString)+" "
dataSource+="--dataset "+dataSetString+" "
else:
createNewData=False
dataSource="--datasource GENERATED "
dataSource+="--filesDir "+thisfDir+" "
#command="cd " +path+";"
command="./bin/main "\
+cols+res+datapoints\
+dataSource\
+use_oramFlag\
+minVals+maxVals\
+insertBulk\
+agg+queries+queryIndex+whereIndex\
+pointQueries+rangequeryrangeString\
+controlSelectivity+maxSelectivityString\
+useGammaString\
+valueSize\
+seed\
+verbosityStr+outdirStr+fileLoggingStr
print(command)
print("Thread "+str(s)+": Execution "+str(i)+"/"+str(numOptions)+ " ("+command+")", flush=True)
subprocess.run(command, shell=True,
stdout=subprocess.DEVNULL,
#stdout=subprocess.STDOUT,
stderr=sys.stdout)
def main():
dbName="ram-lock.db"
availableRAM=int((psutil.virtual_memory().total/ ( 1024 * 1024 * 1024))-3) # in GB
if (not os.path.isfile(dbName)):
cur = sqlite3.connect(dbName)
cur.execute("CREATE TABLE LOCKED (ID INT PRIMARY KEY NOT NULL, USED INT NOT NULL);")
cur.execute("INSERT INTO LOCKED (ID, USED) VALUES (0, "+str(availableRAM)+");")
cur.commit()
cur.close()
global maxNumThreads
if maxNumThreads==0:
perThread=0
#esitmating number of threads
c=max(columnOptions)
i=round(log(max(numDatapoints))/log(2))-16
if(c==1):
perThread=col1[i]
if(c==5):
perThread=col5[i]
else:
factor=col5[i]/col1[i]
perThread=factor*c
peak=perThread*2.5
maxNumThreads=floor((availableRAM-peak)/perThread)
print("Calculated max Number of Thread is "+str(maxNumThreads))
exit(0)
num = min(len(seeds), maxNumThreads) # sqet to the number of workers you want (it defaults to the cpu count of your machine)
print(str(num)+" Threads selected")
tp = ThreadPool(num)
results=list()
for s in sorted(seeds):
#if(s is not min(seeds)):
# print("Thread "+str(s)+" sleeps for "+str(waitDuration)+"minutes unitl started.")
# time.sleep(waitDuration*60) #time in seconds
x= tp.apply_async(run_with_seed, (s,))
results.append(x)
for x in results:
x.get()
tp.close()
tp.join()
main()