Repository navigation
Expand file tree
/
Copy pathtput.py
More file actions
executable file
·128 lines (114 loc) · 3.85 KB
/
Copy pathtput.py
File metadata and controls
executable file
·128 lines (114 loc) · 3.85 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
#!/usr/bin/python3
"""
Analyzes throughput of message arrivals in a timetrace.
Usage: tput.py [--verbose] [tt_file]
The existing timetrace is in tt_file (or stdin in tt_file is omitted).
"""
from glob import glob
from optparse import OptionParser
import math
import os
import re
import string
import sys
verbose = False
if (len(sys.argv) >= 2) and (sys.argv[1] == "--verbose"):
verbose = True
sys.argv.pop(1)
if len(sys.argv) == 2:
f = open(sys.argv[1])
elif len(sys.argv) == 1:
f = sys.stdin
else:
print("Usage: %s [tt_file]" % (sys.argv[0]))
sys.exit(1)
# Keys are RPC ids, values are dictionaries containing the following fields:
# start: time offset 0 received
# grant: time the first grant was sent
# grant_offset: offset in last data packet after first grant
# end: time last packet received
# offset: highest offset in any packet received for the RPC
rpcs = {}
for line in f:
match = re.match(' *([-0-9.]+) us .* \[C([0-9]+)\]', line)
if not match:
continue
time = float(match.group(1))
core = match.group(2)
match = re.match('.*sending grant for id ([0-9]+)',
line)
if match:
id = match.group(1)
if id in rpcs and not 'grant' in rpcs[id]:
rpcs[id]['grant'] = time
rpcs[id]['grant_offset'] = rpcs[id]['offset']
match = re.match('.*homa_gro_receive got packet .* id ([0-9]+), '
'offset ([0-9]+)', line)
if match:
id = match.group(1)
offset = int(match.group(2))
if (not id in rpcs) and (offset == 0):
rpcs[id] = {'offset': 0, 'start': time}
if id in rpcs:
rpcs[id]['end'] = time
if offset > rpcs[id]['offset']:
rpcs[id]['offset'] = offset
match = re.match('.*incoming data packet, id ([0-9]+), .* offset '
'([0-9]+)/([0-9]+)', line)
if match:
id = match.group(1)
length = int(match.group(3))
if id in rpcs:
rpcs[id]['length'] = length
total_bytes = 0
total_bytes2 = 0
total_time = 0
total_time2 = 0
tputs = []
tputs2 = []
for id in sorted(rpcs.keys()):
rpc = rpcs[id]
if (not 'start' in rpc) or (not 'end' in rpc):
continue
if rpc['offset'] < 300000:
continue
bytes = rpc['offset']
time = rpc['end'] - rpc['start']
tput = bytes*8.0/time/1000
tputs.append(tput)
total_bytes += bytes
total_time += time
# Compute separate statistics for throughput after sending the first
# grant (this eliminates time waiting for the message to become highest
# priority)
if 'grant' in rpc:
bytes2 = rpc['offset'] - rpc['grant_offset']
time2 = rpc['end'] - rpc['grant']
tput2 = bytes2*8.0/time2/1000
tputs2.append(tput2)
total_bytes2 += bytes2
total_time2 += time2
if verbose:
print("%9.3f: id %s, grant at %9.3f, offset grant_offset %d, "
"last_offset %d at %9.3f, tput %.1f, tput2 %.1f" % (
rpc['start'], id, rpc['grant'], rpc['grant_offset'], rpc['offset'],
rpc['end'], tput, tput2))
tputs.sort()
if verbose:
print("")
print("Messages >= 300KB: %d" % (len(tputs)))
print("Entire messages:")
print("Minimum tput: %4.1f Gbps" % (tputs[0]))
print("Median tput: %4.1f Gbps" % (tputs[len(tputs)//2]))
print("P90 tput: %4.1f Gbps" % (tputs[len(tputs)*9//10]))
print("P99 tput: %4.1f Gbps" % (tputs[len(tputs)*99//100]))
print("Maximum tput: %4.1f Gbps" % (tputs[-1]))
print("Average tput: %4.1f Gbps" % (total_bytes*8.0/total_time/1000))
tputs2.sort()
print("\nMessage data after first grant:")
print("Minimum tput: %4.1f Gbps" % (tputs2[0]))
print("Median tput: %4.1f Gbps" % (tputs2[len(tputs2)//2]))
print("P90 tput: %4.1f Gbps" % (tputs2[len(tputs2)*9//10]))
print("P99 tput: %4.1f Gbps" % (tputs2[len(tputs2)*99//100]))
print("Maximum tput: %4.1f Gbps" % (tputs2[-1]))
print("Average tput: %4.1f Gbps" % (total_bytes2*8.0/total_time2/1000))