-
Notifications
You must be signed in to change notification settings - Fork 51
/
disk_utilization.py
49 lines (41 loc) · 1.6 KB
/
disk_utilization.py
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
import numpy
import os
import sys
import parse_logs
def plot_cdf(values, filename):
f = open(filename, "w")
def write_data_to_file(data, file_handle):
stringified_data = [str(x) for x in data]
stringified_data += "\n"
file_handle.write("\t".join(stringified_data))
def main(argv):
map_utilizations = []
reduce_utilizations = []
all_utilizations = []
dirname = argv[0]
for filename in os.listdir(dirname):
full_name = os.path.join(dirname, filename)
if os.path.isfile(full_name) and filename.endswith("job_log"):
print "Reading %s" % filename
analyzer = parse_logs.Analyzer(full_name)
for (id, stage) in analyzer.stages.iteritems():
for task in stage.tasks:
for name, block_device_numbers in task.disk_utilization.iteritems():
if name in ["xvdb", "xvdf"]:
effective_util = 0
if block_device_numbers[0] > 0:
effective_util = (block_device_numbers[1] + block_device_numbers[2]) / block_device_numbers[0]
all_utilizations.append(effective_util)
if task.has_fetch:
reduce_utilizations.append(effective_util)
else:
map_utilizations.append(effective_util)
output_filename = os.path.join(dirname, "disk_utilization_cdf")
f = open(output_filename, "w")
for percent in range(100):
f.write("%s\t%s\t%s\t%s\n" % (percent / 100., numpy.percentile(map_utilizations, percent),
numpy.percentile(reduce_utilizations, percent),
numpy.percentile(all_utilizations, percent)))
f.close()
if __name__ == "__main__":
main(sys.argv[1:])