-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
212 lines (184 loc) · 7.59 KB
/
Copy pathplot.py
File metadata and controls
212 lines (184 loc) · 7.59 KB
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
import os
import sys
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import scipy.stats as st
PLOT_STYLES = {
"demon": "o-",
"gemini": "o-",
"redblue": "o-",
"unistore": "o-",
"causal": "o-",
"strict": "o-",
}
COLORS = {
"demon": "tab:blue",
"gemini": "tab:red",
"redblue": "tab:green",
"unistore": "tab:orange",
"causal": "tab:purple",
"strict": "tab:brown",
}
LABELS = {
"demon": "semi-ser",
"gemini": "gemini",
"redblue": "redblue (new)",
"unistore": "unistore",
"causal": "causal",
"strict": "strict",
}
def p99(series):
return st.scoreatpercentile(series, 99.0)
def calc_stats(series, confidence_level=0.95):
return {
"mean": st.tmean(series),
"mean_conf_int": st.bootstrap((series,), st.tmean, confidence_level=confidence_level, method="percentile").confidence_interval,
"p99": p99(series),
"p99_conf_int": st.bootstrap((series,), p99, confidence_level=confidence_level, method="percentile").confidence_interval,
}
def plot_tpcc(df, dir_path):
for cluster_size in df["cluster_size"].unique():
cluster_df = df[df["cluster_size"] == cluster_size]
protocols = cluster_df["proto"].unique()
plt.figure(figsize=(10, 6)) # Adjust size as needed
for proto in protocols:
proto_df = cluster_df[cluster_df["proto"] == proto]
plt.plot(proto_df["total_throughput"], (proto_df["total_time"] * 1000) / proto_df["total_count"], PLOT_STYLES[proto], label=LABELS[proto], color=COLORS[proto])
plt.xlabel("throughput (txns/s)")
plt.ylabel("mean latency (ms)")
plt.title(f"TPCC latency by throughput ({cluster_size} replicas)")
plt.legend()
plt.savefig(os.path.join(dir_path, f"tpcc_plot_{cluster_size}_nodes.png"), dpi=300)
def plot_rubis(df, dir_path):
df = df[df["datatype"] == "rubis"]
if len(df) == 0:
return
for cluster_size in df["cluster_size"].unique():
cluster_df = df[df["cluster_size"] == cluster_size]
protocols = df["proto"].unique()
operations = ["GetAuction", "GetItem", "OpenAuction", "CloseAuction", "Bid", "Sell", "BuyNow"]
stats = {proto: [] for proto in protocols}
for proto in protocols:
proto_df = cluster_df[cluster_df["proto"] == proto]
for operation in operations:
op_df = proto_df[proto_df["op"] == operation]
stats[proto].append(calc_stats(op_df["latency_micros"]))
plt.figure(figsize=(6, 6)) # Adjust size as needed
plt.suptitle(f"Rubis-like benchmark with {cluster_size} replicas")
index = np.arange(len(operations))
bar_width = 0.1
i = 0
for proto, stats in stats.items():
mean = [item["mean"] for item in stats]
mean_conf = [item["mean_conf_int"] for item in stats]
# p99 = [item["p99"] for item in stats]
plt.bar(
x=index + 1.5*i*bar_width,
height=[item["mean"] for item in stats],
yerr=([item["mean"] - item["mean_conf_int"].low for item in stats], [item["mean_conf_int"].high - item["mean"] for item in stats]),
width=bar_width,
label=proto,
capsize=1.0
)
i += 1
plt.xticks(index + 0.5 * 1.5 * bar_width * (len(protocols)-1), operations)
plt.ylabel("mean latency (ms)")
# plt.title(f"mean latency per operation")
plt.legend()
plt.savefig(os.path.join(dir_path, f"rubis_bar_plot_{cluster_size}_nodes.png"), dpi=300)
# plt.subplot(2, 1, 2)
# i = 0
# for operation, vals in p99_latencies.items():
# plt.bar(index + 1.5*i*bar_width, vals, bar_width, label=operation)
# i += 1
# plt.xticks(index + 0.5 * 1.5 * bar_width * (len(protocols)-1), operations)
# plt.ylabel("p99 latency (ms)")
# # plt.title(f"tail latency per operation")
# plt.legend()
plt.savefig(os.path.join(dir_path, f"rubis_bar_plot_{cluster_size}_nodes.png"), dpi=300)
def plot_micro(df, dir_path):
for cluster_size in df["cluster_size"].unique():
cluster_df = df[df["cluster_size"] == cluster_size]
datatypes = cluster_df["datatype"].unique()
for dtype in datatypes:
plot_single_micro(cluster_df[cluster_df["datatype"] == dtype], dtype, cluster_size, dir_path)
def plot_single_micro(df, datatype, cluster_size, dir_path):
protocols = df["proto"].unique()
# aggregate the data
throughputs = {}
mean_latencies = {}
p95_latencies = {}
p99_latencies = {}
for proto in protocols:
proto_df = df[df["proto"] == proto]
grouped = proto_df.groupby("strong_ratio")
idx = grouped["total_throughput"].idxmax()
rows_with_max_throughput = proto_df.loc[idx]
print(rows_with_max_throughput[["num_clients", "proto", "datatype", "strong_ratio"]])
throughputs[proto] = {
"x": rows_with_max_throughput["strong_ratio"],
"y": rows_with_max_throughput["total_throughput"],
}
mean_latencies[proto] = {
"x": rows_with_max_throughput["strong_ratio"],
"y": rows_with_max_throughput["total_mean_latency"],
}
p95_latencies[proto] = {
"x": rows_with_max_throughput["strong_ratio"],
"y": rows_with_max_throughput["total_p95_latency"],
}
p99_latencies[proto] = {
"x": rows_with_max_throughput["strong_ratio"],
"y": rows_with_max_throughput["total_p99_latency"],
}
plt.figure(figsize=(10, 10)) # Adjust size as needed
plt.suptitle(f"{datatype} with {cluster_size} replicas")
plt.subplot(2, 2, 1)
for proto, vals in mean_latencies.items():
plt.plot(vals["x"], vals["y"], PLOT_STYLES[proto], label=LABELS[proto], color=COLORS[proto])
plt.xlabel("strong operation ratio")
plt.ylabel("mean latency (ms)")
plt.title(f"mean latency at max throughput")
plt.legend()
plt.subplot(2, 2, 2)
for proto, vals in throughputs.items():
plt.plot(vals["x"], vals["y"], PLOT_STYLES[proto], label=LABELS[proto], color=COLORS[proto])
plt.yscale("log")
plt.xlabel("strong operation ratio")
plt.ylabel("throughput (ops/s)")
plt.title(f"max throughput")
plt.legend()
plt.subplot(2, 2, 3)
for proto, vals in p95_latencies.items():
plt.plot(vals["x"], vals["y"], PLOT_STYLES[proto], label=LABELS[proto], color=COLORS[proto])
plt.xlabel("strong operation ratio")
plt.ylabel("95th percentile latency (ms)")
plt.title(f"95th percentile latency at max throughput")
plt.legend()
plt.subplot(2, 2, 4)
for proto, vals in p99_latencies.items():
plt.plot(vals["x"], vals["y"], PLOT_STYLES[proto], label=LABELS[proto], color=COLORS[proto])
plt.xlabel("strong operation ratio")
plt.ylabel("99th percentile latency (ms)")
plt.title(f"99th percentile latency at max throughput")
plt.legend()
plt.savefig(os.path.join(dir_path, f"{datatype}_plot_{cluster_size}_nodes.png"), dpi=300)
if __name__ == "__main__":
if len(sys.argv) < 2:
print("argument required to specify input directory")
exit()
args = sys.argv[1:]
path = args[0]
try:
df = pd.read_csv(os.path.join(path, "micro.csv"))
plot_rubis(df, path)
exit()
plot_micro(df, path)
except Exception as e:
print(f"err: {e}")
try:
df = pd.read_csv(os.path.join(path, "tpcc.csv"))
plot_tpcc(df, path)
except Exception as e:
print(f"err: {e}")