Repository navigation
Expand file tree
/
Copy pathcp_buffers
More file actions
executable file
·172 lines (150 loc) · 6.64 KB
/
Copy pathcp_buffers
File metadata and controls
executable file
·172 lines (150 loc) · 6.64 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
#!/usr/bin/python3 -u
# Copyright (c) 2023 Homa Developers
# SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0+
# This cperf benchmark varies one or more aspects of Homa's configuration,
# similar and measures Homa slowdown, but it also measures switch buffer
# utilization for each configuration, including the maximum utilization
# (if there is no limit), and the minimum buffer space that can be supported
# without significant performance degradation.
# Type "cp_config_buf --help" for documentation.
from cperf import *
from switch import *
# Workloads, bandwidths, and running times to use by default.
load_info = [["w3", 14, 10], ["w4", 20, 20], ["w5", 20, 30]]
parser = get_parser(description=
'Measures performance as the available switch buffer space is restricted.',
usage='%(prog)s [options]', defaults={'client_max': 400})
options = parser.parse_args()
options.alt_slowdown = True
init(options)
if options.workload != "":
load_info = [[options.workload, options.gbps, options.seconds]]
# Total downlink bandwidth across all nodes, in MBytes/sec
mBps = float(get_sysctl_parameter(".net.homa.link_mbps")) * options.num_nodes/8
# Used to collect data from experiments; a list with one value for each
# experiment. The value is a dictionary containing various information
# about the experiment.
data = []
if options.protocol == "homa":
pcts = [90, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30]
elif options.protocol == "tcp":
pcts = [90, 80, 70, 60, 50, 40, 30, 20]
set_sysctl_parameter('.net.ipv4.tcp_congestion_control', 'cubic',
options.nodes)
elif options.protocol == "dctcp":
pcts = [50, 40, 30, 25, 20, 15, 10]
set_sysctl_parameter('.net.ipv4.tcp_congestion_control', 'dctcp',
options.nodes)
pcts = [90, 80, 70, 60, 50, 40, 30, 25, 20, 15, 10]
switch = Switch()
if not options.plot_only:
try:
for workload, bw, seconds in load_info:
options.workload = workload
options.seconds = seconds
options.gbps = bw/2.0
# Measure unloaded performance.
o = copy.deepcopy(options)
o.protocol = "homa"
o.client_ports = 1
o.client_max = 1
o.server_ports = 1
o.servers = options.nodes[1:2]
o.unloaded = 500
exp_name = "unloaded_" + workload
start_servers(o.servers, o)
run_experiment(exp_name, o.clients[0:1], o)
set_unloaded(exp_name)
start_servers(options.servers, options)
# Run the experiment once with no buffer restrictions to get
# a baseline slowdown and buffer utilization.
switch.clear_max_buffer_usage()
switch.set_buffer_limit(13.2)
exp_name = "%s_%s_100" % (options.protocol, workload)
run_experiment(exp_name, options.clients, options)
digest = get_digest(exp_name)
base_slowdown = digest["avg_slowdown"]
base_buf = switch.get_max_buffer_usage()
log("Baseline for %s: slowdown %.1f, buffer space %.1f MB"
% (exp_name, base_slowdown, base_buf))
data.append({
"name": exp_name,
"workload": workload,
"pct": 100,
"buf_size": base_buf,
"slowdown": base_slowdown
})
# Restrict the buffer size in increments of 10% of the
# baseline usage.
for pct in pcts:
buf = base_buf*pct/100
switch.set_buffer_limit(buf)
log("Trying %.3f MB buffer limit (%d%% of baseline)"
% (buf, pct))
exp = "%s_%d" % (exp_name, pct)
run_experiment(exp, options.clients, options)
slowdown = get_digest(exp)["avg_slowdown"]
log("Slowdown for %s with %.3f MB buffer limit: %.1f"
% (exp, buf, slowdown))
data.append({
"name": exp,
"workload": workload,
"pct": pct,
"buf_size": buf,
"slowdown": slowdown
})
if (slowdown > 5*base_slowdown):
break;
except Exception as e:
log(traceback.format_exc())
f = open("%s/reports/%s_slowdown.data" % (options.log_dir, options.protocol),
"w")
print("# This file was created by cp_buffers at %s"
% date_time, file=f)
for name in sorted(dir(options)):
if name.startswith("_"):
continue
print("# options.%s: %*s %s" % (name, 20 - len(name), "",
getattr(options, name)), file=f)
log("\nSlowdown vs. Switch Buffer Space:")
print("\n# Slowdown as a function of switch buffer space for %s:"
% (options.protocol), file=f)
print("# exp: Name of the experiment", file=f)
print("# prot: Transport protocol", file=f)
print("# workload: w1-w5", file=f)
print("# buf_mb: Buffer space limit for experiment (MBytes)", file=f)
print("# pct: Buffer space limit as percentage of buf usage when", file=f)
print("# unrestricted", file=f)
print("# slowdown: Average slowdown across all RPCs", file=f)
log("Experiment Buffer MB Pct Slowdown")
print("%-20s prot workload buf_mb pct slowdown" % ("exp"), file = f)
for exp in data:
log("%-20s %6.1f %5d %6.1f" % (
exp["name"], exp["buf_size"], exp["pct"],
exp["slowdown"]))
print("%-20s %6s %6s %6.1f %5d %6.1f" % (
exp["name"], options.protocol, exp["workload"],
exp["buf_size"], exp["pct"], exp["slowdown"]), file=f)
log("")
f.close()
log("Stopping nodes")
stop_nodes()
scan_logs()
log("Resetting switch buffer limit")
switch.set_buffer_limit(13.2)
switch.close()
# Generate plots and reports
for workload, bw, seconds in load_info:
set_unloaded("unloaded_" + workload)
# Generate slowdown plot.
log("Generating slowdown plot for %s" % (workload))
title = "%s %d nodes, %.1f Gbps" % (workload.capitalize(),
options.num_nodes, bw)
exp_name = "%s_%s" % (options.protocol, workload)
ax = start_plot_vs_msg_length(title, 1000, exp_name, y_label=" Slowdown")
for exp in data:
plot_slowdown(ax, exp["name"], "p99", "%.1f MB P99" % exp["buf_size"])
ax.legend(loc="upper left", prop={'size': 9})
plt.tight_layout()
plt.savefig("%s/reports/%s_%s.pdf" %
(options.log_dir, options.protocol, workload))