-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze_multiple.py
1042 lines (920 loc) · 31.6 KB
/
analyze_multiple.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
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.15.2
# kernelspec:
# display_name: incast-analysis-venv
# language: python
# name: incast-analysis-venv
# ---
# %% editable=true slideshow={"slide_type": ""}
# %matplotlib widget
import math
import multiprocessing
import os
from os import path
import pickle
import numpy as np
from matplotlib import pyplot as plt
import analysis
PARALLEL = False
COLORS_FRIENDLY_HEX = [
"#d73027", # red
"#fc8d59", # orange
"#a68f51", # gold
"#91bfdb", # light blue
"#4575b4", # dark blue
"grey",
]
FLOWSS = [50, 100, 150, 200, 500, 1000]
DUR_MS = "15ms"
DESIRED = {
"incast_queue_across_bursts",
"inflight_metrics_across_bursts",
"sender_to_inflights_by_burst",
}
# %% editable=true slideshow={"slide_type": ""}
def load_one(exp_dir):
if not path.exists(exp_dir):
return None
data_flp = path.join(exp_dir, "data.pickle")
if path.exists(data_flp):
# if False:
print(f"Loading from file: {exp_dir}...")
with open(data_flp, "rb") as fil:
try:
data = pickle.load(fil)
print(f"Succeeded loading from file: {data_flp}")
return data
except KeyboardInterrupt:
raise
except:
print(f"Warning: Failed loading from file: {data_flp}")
try:
data = analysis.get_all_metrics_for_exp(
exp_dir, interp_delta=1e5, desired=DESIRED
)
except KeyboardInterrupt:
raise
except:
print(f"Error during: {exp_dir}")
raise
with open(data_flp, "wb") as fil:
pickle.dump(data, fil)
return data
def load_all(sweep_dir, filt=None):
exp_dirs = [
path.join(sweep_dir, dirn)
for dirn in os.listdir(sweep_dir)
if dirn != "graphs" and dirn != "tmpfs" and dirn[-7:] != ".pickle"
]
exp_dirs = [
exp_dir
for exp_dir in exp_dirs
if filt is None or filt(analysis.get_config_json(exp_dir))
]
print(f"Loading {len(exp_dirs)} experiments...")
if PARALLEL:
with multiprocessing.Pool(processes=20) as pool:
exp_to_data = dict(zip(exp_dirs, pool.map(load_one, exp_dirs)))
else:
exp_to_data = {exp_dir: load_one(exp_dir) for exp_dir in exp_dirs}
exp_to_data = {exp: data for exp, data in exp_to_data.items() if data is not None}
print(f"Loaded {len(exp_to_data)} experiments.")
return exp_to_data
def graph_simple(
lines, graph_dir, xlabel, ylabel, legend_title, prefix=None, suffix=None, width=10
):
fig, axes = analysis.get_axes(width=width)
ax = axes[0]
max_x = 0
max_y = 0
for xs, ys, label in lines:
ax.plot(
xs,
ys,
# COLORS_FRIENDLY_HEX[i],
label=label,
linewidth=analysis.LINESIZE,
alpha=0.9,
)
max_x = max(max_x, xs[-1])
max_y = max(max_y, *ys)
ax.set_xlabel(xlabel, fontsize=analysis.FONTSIZE)
ax.set_ylabel(ylabel, fontsize=analysis.FONTSIZE)
ax.set_xlim(left=-0.01 * max_x, right=1.01 * max_x)
ax.set_ylim(bottom=-0.01 * max_y, top=1.1 * max_y)
ax.tick_params(axis="x", labelsize=analysis.FONTSIZE)
ax.tick_params(axis="y", labelsize=analysis.FONTSIZE)
ax.legend(
fontsize=analysis.FONTSIZE,
bbox_to_anchor=(1.02, 0.5),
loc="center left",
title=legend_title,
title_fontsize=analysis.FONTSIZE,
ncols=math.ceil(len(lines) / 7),
)
analysis.show(fig)
analysis.save(graph_dir, prefix, suffix)
def graph_avg_queue_length(exp_to_data, dur_ms, graph_dir):
flowss = sorted(
list({data["config"]["numBurstSenders"] for data in exp_to_data.values()})
)
rwnds = [None] + sorted(
list(
{
data["config"]["staticRwndBytes"]
for data in exp_to_data.values()
if data["config"]["rwndStrategy"] == "static"
}
)
)
lines = []
for rwnd in rwnds:
xs = []
ys = []
for flows in flowss:
data = [
data
for data in exp_to_data.values()
if (
(data["config"]["numBurstSenders"] == flows)
and (
# No RWND
(rwnd is None and data["config"]["rwndStrategy"] == "none")
or
# RWND
(
rwnd is not None
and data["config"]["rwndStrategy"] == "static"
and data["config"]["staticRwndBytes"] == rwnd
)
)
)
]
if len(data) == 0:
print(f"looking for RWND {rwnd} and {flows} flows")
print("\n".join(sorted(exp_to_data.keys())))
assert len(data) == 1, f"Expected 1 but found: {len(data)}"
data = data[0]
xs.append(data["config"]["numBurstSenders"])
_, avg_lengths, _, _, _, _, _ = data["incast_queue_across_bursts"]
ys.append(np.mean(avg_lengths))
lines.append((xs, ys, "None" if rwnd is None else round(rwnd / 1024)))
graph_simple(
lines,
graph_dir,
"flows",
"average queue length\n(packets)",
"RWND Clamp (KB)",
f"avg_queue_length_{dur_ms}ms",
)
def graph_avg_tput(exp_to_data, dur_ms, graph_dir):
flowss = sorted(
list({data["config"]["numBurstSenders"] for data in exp_to_data.values()})
)
rwnds = [None] + sorted(
list(
{
data["config"]["staticRwndBytes"]
for data in exp_to_data.values()
if data["config"]["rwndStrategy"] == "static"
}
)
)
lines = []
for rwnd in rwnds:
xs = []
ys = []
for flows in flowss:
data = [
data
for data in exp_to_data.values()
if (
(data["config"]["numBurstSenders"] == flows)
and (
# No RWND
(rwnd is None and data["config"]["rwndStrategy"] == "none")
or
# RWND
(
rwnd is not None
and data["config"]["rwndStrategy"] == "static"
and data["config"]["staticRwndBytes"] == rwnd
)
)
)
]
assert len(data) == 1
data = data[0]
xs.append(data["config"]["numBurstSenders"])
ys.append(np.mean(data["avg_tput_by_burst_bps"][1:]) / 1e9)
lines.append((xs, ys, "None" if rwnd is None else round(rwnd / 1024)))
graph_simple(
lines,
graph_dir,
"flows",
"average throughput\n(Gbps)",
"RWND Clamp (KB)",
f"avg_tput_{dur_ms}ms",
)
# Graph queue over time for various RWND thresholds.
def graph_queue(
lines,
dur_ms,
marking_threshold_packets,
capacity_packets,
graph_dir,
legend_title=None,
prefix=None,
suffix=None,
ncols=3,
):
fig, axes = analysis.get_axes()
ax = axes[0]
LINESTYLES: List[Any] = [
"solid",
"dashdot",
# (5, (10, 3)),
(0, (5, 7)),
(0, (3, 5, 1, 5)),
]
# Plot a line for each RWND clamp.
max_x = 0
max_y = 0
for idx, (xs, ys, label) in enumerate(lines):
# xs = xs - xs[0]
xs = xs * 1e3
ax.plot(
xs,
ys,
drawstyle="steps-post",
label=label,
linewidth=analysis.LINESIZE,
linestyle=LINESTYLES[idx],
alpha=0.9,
)
max_x = max(max_x, xs[-1])
max_y = max(max_y, *ys)
# Draw a line at the marking threshold
ax.plot(
[0, max_x],
[marking_threshold_packets] * 2,
label="ECN\nthreshold" if dur_ms == 2 else "ECN threshold",
color="orange",
linestyle="dashed",
linewidth=analysis.LINESIZE,
alpha=0.9,
)
# Draw a line at the queue capacity
if max_y > capacity_packets / 2:
# Draw a line at the queue capacity
ax.plot(
[0, max_x],
[capacity_packets] * 2,
label="queue capacity",
color="red",
linestyle="dotted",
linewidth=analysis.LINESIZE,
alpha=0.9,
)
max_y = capacity_packets
elif len(lines) == 1:
max_y = capacity_packets / 2
ax.set_xlabel("time (ms)", fontsize=analysis.FONTSIZE)
ax.set_ylabel(
"packets" if len(lines) == 1 else "queue length\n(packets)",
fontsize=analysis.FONTSIZE,
)
ax.tick_params(axis="x", labelsize=analysis.FONTSIZE)
ax.tick_params(axis="y", labelsize=analysis.FONTSIZE)
ax.set_xlim(left=-0.01 * max_x, right=1.01 * max_x)
ax.set_ylim(bottom=-0.01 * max_y, top=1.1 * max_y)
print("dur_ms", dur_ms)
if dur_ms == 2:
print("putting legend outside")
ax.legend(
fontsize=analysis.FONTSIZE,
ncols=ncols,
**(
{}
if legend_title is None
else {"title": legend_title, "title_fontsize": analysis.FONTSIZE}
),
bbox_to_anchor=(1.02, 0.5),
loc="center left",
)
else:
ax.legend(
fontsize=analysis.FONTSIZE,
loc="center right" if max_y > capacity_packets / 2 else "upper right",
ncols=ncols,
**(
{}
if legend_title is None
else {"title": legend_title, "title_fontsize": analysis.FONTSIZE}
),
)
plt.tight_layout()
analysis.show(fig)
analysis.save(graph_dir, prefix, suffix)
# Graph FCT distribution for various RWND thresholds
def graph_fct(lines, graph_dir, dur_ms, fln):
fig, axes = analysis.get_axes(width=6) # if len(lines) > 1 else 3)
ax = axes[0]
max_x = 0
for fcts, label in lines:
max_x = max(max_x, *fcts)
count, bins_count = np.histogram(fcts, bins=len(fcts))
ax.plot(
bins_count[1:],
np.cumsum(count / sum(count)),
label=label,
linewidth=analysis.LINESIZE,
alpha=0.9,
)
ax.set_xlabel("flow duration (ms)", fontsize=analysis.FONTSIZE)
ax.set_ylabel("CDF", fontsize=analysis.FONTSIZE)
ax.tick_params(axis="x", labelsize=analysis.FONTSIZE)
ax.tick_params(axis="y", labelsize=analysis.FONTSIZE)
ax.set_xlim(left=-0.01 * max_x, right=1.01 * max_x)
ax.set_ylim(bottom=-0.01, top=1.01)
if len(lines) > 1:
ax.legend(
fontsize=analysis.FONTSIZE,
# bbox_to_anchor=(1.02, 0.5),
# loc="center left",
loc="upper left",
# ncols=ncols,
title="RWND clamp (KB)",
title_fontsize=analysis.FONTSIZE,
)
analysis.show(fig)
analysis.save(graph_dir, f"{fln}_{dur_ms}ms")
# Graph p95 in-flight data over time for various RWND thresholds
def graph_p95_bytes_in_flight(exp_to_data, dur_ms, flows, graph_dir):
fig, axes = analysis.get_axes()
ax = axes[0]
# Plot a line for No RWND tuning
none = [
data
for data in exp_to_data.values()
if (
data["config"]["rwndStrategy"] == "none"
and data["config"]["numBurstSenders"] == flows
)
]
assert len(none) == 1
# Plot a line for each RWND clamp.
max_x = 0
max_y = 0
for data in (
list(
reversed(
sorted(
(
data
for data in exp_to_data.values()
if (
data["config"]["rwndStrategy"] == "static"
and data["config"]["staticRwndBytes"] < 11000
and data["config"]["numBurstSenders"] == flows
)
),
key=lambda p: p["config"]["staticRwndBytes"],
)
)
)
+ none
):
# Skip odd RWND clamps
if (
data["config"]["rwndStrategy"] == "static"
and round(data["config"]["staticRwndBytes"] / 1024) % 2 == 1
):
continue
# Last element in the tuple is the total in-flight data
xs, _, _, _, _, percentiles, _ = data["inflight_metrics_across_bursts"]
# xs = np.asarray(xs) - xs[0]
xs = xs * 1e3
# Extract p95
ys = percentiles[4]
ys = ys / 1e3
xs = xs[: len(ys)]
ys = ys[: len(xs)]
ax.plot(
xs,
ys,
# COLORS_FRIENDLY_HEX[i],
label=(
"None"
if data["config"]["rwndStrategy"] == "none"
else round(data["config"]["staticRwndBytes"] / 1024)
),
linewidth=analysis.LINESIZE,
alpha=0.9,
)
max_x = max(max_x, xs[-1])
max_y = max(max_y, *ys)
ax.set_xlabel("time (ms)", fontsize=analysis.FONTSIZE)
ax.set_ylabel("per-flow in-flight data\n(p95, KB)", fontsize=analysis.FONTSIZE)
ax.set_xlim(left=-0.01 * max_x, right=1.01 * max_x)
ax.set_ylim(bottom=-0.01 * max_y, top=1.1 * max_y)
ax.tick_params(axis="x", labelsize=analysis.FONTSIZE)
ax.tick_params(axis="y", labelsize=analysis.FONTSIZE)
ax.legend(
fontsize=analysis.FONTSIZE,
# bbox_to_anchor=(1.02, 0.5),
# loc="center left",
loc="upper center",
title="RWND clamp (KB)",
title_fontsize=analysis.FONTSIZE,
ncols=3,
)
plt.tight_layout()
analysis.show(fig)
analysis.save(
graph_dir,
suffix=f"staticRwnd_p95_bytes_in_flight_{dur_ms}ms_{none[0]['config']['numBurstSenders']}flows",
)
# Graph total in-flight data over time for various RWND thresholds
def graph_total_inflight(exp_to_data, dur_ms, flows, graph_dir):
fig, axes = analysis.get_axes()
ax = axes[0]
# Plot a line for No RWND tuning
none = [
data
for data in exp_to_data.values()
if (
data["config"]["rwndStrategy"] == "none"
and data["config"]["numBurstSenders"] == flows
)
]
assert len(none) == 1
# Plot a line for each RWND clamp.
max_x = 0
max_y = 0
for data in (
list(
reversed(
sorted(
(
data
for data in exp_to_data.values()
if (
data["config"]["rwndStrategy"] == "static"
and data["config"]["staticRwndBytes"] < 11000
and data["config"]["numBurstSenders"] == flows
)
),
key=lambda p: p["config"]["staticRwndBytes"],
)
)
)
+ none
):
# Skip odd RWND clamps
if (
data["config"]["rwndStrategy"] == "static"
and round(data["config"]["staticRwndBytes"] / 1024) % 2 == 1
):
continue
bdp_bytes = (
data["config"]["smallLinkBandwidthMbps"]
* 1e6
/ 8
* 6
* data["config"]["delayPerLinkUs"]
/ 1e6
)
# print(bdp_bytes)
# Last element in the tuple is the total inflight
xs, _, _, _, _, _, total_ys = data["inflight_metrics_across_bursts"]
# print(total_ys[:10])
# xs = np.array(xs) - xs[0]
xs = xs * 1e3
total_ys = total_ys / bdp_bytes
ax.plot(
xs,
total_ys,
# COLORS_FRIENDLY_HEX[i],
label=(
"None"
if data["config"]["rwndStrategy"] == "none"
else round(data["config"]["staticRwndBytes"] / 1024)
),
linewidth=analysis.LINESIZE,
alpha=0.9,
)
max_x = max(max_x, xs[-1])
max_y = max(max_y, *total_ys)
ax.set_xlabel("time (ms)", fontsize=analysis.FONTSIZE)
ax.set_ylabel("total in-flight data\n(x BDP)", fontsize=analysis.FONTSIZE)
ax.set_xlim(left=-0.01 * max_x, right=1.01 * max_x)
ax.set_ylim(bottom=-0.01 * max_y, top=1.1 * max_y)
ax.tick_params(axis="x", labelsize=analysis.FONTSIZE)
ax.tick_params(axis="y", labelsize=analysis.FONTSIZE)
ax.legend(
fontsize=analysis.FONTSIZE,
# bbox_to_anchor=(1.02, 0.5),
# loc="center left",
loc="upper right",
title="RWND clamp (KB)",
title_fontsize=analysis.FONTSIZE,
ncols=3,
)
plt.tight_layout()
analysis.show(fig)
analysis.save(
graph_dir,
suffix=f"staticRwnd_total_in_flight_data_{dur_ms}ms_{none[0]['config']['numBurstSenders']}flows",
)
# Graph all flows in flight data over time for a specific RWND clamp
def graph_sender_inflight(exp_to_data, dur_ms, graph_dir, clamp):
fig, axes = analysis.get_axes()
ax = axes[0]
options = [
data
for data in exp_to_data.values()
if data["config"]["rwndStrategy"] == "static"
and data["config"]["staticRwndBytes"] == clamp
]
assert len(options) == 1
data = options[0]
max_x = 0
max_y = 0
for bursts in data["sender_to_inflights_by_burst"].values():
burst = bursts[-1]
xs, ys = zip(*burst)
# xs = np.array(xs) - xs[0]
xs = xs * 1e3
ax.plot(
xs,
ys,
linewidth=analysis.LINESIZE,
alpha=0.9,
)
max_x = max(max_x, xs[-1])
max_y = max(max_y, *ys)
ax.set_xlabel("time (ms)", fontsize=analysis.FONTSIZE)
ax.set_ylabel("in-flight data (bytes)", fontsize=analysis.FONTSIZE)
# ax.set_xlim(left=0)
ax.set_ylim(bottom=-1, top=max_y * 1.1)
ax.tick_params(axis="x", labelsize=analysis.FONTSIZE)
ax.tick_params(axis="y", labelsize=analysis.FONTSIZE)
plt.tight_layout()
analysis.show(fig)
analysis.save(
graph_dir,
suffix=f"in_flight_data_{dur_ms}ms_{data['config']['numBurstSenders']}flows_{clamp}KB",
)
# %%
def generate_graphs_for_duration(exp_to_data, dur_ms, graph_dir):
ecn_threshs_packets = {
data["config"]["smallQueueMinThresholdPackets"] for data in exp_to_data.values()
}
assert len(ecn_threshs_packets) == 1
ecn_thresh_packets = ecn_threshs_packets.pop()
queue_capacities_packets = {
data["config"]["smallQueueSizePackets"] for data in exp_to_data.values()
}
assert len(queue_capacities_packets) == 1
queue_capacity_packets = queue_capacities_packets.pop()
# Average queue length vs. number of flows; Line for each RWND clamp ###########################
print(
f"Average queue length vs. flow count for duration {dur_ms}ms, for various RWND clamps:"
)
graph_avg_queue_length(exp_to_data, dur_ms, graph_dir)
# Average throughput vs. number of flows; Line for each RWND clamp ############################
print(
f"Average throughput vs. flow count for duration {dur_ms}ms, for various RWND clamps:"
)
graph_avg_tput(exp_to_data, dur_ms, graph_dir)
# Queue length - Special cases #################################################################
#### For 2ms, plot one graph with all flow counts
if dur_ms == 2:
datas = [
data
for data in exp_to_data.values()
if data["config"]["rwndStrategy"] == "none"
]
lines = []
for data in sorted(datas, key=lambda d: d["config"]["numBurstSenders"]):
if data["config"]["numBurstSenders"] not in {100, 150, 200, 500}:
continue
xs, avg_ys, _, _, _, _, _ = data["incast_queue_across_bursts"]
lines.append((xs, avg_ys, data["config"]["numBurstSenders"]))
print(f"Queue length over time for duration {dur_ms}ms, no RWND:")
graph_queue(
lines,
dur_ms,
ecn_thresh_packets,
queue_capacity_packets,
graph_dir,
prefix=f"noRwnd_{dur_ms}ms_allFlowCounts",
suffix="incast_queue",
ncols=1,
legend_title="Flow count",
)
for flows in FLOWSS:
print(flows)
# P95 per-flow in-flight data across bursts ###############################################
print(
f"p95 (across senders) in-flight data for duration {dur_ms}ms and {flows} flows, various RWND clamps:"
)
graph_p95_bytes_in_flight(exp_to_data, dur_ms, flows, graph_dir)
# Total in-flight data across bursts ######################################################
print(
f"Total in-flight data for duration {dur_ms}ms and {flows} flows, various RWND clamps:"
)
graph_total_inflight(exp_to_data, dur_ms, flows, graph_dir)
# FCT #####################################################################################
#### FCT - No RWND tuning
none = [
data
for data in exp_to_data.values()
if (
data["config"]["numBurstSenders"] == flows
and data["config"]["rwndStrategy"] == "none"
)
]
assert len(none) == 1
none = none[0]
fcts = []
# Merge all samples across bursts
for burst_idx in range(1, none["config"]["numBursts"]):
times = [
flow_times_by_burst[burst_idx]
for flow_times_by_burst in none[
"sender_to_flow_times_by_burst"
].values()
]
fcts.extend([(end - start) * 1e3 for start, _, end, _ in times])
# (FCTs, label)
lines = [(fcts, None)]
print(f"CDF of FCT for duration {dur_ms}ms and {flows} flows, no RWND:")
graph_fct(
lines,
graph_dir,
dur_ms,
f"noRwnd_{dur_ms}ms_{none['config']['numBurstSenders']}flows_fct",
)
#### FCT - Line for each RWND clamp
datas = [
data
for data in exp_to_data.values()
if data["config"]["numBurstSenders"] == flows
]
# Add a line for No RWND tuning
none = [data for data in datas if data["config"]["rwndStrategy"] == "none"]
assert len(none) == 1
# Add a line for each RWND clamp.
lines = []
for data in (
list(
reversed(
sorted(
(
data
for data in datas
if (
data["config"]["rwndStrategy"] == "static"
and data["config"]["staticRwndBytes"] < 11000
)
),
key=lambda p: p["config"]["staticRwndBytes"],
)
)
)
+ none
):
# Skip odd RWND clamps
if (
data["config"]["rwndStrategy"] == "static"
and round(data["config"]["staticRwndBytes"] / 1024) % 2 == 1
):
continue
fcts = []
for burst_idx in range(1, data["config"]["numBursts"]):
times = [
flow_times_by_burst[burst_idx]
for flow_times_by_burst in data[
"sender_to_flow_times_by_burst"
].values()
]
fcts.extend([(end - start) * 1e3 for start, _, end, _ in times])
lines.append(
(
fcts,
# Label
(
"None"
if data["config"]["rwndStrategy"] == "none"
else round(data["config"]["staticRwndBytes"] / 1024)
),
)
)
print(
f"CDF of FCT for duration {dur_ms}ms and {flows} flows, for various RWND clamps:"
)
graph_fct(lines, graph_dir, dur_ms, f"staticRwnd_{dur_ms}ms_{flows}flows_fct")
# Queue length #############################################################################
#### Queue length - No RWND tuning
datas = [
data
for data in exp_to_data.values()
if data["config"]["numBurstSenders"] == flows
]
# Add a line for No RWND tuning
none = [data for data in datas if data["config"]["rwndStrategy"] == "none"]
assert len(none) == 1
none = none[0]
xs, avg_ys, _, _, _, _, _ = none["incast_queue_across_bursts"]
xs = np.asarray(xs)
lines = [(xs, avg_ys, "queue length")]
print(
f"Queue length over time for duration {dur_ms}ms and {flows} flows, no RWND:"
)
graph_queue(
lines,
dur_ms,
ecn_thresh_packets,
queue_capacity_packets,
graph_dir,
prefix=f"noRwnd_{dur_ms}ms_{flows}flows",
suffix="incast_queue",
ncols=2,
)
#### Queue length - Line for each RWND clamp
datas = [
data
for data in exp_to_data.values()
if data["config"]["numBurstSenders"] == flows
]
# Add a line for No RWND tuning
none = [data for data in datas if data["config"]["rwndStrategy"] == "none"]
assert len(none) == 1
# Add a line for each RWND clamp.
lines = []
for data in (
list(
reversed(
sorted(
(
data
for data in datas
if (
data["config"]["rwndStrategy"] == "static"
and data["config"]["staticRwndBytes"] < 11000
)
),
key=lambda p: p["config"]["staticRwndBytes"],
)
)
)
+ none
):
# Skip odd RWND clamps
if (
data["config"]["rwndStrategy"] == "static"
and round(data["config"]["staticRwndBytes"] / 1024) % 2 == 1
):
continue
xs, avg_ys, _, _, _, _, _ = data["incast_queue_across_bursts"]
xs = np.asarray(xs)
lines.append(
(
xs,
avg_ys,
"None"
if data["config"]["rwndStrategy"] == "none"
else round(data["config"]["staticRwndBytes"] / 1024),
)
)
print(
f"Queue length over time for duration {dur_ms}ms and {flows} flows, for various RWND clamps:"
)
graph_queue(
lines,
dur_ms,
ecn_thresh_packets,
queue_capacity_packets,
graph_dir,
legend_title="RWND clamp (KB)",
prefix=f"staticRwnd_{dur_ms}ms_{flows}flows",
suffix="incast_queue",
ncols=2 if dur_ms == 2 else 3,
)
# for flowS in FLOWSS:
# print(flowS)
# graph_sender_inflight(
# {
# exp: data
# for exp, data in exp_to_data.items()
# if data["config"]["numBurstSenders"] == flowS
# },
# SWEEP_DIR,
# 2048
# )
# %%
def load_duration(sweep_dir, dur_ms, reload):
save_flp = path.join(sweep_dir, f"{dur_ms}.pickle")
if reload or not path.exists(save_flp):
exp_to_data = load_all(
sweep_dir,
filt=lambda c: (
f"{dur_ms}ms" in c["outputDirectory"]
# and c["numBurstSenders"] <= 1000
# and c["numBurstSenders"] < 1000
# and c["smallLinkBandwidthMbps"] == 10000
# and c["smallQueueMinThresholdPackets"] == 65
# and c["smallQueueSizePackets"] == 667
# and c["smallQueueSizePackets"] == 1334
# and c["rwndStrategy"] in ["none", "static"]
# and c["numBurstSenders"] in FLOWSS
),
)
print("Saving:", save_flp)
with open(save_flp, "wb") as fil:
pickle.dump(exp_to_data, fil)
print("Saved.")
else:
print("Loading:", save_flp)
with open(save_flp, "rb") as fil:
exp_to_data = pickle.load(fil)
print("Loaded.")
return exp_to_data
# %%
SWEEP_DIR = "/data_ssd/ccanel/data/imc2024/sweep/background-senders"
GRAPH_DIR = path.join(SWEEP_DIR, "graphs")
if not path.isdir(GRAPH_DIR):
os.makedirs(GRAPH_DIR)
# %%
EXP_TO_DATA_2MS = load_duration(SWEEP_DIR, 2, False)
generate_graphs_for_duration(EXP_TO_DATA_2MS, 2, GRAPH_DIR)
# %%
EXP_TO_DATA_15MS = load_duration(SWEEP_DIR, 15, False)
generate_graphs_for_duration(EXP_TO_DATA_15MS, 15, GRAPH_DIR)
# %%
# delack_sweep_dir = "/data_hdd/incast/out/delack_sweep_2ms"
# delack_sweep_exp_to_data = load_sweep(delack_sweep_dir)
# def graph_delack_sweep(exp_to_data, sweep_dir):
# def get_x(data):
# return data["config"]["delAckCount"]
# def get_y(data):
# return np.mean([end - start for start, end in data["burst_times"][1:]])
# points = [(get_x(data), get_y(data)) for exp, data in exp_to_data.items()]
# points = sorted(points)
# xs, ys = zip(*points)
# ys = [y * 1e3 for y in ys]
# fig, axes = analysis.get_axes(width=5)
# ax = ax
# ax.plot(xs, ys, "o-", alpha=0.7)
# ax.set_title(f"Average burst duration vs. DelAckCount")
# ax.set_xlabel("DelAckCount")
# ax.set_ylabel("Burst duration (ms)")
# ax.set_xlim(left=0)
# ax.set_ylim(bottom=0)
# plt.tight_layout()
# analysis.show(fig)
# analysis.save(graph_dir, suffix="duration")
# def graph_delack_sweep_cdf(exp_to_data, sweep_dir):