Repository navigation
Expand file tree
/
Copy pathcp_client_threads
More file actions
executable file
·103 lines (91 loc) · 3.44 KB
/
Copy pathcp_client_threads
File metadata and controls
executable file
·103 lines (91 loc) · 3.44 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
#!/usr/bin/python3
# Copyright (c) 2020-2023 Homa Developers
# SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0+
# This cperf benchmark measures the throughput of a single client as a
# function of the number of sending threads
from cperf import *
parser = get_parser(description=
'Measures throughput of a single client as a function of the number '
' of sending threads.',
usage='%(prog)s [options]',
defaults={
"server_ports": 6,
"port_threads": 3})
options = parser.parse_args()
options.no_rtt_files = True
init(options)
if options.num_nodes < 2:
print("--num_nodes too small (%d): must be at least 2"
% (options.num_nodes))
sys.exit(-1)
dir = "%s/reports" % (options.log_dir)
if not os.path.exists(dir):
os.makedirs(dir)
options.server_nodes = options.num_nodes - 1
options.first_server = 1
options.port_receivers = 1
options.no_rtt_files = True
options.gbps = 0.0
workloads = ["w1", "w2", "w3", "w4", "w5"]
port_range = range(1,11)
# Run the experiments, if desired
if not options.plot_only:
start_servers(range(1, options.num_nodes), options)
for workload in workloads:
for ports in port_range:
exp = "%s_%s_%d" % (options.protocol, workload, ports)
options.workload = workload
options.client_ports = ports
options.tcp_client_ports = ports
run_experiment(exp, range(0,1), options)
log("Stopping nodes")
stop_nodes()
# Parse the log files to extract useful data
experiments = {}
scan_log(options.log_dir + "/node0.log", "node0", experiments)
# Keys are workload names, values are lists of throughputs for each
# number of ports
tput = {}
for workload in workloads:
tput[workload] = []
for ports in port_range:
exp = "%s_%s_%d" % (options.protocol, workload, ports)
node = experiments[exp]["node0"]
readings = node["client_kops"]
if len(readings) == 0:
raise Error("No client RPC throughput found for experiment %s"
% (exp))
tput[workload].append(sum(readings)/len(readings))
# print(tput)
fig, (ax1, ax2) = plt.subplots(2, figsize=[4, 5])
fig.suptitle("%s Single-Client Throughput" % (options.protocol.capitalize()),
y=0.95)
plt.rcParams.update({'font.size': 10})
ax1.set_ylim(0, 2000)
ax2.set_ylim(0, 60)
for axis in [ax1, ax2]:
axis.get_xaxis().set_tick_params(direction='in')
axis.get_yaxis().set_tick_params(direction='in')
axis.set_xlim(0, port_range[-1])
top = axis.twiny()
top.set_xlim(0, port_range[-1])
top.set_xticklabels([])
top.get_xaxis().set_tick_params(direction='in')
axis.set_ylabel("Kops/second")
right = axis.twinx()
right.set_ylim(0, axis.get_ylim()[1])
right.set_yticklabels([])
right.get_yaxis().set_tick_params(direction='in')
ax1.grid(axis='y', which='major', linestyle='dotted')
ax2.set_xlabel("Sending threads")
ax2.grid(axis='y', which='major', linestyle='dotted')
colors = ['#9467bd', '#d62728', '#2ca02c', '#ff7f0e', '#1f77b4']
for workload in workloads:
if (workload == "w4") or (workload == "w5"):
ax2.plot(port_range, tput[workload], label=workload, color=colors.pop())
else:
ax1.plot(port_range, tput[workload], label=workload, color=colors.pop())
ax1.legend(loc="upper left", prop={'size': 9})
ax2.legend(loc="upper left", prop={'size': 9})
# plt.tight_layout()
plt.savefig("%s/reports/%s_client_tput.pdf" % (options.log_dir, options.protocol))