Repository navigation
Expand file tree
/
Copy pathcp_config_buf
More file actions
executable file
·371 lines (349 loc) · 16.1 KB
/
Copy pathcp_config_buf
File metadata and controls
executable file
·371 lines (349 loc) · 16.1 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
#!/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 = [["w2", 3.2, 5], ["w3", 14, 10], ["w4", 20, 20], ["w5", 20, 30]]
parser = get_parser(description=
'Measures Homa slowdown and buffer utilization in TOR egress ports '
"while varying Homa's configuration.",
usage='%(prog)s [options]')
parser.add_argument('-c', '--config', dest='config',
choices=['dctcp_link_util',
'dctcp_nodes',
'dctcp_threshold',
'dynamic_windows',
'link_util',
'nodes',
'overcommit',
'tcp_link_util',
'tcp_nodes',
'unsched_bytes'],
required = True,
help='Aspect of configuration to vary')
parser.add_argument('--report', dest='report',
metavar='F', default='buf_usage.data',
help='Name of the file to use for the buffer usage report in the log '
'"reports" directory (default: buf_usage.data)')
options = parser.parse_args()
init(options)
if options.workload != "":
load_info = [[options.workload, options.gbps, options.seconds]]
plot_max_y = 1000
specs = []
if options.config == 'dctcp_link_util':
# Measure DCTCP while varying link utilization
options.protocol = "dctcp"
for gbps in [5, 10, 12, 14, 16, 18, 20]:
specs.append({'exp_name': 'dctcp_util_%d' % (gbps),
'label': 'DCTCP link utilization %d Gbps' % (gbps),
'options': ['gbps', gbps/2.0],
'sysctl': ['.net.ipv4.tcp_congestion_control', 'dctcp'],
'value': gbps
})
elif options.config == 'dctcp_nodes':
# Measure DCTCP while varying the number of nodes
if not options.workload:
load_info = [["w3", 14, 10], ["w4", 20, 20], ["w5", 20, 30]]
options.protocol = "dctcp"
for nodes in [5, 10, 15, 20, 25, 30]:
if nodes > options.num_nodes:
print("Can't run experiment with %d nodes: --nodes is only %d"
% (nodes, options.num_nodes))
continue
specs.append({'exp_name': 'dctcp_nodes_%d' % (nodes),
'label': '%d nodes' % (nodes),
'options': ['num_nodes', nodes],
'sysctl': ['.net.ipv4.tcp_congestion_control', 'dctcp'],
'value': nodes
})
elif options.config == 'dctcp_threshold':
# Measure DCTCP while varying the ECN marking threshold
options.protocol = "dctcp"
for thresh in [50, 78, 100, 150, 200, 500, 1000, 2000]:
specs.append({'exp_name': 'dctcp_threshold_%dk' % (thresh),
'label': 'DCTCP ECN threshold %d KB' % (thresh),
'sysctl': ['.net.ipv4.tcp_congestion_control', 'dctcp'],
'ecn_threshold': thresh,
'value': thresh
})
elif options.config == 'dynamic_windows':
# Use Homa's new dynamic windows and vary max_incoming
for max in [200, 300, 400, 500, 1000]:
specs.append({'exp_name': 'dwin_%dk' % (max),
'label': 'max_incoming %d KB' % (max),
'sysctl': ['.net.homa.dynamic_windows', 1,
'.net.homa.max_incoming', max*1000],
'value': max
})
elif options.config == 'link_util':
# Vary link utilization
for gbps in [5, 10, 12, 14, 16, 18, 20]:
specs.append({'exp_name': 'util_%d' % (gbps),
'label': 'Link utilization %d Gbps' % (gbps),
'options': ['gbps', gbps/2.0],
'value': gbps
})
elif options.config == 'nodes':
# Vary the number of nodes
if not options.workload:
load_info = [["w3", 14, 10], ["w4", 20, 20], ["w5", 20, 30]]
for nodes in [5, 10, 15, 20, 25, 30]:
if nodes > options.num_nodes:
print("Can't run experiment with %d nodes: --nodes is only %d"
% (nodes, options.num_nodes))
break
specs.append({'exp_name': 'nodes_%d' % (nodes),
'label': '%d nodes' % (nodes),
'options': ['num_nodes', nodes],
'value': nodes
})
elif options.config == 'overcommit':
# Vary unsched_bytes
if not options.workload:
load_info = [["w3", 14, 10], ["w4", 20, 20], ["w5", 20, 30]]
for over in [2, 3, 4, 5, 6, 7, 8]:
specs.append({'exp_name': 'over_%d' % (over),
'label': 'Overcommit %d' % (over),
'sysctl': ['.net.homa.max_overcommit', over],
'value': over
})
elif options.config == 'tcp_link_util':
# Measure TCP while varying link utilization
options.protocol = "tcp"
for gbps in [5, 10, 12, 14, 16, 18, 20]:
specs.append({'exp_name': 'tcp_util_%d' % (gbps),
'label': 'TCP link utilization %d Gbps' % (gbps),
'options': ['gbps', gbps/2.0],
'sysctl': ['.net.ipv4.tcp_congestion_control', 'cubic'],
'value': gbps
})
elif options.config == 'tcp_nodes':
# Meausre TCP while varying the number of nodes
if not options.workload:
load_info = [["w3", 14, 10], ["w4", 20, 20], ["w5", 20, 30]]
options.protocol = "tcp"
for nodes in [5, 10, 15, 20, 25, 30]:
if nodes > options.num_nodes:
print("Can't run experiment with %d nodes: --nodes is only %d"
% (nodes, options.num_nodes))
continue
specs.append({'exp_name': 'tcp_nodes_%d' % (nodes),
'label': '%d nodes' % (nodes),
'options': ['num_nodes', nodes],
'sysctl': ['.net.ipv4.tcp_congestion_control', 'cubic'],
'value': nodes
})
elif options.config == 'unsched_bytes':
# Vary unsched_bytes
for unsched in [40, 60, 80, 100, 120]:
specs.append({'exp_name': 'unsched_%dk' % (unsched),
'label': 'unsched_bytes %dk' % (unsched),
'sysctl': ['.net.homa.unsched_bytes', unsched*1000],
'value': unsched
})
# A list with one value per entry in specs. Each value is a dictionary
# with several fields describing various results for that spec.
buf_limits = []
# Keys are parameter names, values are old values to restore.
old_values = {}
if not options.plot_only:
try:
switch = Switch()
# For each workload, run a set of experiments with a different
# configurations.
for workload, bw, seconds in load_info:
o = copy.deepcopy(options)
o.protocol = "homa"
o.workload = workload
o.gbps = bw/2.0
o.seconds = seconds
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)
for spec in specs:
o = copy.deepcopy(options)
o.workload = workload
o.gbps = bw/2.0
o.seconds = seconds
exp_name = "%s_%s" % (spec['exp_name'], workload)
if 'sysctl' in spec:
for i in range(0, len(spec['sysctl']), 2):
name = spec['sysctl'][i]
value = spec['sysctl'][i+1]
if name not in old_values:
old_values[name] = get_sysctl_parameter(name)
log("Setting %s = %s" % (name, value))
set_sysctl_parameter(name, value,
range(0, options.num_nodes))
if 'options' in spec:
for i in range(0, len(spec['options']), 2):
name = spec['options'][i]
value = spec['options'][i+1]
setattr(o, name, value)
if 'ecn_threshold' in spec:
log("Setting switch ECN marking thresholds to %d"
% (spec['ecn_threshold']))
switch.set_all_ecn_thresholds(spec['ecn_threshold'])
o.servers = options.nodes[0:o.num_nodes]
o.clients = options.nodes[0:o.num_nodes]
# Total downlink bandwidth across all nodes, in MBytes/sec
mBps = float(get_sysctl_parameter(".net.homa.link_mbps")) \
* o.num_nodes/8
start_servers(o.servers, o)
# 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)
run_experiment(exp_name, o.clients, o)
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))
if base_buf < 1.0:
log("Baseline buffer space for %s is only %.3f MB; "
"no need to find minimum." % (exp_name, base_buf))
buf_limits.append({
"name": exp_name,
"workload": workload,
"value": spec["value"],
"slowdown": base_slowdown,
"base_buf": base_buf,
"lower_limit": 0,
"base_usecs": base_buf * 1e06 / mBps,
"min_usecs": 0
})
continue
# Now restrict the buffer size, using a series of experiments
# with binary search to find the buffer size at which average
# slowdown increases by 10% from the baseline
max_buf = base_buf
min_buf = 0.0
count = 0
while ((max_buf - min_buf) > .1*max_buf) and (max_buf > 0.1):
buf = (max_buf + min_buf)/2.0
switch.set_buffer_limit(buf)
log("Trying %.3f MB buffer limit (max %.3f MB, min %.3f MB)"
% (buf, max_buf, min_buf))
count += 1
exp = "%s_%d" % (exp_name, count)
run_experiment(exp, o.clients, o)
slowdown = get_digest(exp)["avg_slowdown"]
log("Slowdown for %s with %.3f MB buffer limit: %.1f"
% (exp, buf, slowdown))
if (slowdown < base_slowdown):
slowdown = base_slowdown
if slowdown > 1.1*base_slowdown:
min_buf = buf
else:
max_buf = buf
lower_limit = (max_buf + min_buf)/2.0
log("Minimum buffer space for %s: %.3f MB" % (exp_name,
lower_limit))
buf_limits.append({
"name": exp_name,
"workload": workload,
"value": spec["value"],
"slowdown": base_slowdown,
"base_buf": base_buf,
"lower_limit": lower_limit,
"base_usecs": base_buf * 1e06 / mBps,
"min_usecs": lower_limit * 1e06/ mBps
})
log("Resetting switch buffer limit")
switch.set_buffer_limit(13.2)
if options.config == 'dctcp_threshold':
log("Resetting switch ECN marking thresholds")
switch.set_all_ecn_thresholds(78)
switch.close()
except Exception as e:
log(traceback.format_exc())
f = open("%s/reports/%s" % (options.log_dir, options.report), "w")
print("# Buffer usage statistics gathered by cp_config_buf 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("\nSwitch Buffer Utilization:")
print("", file=f)
print("# exp: Name of the experiment", file=f)
print("# prot: Transport protocol", file=f)
print("# workload: w1-w5", file=f)
print("# value: Value of configuration option that is varied", file=f)
print("# slowdown: Average slowdown across all RPCs when no restrictions", file=f)
print("# base_mb: Buffer space used when no restrictions (MBytes)", file=f)
print("# min_mb: Buffer space when slowdown degrades by 10% (MBytes)", file=f)
print("# base_us: Buffer space used when no restriction (microseconds)", file=f)
print("# min_us: Buffer space when slowdown degrades by 10% (microseconds)", file=f)
log("Experiment Slowdown Max MB Min MB Max us Min us")
print("%-24s prot workload value slowdown base_mb min_mb "
"base_us min_us" % ("exp"), file = f)
for exp in buf_limits:
log("%-24s %6.1f %6.2f %6.2f %6.1f %6.1f" % (
exp["name"], exp["slowdown"], exp["base_buf"],
exp["lower_limit"], exp["base_usecs"], exp["min_usecs"]))
print("%-24s %6s %6s %6s %6.1f %6.2f %6.2f %6.1f %6.1f" % (
exp["name"], options.protocol, exp["workload"], exp["value"],
exp["slowdown"], exp["base_buf"], exp["lower_limit"],
exp["base_usecs"], exp["min_usecs"]),
file=f)
log("")
f.close()
for name, value in old_values.items():
log("Restoring %s to %s" % (name, value))
set_sysctl_parameter(name, value, range(0, options.num_nodes))
log("Stopping nodes")
stop_nodes()
scan_logs()
# 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)
ax = start_plot_vs_msg_length(title, plot_max_y, "%s_%s" % (
specs[0]['exp_name'], workload), y_label=" Slowdown")
for spec in specs:
exp_name = "%s_%s" % (spec['exp_name'], workload)
plot_slowdown(ax, exp_name, "p99", spec['label'] + ' P99')
for spec in specs:
exp_name = "%s_%s" % (spec['exp_name'], workload)
plot_slowdown(ax, exp_name, "p50", spec['label'] + ' P50')
if workload == "w5":
ax.legend(loc="upper right", prop={'size': 9})
else:
ax.legend(loc="upper left", prop={'size': 9})
plt.tight_layout()
plt.savefig("%s/reports/%s_%s.pdf" %
(options.log_dir, options.config, workload))
# Generate CDF of small-message RTTs.
log("Generating short message CDFs for %s" % (workload))
title = "%s %d nodes" % (workload.capitalize(), options.num_nodes)
start_cdf_plot(title, 10, 0.99e05, 1e-05, "RTT (usecs)",
"Cumulative Fraction of Short Messages")
for spec in specs:
exp_name = "%s_%s" % (spec['exp_name'], workload)
x, y = get_short_cdf(exp_name)
plt.plot(x, y, label=spec['label'])
x, y = get_short_cdf("unloaded_" + workload)
plt.plot(x, y, label="Homa best case")
plt.legend(loc="upper right", prop={'size': 9})
plt.savefig("%s/reports/%s_%s_cdfs.pdf" %
(options.log_dir, options.config, workload))