-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark_evaluation.py
147 lines (115 loc) · 6.08 KB
/
benchmark_evaluation.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
import os
import numpy as np
import subprocess
def get_cmd_results(cmd):
return subprocess.check_output(cmd, shell=True).decode('utf-8').rstrip("\n").split("\t")
def eval_wiki():
wiki_data_path = "SOSD/data/wiki_ts_200M_uint64"
wiki_workloads = [
"workloads/wiki_ts_200M_uint64_workload200000k_alpha1.1",
"workloads/wiki_ts_200M_uint64_workload200000k_alpha1.5",
"workloads/wiki_ts_200M_uint64_workload200000k_alpha1.9"
]
num_records = 200000000
workload_size = 200000000
num_second_level_models = [100, 1000, 10000, 100000, 1000000]
lookup_table_sizes = [1000, 10000]
models = ["linear_model", "weighted_linear_model", "look_up_table_linear_model"]
log_path = "results/wiki_200000k_v3.csv"
if os.path.isfile(log_path):
log = open(log_path, "a")
else:
log = open(log_path, "w")
log.write("model,num_second_level_models,table_size,train_workload,test_workload,model_size,build_time,test_workload_time,num_last_mile_search\n")
for workload in wiki_workloads:
for nslm in num_second_level_models:
for idx, model in enumerate(models):
if model == "linear_model": # linear model
cmd = "./build/benchmark_learned_index {} {} {} {} {}".format(
nslm, wiki_data_path, workload, num_records, workload_size
)
msize, btime, wtime, nlms = get_cmd_results(cmd)
info = "{},{},{},{},{},{},{},{},{}".format(
model, nslm, "NA", "NA", workload, msize, btime, wtime, nlms
)
print(info)
log.write(info + "\n")
weight_path = os.path.join("weights", os.path.basename(workload))
if model == "weighted_linear_model": # weighted linear model
cmd = "./build/benchmark_weighted_learned_index {} {} {} {} {} {}".format(
nslm, wiki_data_path, weight_path, workload, num_records, workload_size
)
msize, btime, wtime, nlms = get_cmd_results(cmd)
info = "{},{},{},{},{},{},{},{},{}".format(
model, nslm, "NA", workload, workload, msize, btime, wtime, nlms
)
print(info)
log.write(info + "\n")
if model == "look_up_table_linear_model": # lookup table linear model
for tsize in lookup_table_sizes:
cmd = "./build/benchmark_look_up_table_learned_index {} {} {} {} {} {} {}".format(
nslm, tsize, wiki_data_path, weight_path, workload, num_records, workload_size
)
msize, btime, wtime, nlms = get_cmd_results(cmd)
info = "{},{},{},{},{},{},{},{},{}".format(
model, nslm, tsize, workload, workload, msize, btime, wtime,nlms
)
print(info)
log.write(info + "\n")
log.close()
def eval_book():
book_data_path = "SOSD/data/books_200M_uint64"
book_workloads = [
"workloads/books_200M_uint64_workload200000k_alpha1.1",
"workloads/books_200M_uint64_workload200000k_alpha1.5",
"workloads/books_200M_uint64_workload200000k_alpha1.9"
]
num_records = 200000000
workload_size = 200000000
num_second_level_models = [100, 1000, 10000, 100000, 1000000]
lookup_table_sizes = [1000, 10000]
models = ["linear_model", "weighted_linear_model", "look_up_table_linear_model"]
log_path = "results/books_200000k_v3.csv"
if os.path.isfile(log_path):
log = open(log_path, "a")
else:
log = open(log_path, "w")
log.write("model,num_second_level_models,table_size,train_workload,test_workload,model_size,build_time,test_workload_time,num_last_mile_search\n")
for workload in book_workloads:
for nslm in num_second_level_models:
for idx, model in enumerate(models):
if model == "linear_model": # linear model
cmd = "./build/benchmark_learned_index {} {} {} {} {}".format(
nslm, book_data_path, workload, num_records, workload_size
)
msize, btime, wtime, nlms = get_cmd_results(cmd)
info = "{},{},{},{},{},{},{},{},{}".format(
model, nslm, "NA", "NA", workload, msize, btime, wtime, nlms
)
print(info)
log.write(info + "\n")
if model == "weighted_linear_model": # weighted linear model
weight_path = os.path.join("weights", os.path.basename(workload))
cmd = "./build/benchmark_weighted_learned_index {} {} {} {} {} {}".format(
nslm, book_data_path, weight_path, workload, num_records, workload_size
)
msize, btime, wtime, nlms = get_cmd_results(cmd)
info = "{},{},{},{},{},{},{},{},{}".format(
model, nslm, "NA", workload, workload, msize, btime, wtime, nlms
)
print(info)
log.write(info + "\n")
if model == "look_up_table_linear_model": # lookup table linear model
for tsize in lookup_table_sizes:
cmd = "./build/benchmark_look_up_table_learned_index {} {} {} {} {} {} {} {}".format(
nslm, tsize, book_data_path, workload, workload, num_records, workload_size, workload_size
)
msize, btime, wtime, nlms = get_cmd_results(cmd)
info = "{},{},{},{},{},{},{},{},{}".format(
model, nslm, tsize, workload, workload, msize, btime, wtime,nlms
)
print(info)
log.write(info + "\n")
log.close()
if __name__ == "__main__":
eval_wiki()