-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_break.m
More file actions
363 lines (296 loc) · 8.38 KB
/
basic_break.m
File metadata and controls
363 lines (296 loc) · 8.38 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
% basic hybrid copy migration
global wss numpages readrate dirtyrate pagesize b scinfo
global totaltime downtime totaldata
% memory size in MB
r = 4096
r *= 1024 % convert to KB
% page dirty rate in percent (%): against to total memory pages
readrate = 50
prefix = strcat ("M4G_R", num2str(readrate))
readrate /= 100
dirtyrate = 50
prefix = strcat (prefix, "_W", num2str(dirtyrate))
dirtyrate /= 100
% prediction accuracy 0 through 1
acc = 0
pagesize = 4 % in KB
numpages = r / pagesize
% delta compression rate
comp = 0.5
% amount of CPU and device states in KB
scinfo = 100
% working set size in number of pages
wss = numpages * 0.25
% 0: zero, 1: read, 2: dirtied, 3: inactive data
mem = zeros(1, numpages);
run = 1
%prefix = strcat (prefix, "_acc", num2str(acc), "_r", num2str(run))
% bandwidth in gbps
b = 1000
b = b * 1024/8 % convert to KB
%fontsize = 10
fontsize = 18
%fontsize = 20
totaltime = 0;
downtime = 0;
totaldata = 0;
numrows = 8;
A = zeros(numrows, 3);
row = 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% precopy migration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf('\n')
disp('==================== Precopy migration ====================')
% iterations
present = numpages * pagesize
iter = 0
while present > 50 && iter < 29 && totaldata < 4*r
pretime = present / b
totaltime += pretime
totaldata += present
present = numpages * pagesize * dirtyrate
%dirts = wss * dirtyrate
iter += 1
end
% stop-and-copy phase
% stop conditions: 29 iterations, 50 pages, 4 memory size sent
scsent = scinfo + present * pagesize
downtime = scsent / b
totaltime += downtime
totaldata += scsent
% network fault rate
NFR = 0
A (row, 1) = totaltime;
A (row, 2) = downtime;
A (row, 3) = totaldata;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% postcopy migration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf('\n')
disp('===================== Postcopy migration ======================')
totaltime = 0;
downtime = 0;
totaldata = 0;
% stop-and-copy phase
scsent = scinfo
downtime = scsent / b
totaltime += downtime
totaldata += scsent
% prepaging (bubbling) and on-demand paging
postsent = r
posttime = postsent/b
totaltime += posttime
totaldata += postsent
% network fault rate
NFR = 0.2
row ++
A (row, 1) = totaltime;
A (row, 2) = downtime;
A (row, 3) = totaldata;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% hybrid copy migration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf('\n')
disp('==================== Hybrid copy migration ====================')
totaltime = 0;
downtime = 0;
totaldata = 0;
% precopy phase: single iteration
present = r
pretime = present / b
totaltime += pretime
totaldata += present
% stop-and-copy phase
bitmapsize = numpages * dirtyrate/8/1024 % KB
scsent = scinfo + bitmapsize
downtime = scsent / b
totaltime += downtime
totaldata += scsent
% postcopy phase: prepaging (bubbling) and on-demand paging
%dirts = wss * dirtyrate
dirts = numpages * dirtyrate
postsent = dirts * pagesize
posttime = postsent/b
totaltime += posttime
totaldata += postsent
% network fault rate
NFR = 0.2
row ++
A (row, 1) = totaltime;
A (row, 2) = downtime;
A (row, 3) = totaldata;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% proactive hybrid copy migration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%disp(char(10))
fprintf('\n')
disp('=============== Proactive hybrid copy migration ================')
function [tt, dt, td] = prohybrid(acc)
global wss numpages readrate dirtyrate pagesize b scinfo
global totaltime downtime totaldata
totaltime = 0;
downtime = 0;
totaldata = 0;
% precopy phase
% LRU, PFR
% scan the dirtied pages
% for dirtied pages
% mark dirtied (1)
% mem(random (1, wss * 0.1))
%randperm(int64(wss * 0.1));
% for read pages
% mark read (2)
% mem (random (wss * 0.1, wss * 0.2))
% for pages
% predict read/write
% send the pages most likely to be read and least likely to be dirtied
% do not send the pages most likely to be dirtied
% construct queue with the order of p1/p2
%reads = numpages * 0.4
% total read rate = wss * read_rate = 0.25 * 0.16 = 0.04 (4%)
%read_rate = 0.16
%read_rate = 0.04 % 4% of total memory
% total write rate = wss * write_rate = 0.25 * 0.16 = 0.04 (4%)
%write_rate = 0.16
%write_rate = 0.04 % 4% of total memory
% simple case: readonly pages (RO) - zero dirtied pages
%RO = 0.3
pred_pages = numpages * readrate * acc
% LRU
% for LRU queue
% mark sent
% insert the pages into cache and perform delta compression
present = pred_pages * pagesize
pretime = present/b
totaltime += pretime
totaldata += present
% stop-and-copy phase
% send the CPU and device states
bitmapsize = numpages * dirtyrate / 8 / 1024 % KB
scsent = scinfo + bitmapsize
downtime = scsent/b
totaltime += downtime
totaldata += scsent
% postcopy phase
postsent = (numpages - pred_pages) * pagesize
% exclude the predicted dirtied pages
%pred_dirts = numpages * dirtyrate * acc
pred_dirts = 0;
postsent = (numpages - pred_pages - pred_dirts) * pagesize
posttime = postsent/b
totaltime += posttime
totaldata += postsent
end
% network fault rate
NFR = 0.2
prohybrid(acc); row ++;
A (row, 1) = totaltime;
A (row, 2) = downtime;
A (row, 3) = totaldata;
acc = 0.25; row ++;
prohybrid(acc);
A (row, 1) = totaltime;
A (row, 2) = downtime;
A (row, 3) = totaldata;
acc = 0.5
prohybrid(acc); row ++;
A (row, 1) = totaltime;
A (row, 2) = downtime;
A (row, 3) = totaldata;
acc = 0.75
prohybrid(acc); row ++;
A (row, 1) = totaltime;
A (row, 2) = downtime;
A (row, 3) = totaldata;
acc = 1
prohybrid(acc); row ++;
A (row, 1) = totaltime;
A (row, 2) = downtime;
A (row, 3) = totaldata
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plotting
% precopy
% postcopy
% hybrid
% pro-hybrid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%prefix = "M4G_R14W14_acc100_r1"
%prefix = strcat ("M4G_R", readrate, "W", dirtyrate, "acc", acc, "r", run)
%prefix = strcat (prefix, "W")
%prefix = strcat (prefix, dirtyrate)
% write the matrix to file with delimiter white space
dlmwrite (prefix, A, ' ')
%x = ['PRECOPY', 'POSTCOPY', 'HYBRID', 'PRO-HYBRID'];
%x = {'PRE', 'POST', 'HYBR', 'PROH100', 'PROH75', 'PROH50', 'PROH25', 'PROH0'};
%x = {'PR', 'PO', 'HB', '100', '75', '50', '25', '0'};
x = {'PR', 'PO', 'HB', '0', '25', '50', '75', '100'};
%x = {'PO', 'HB', '0', '25', '50', '75', '100'};
%x = {'1', '2', '3', '4', '5', '6', '7', '8'};
xinterval = 2
xintervals = 1:xinterval:(xinterval*length(x));
%xintervals = 1:3:3*length(x);
%xintervals = 1:4:4*length(x);
%%%%%%%%%%%%%%%%%%%% downtime %%%%%%%%%%%%%%%%%%%%%%
figure;
output = strcat(prefix, ".dt");
ylim1 = [0 0.0015];
ylim2 = [64 66];
%cla;
clf;
p0 = get (gca, 'position');
delete(gcf);
%cla;
%a1 = axes ('position', [p0(1) p0(2) p0(3) p0(4)/2]);
a1 = axes ('position', [p0(1) p0(2) p0(3) p0(4)*2/3]);
bar(xintervals, A(:,2))
%set(gca, 'XTick', xintervals, 'XTickLabel', x, 'FontSize', fontsize)
set(a1, 'XTick', xintervals, 'XTickLabel', x, 'FontSize', fontsize)
set (a1, 'ylim', ylim1);
%set(a1, 'xtick', []);
xlabel('COPY METHOD', 'FontSize', fontsize);
%ylabel('DOWNTIME (SEC)', 'FontSize', fontsize);
a2 = axes ('position', [p0(1) p0(4)*2/3+.15 p0(3) p0(4)/3]);
bar(xintervals, A(:,2))
set(a2, 'ylim', ylim2, 'FontSize', fontsize);
set(a2, 'xtick', []);
ylabel('DOWNTIME (SEC)', 'FontSize', fontsize);
saveas (1, strcat(output, ".png"));
saveas (1, strcat(output, ".eps"));
saveas (1, strcat(output, ".emf"));
%%%%%%%%%%%%%%%%%%%% total time %%%%%%%%%%%%%%%%%%%%%%
clf;
delete(gcf);
figure;
output = strcat(prefix, ".tt");
%output = prefix
%plot(x, A(:,2)/1000000, x, A(:,3)/1000000, '-.*');
%plot(A(:,2));
%xtics = 1:4:16
%bar(xtics, A(:,1))
%bar(A(:,1), XTicksLabelStyle = Diagonal)
bar(xintervals, A(:,1))
%bar(A(:,1))
%set(gca, 'XTick', 1:4:32, 'XTickLabel', x, 'FontSize', fontsize)
set(gca, 'XTick', xintervals, 'XTickLabel', x, 'FontSize', fontsize)
%set(gca, 'XTickLabel', x, 'FontSize', fontsize)
xlabel('COPY METHOD', 'FontSize', fontsize);
ylabel('TOTAL TIME (SEC)', 'FontSize', fontsize);
%legend('PRECOPY', 'POSTCOPY', 'HYBRID', 'PRO-HYBRID');
%bar(x, A(:,1))
saveas (1, strcat(output, ".png"));
saveas (1, strcat(output, ".eps"));
saveas (1, strcat(output, ".emf"));
%%%%%%%%%%%%%%%%%%%% total data %%%%%%%%%%%%%%%%%%%%%%
clf;
figure;
output = strcat(prefix, ".td");
%bar(A(:,3))
bar(xintervals, A(:,3))
%set(gca, 'XTick', 1:8, 'XTickLabel', x, 'FontSize', fontsize)
set(gca, 'XTick', xintervals, 'XTickLabel', x, 'FontSize', fontsize)
xlabel('COPY METHOD', 'FontSize', fontsize);
ylabel('TOTAL DATA (KB)', 'FontSize', fontsize);
saveas (1, strcat(output, ".png"));
saveas (1, strcat(output, ".eps"));
saveas (1, strcat(output, ".emf"));