forked from jssmith/ray-scheduler-prototype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_plots.py
181 lines (152 loc) · 5.6 KB
/
sim_plots.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
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
import sys
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
from analyze_basic import analyze_distn
from plot_workloads import std_scheduler_colors
def usage():
print "Usage: plot_cdfs.py log.gz output.pdf"
def plot_analysis(log_filename, output_filename):
stats = analyze_distn(log_filename)
ts_range = (0, stats['job_completion_time'])
with PdfPages(output_filename) as pdf:
plot_cdf(stats['submit_to_phase0_time'],
'Scheduling Delay [seconds from submit to unblocked execution]',
'Fraction of Tasks',
pdf)
plot_cdf(stats['task_time'],
'Task Duration [seconds]',
'Fraction of Tasks',
pdf)
plot_timeseries(stats['runnable_tasks_timeseries'],
ts_range,
'Runnable Tasks',
pdf)
plot_timeseries(stats['workers_active_timeseries'],
ts_range,
'Workers Active',
pdf)
plot_timeseries(stats['workers_blocked_timeseries'],
ts_range,
'Workers Blocked',
pdf)
plot_timeseries(stats['object_transfers_active_timeseries'],
ts_range,
'Object Transfers Active',
pdf)
plot_worker_activity(stats['worker_activity'], pdf)
def plot_cdf(data,
x_variable_description,
y_variable_description,
pdf):
# print 'min {} max {}'.format(min(data), max(data))
sorted_data = np.sort(np.asarray(data))
yvals=np.arange(len(sorted_data))/float(len(sorted_data)-1)
# plt.plot(sorted_data,yvals)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.semilogx(sorted_data,yvals)
ax.set_xlabel(x_variable_description)
ax.set_ylabel(y_variable_description)
pdf.savefig(fig)
plt.close(fig)
def plot_timeseries(data,
x_range,
y_variable_description,
pdf):
times = map(lambda x: x[0], data)
values = map(lambda x: x[1], data)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(times, values, drawstyle='steps-post', linewidth=1.0)
ax.set_xlabel('Time [seconds]')
ax.set_ylabel(y_variable_description)
plt.xlim(x_range)
pdf.savefig(fig)
plt.close(fig)
def plot_worker_activity(data, pdf, title=None):
workers = sorted(data.keys())
width = .8
padding = .2
baseline = padding / 2
fig = plt.figure()
ax = fig.add_subplot(111)
for worker in workers:
last_started = None
last_running = None
last_blocked = None
active_ranges = []
running_ranges = []
for (timestamp, (task_id, status)) in data[worker]:
if status == 'initialized':
last_started = timestamp
last_running = None
last_blocked = None
if status == 'freed':
active_ranges.append((last_started, timestamp - last_started))
last_started = None
if status == 'running':
if last_blocked == timestamp:
(last_running, _) = running_ranges.pop()
else:
last_running = timestamp
if status == 'blocked':
last_blocked = timestamp
running_ranges.append((last_running, timestamp - last_running))
plt.broken_barh(active_ranges, (baseline, width), color='gray')
plt.broken_barh(running_ranges, (baseline, width), color='orange', linewidth=0.0)
baseline += width + padding
ax.set_ylabel('Node ID and Worker ID')
ax.set_yticks(list(0.5 + x for x in range(len(workers))))
ax.set_yticklabels(map(lambda x: str(x), workers))
ax.set_xlabel('Time [seconds]')
if title is not None:
ax.set_title(title)
else:
ax.set_title('Worker Activity')
pdf.savefig(fig)
plt.close(fig)
def build_submit_phase0_cdf_multi_scheduler(workload_name, scheduler_inputs, output_filename):
scheduler_dist = []
for scheduler, log_filename in scheduler_inputs:
scheduler_dist.append((scheduler, analyze_distn(log_filename)))
plot_cdf_multi_scheduler(scheduler_dist,
'Scheduling Delay [seconds from submit to unblocked execution]',
'Fraction of Tasks',
'Scheduling Delay - {} - 4 nodes'.format(workload_name),
output_filename)
def plot_cdf_multi_scheduler(all_data,
x_variable_description,
y_variable_description,
title,
output_filename):
fig_dpi = 300
plt.rcParams.update({'font.size': 6})
scheduler_plot_order = {
'trivial': 1,
'location_aware': 2,
'transfer_aware': 3}
fig = plt.figure(figsize=(4,3), dpi=fig_dpi)
ax = fig.add_subplot(111)
for scheduler, data in sorted(all_data, key=lambda (s, d): scheduler_plot_order[s]):
sorted_data = np.sort(np.asarray(data['submit_to_phase0_time']))
yvals=np.arange(len(sorted_data))/float(len(sorted_data)-1)
if scheduler == 'trivial':
linewidth = 4.0
else:
linewidth = 1.0
ax.plot(sorted_data,yvals, c=std_scheduler_colors[scheduler], label=scheduler, linewidth=linewidth)
ax.set_xlabel(x_variable_description, labelpad=2)
ax.set_ylabel(y_variable_description, labelpad=2)
ax.set_title(title)
ax.legend(shadow=True, fancybox=True, prop={'size':6})
print 'saving cdf to figure {}'.format(output_filename)
fig.savefig(output_filename, dpi=fig_dpi)
plt.close(fig)
if __name__ == '__main__':
if len(sys.argv) != 3:
usage()
sys.exit(1)
log_filename = sys.argv[1]
output_filename = sys.argv[2]
plot_analysis(log_filename, output_filename)