-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreport
executable file
·890 lines (762 loc) · 26.4 KB
/
report
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
#!/usr/bin/python
import json
import sys
import re
import copy
import os
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
class colortext:
def __init__(self, text, color):
self.text = text
self.color = color
def __len__(self):
return len(self.text)
def __str__(self):
return BOLD + self.color + self.text + ENDC
def green(s):
return colortext(s, GREEN)
def red(s):
return colortext(s, RED)
def displayTag(t):
return t
def json_careful_loads(s):
try:
return json.loads(s)
except Exception as e:
sys.stderr.write("[ERR] Error while parsing json: {}\n".format(e))
sys.exit(1)
def json_careful_readlines(f):
return [ json_careful_loads(line.rstrip('\n')) for line in f ]
def safeInsert(dict, key, value):
if key not in dict:
dict[key] = value
else:
sys.stderr.write("[WARN] Key {} is already in use; trying _{} instead.\n".format(key))
safeInsert(dict, "_" + key, value)
def reCompile(exp):
return re.compile(exp, re.MULTILINE)
# def parseCommaInteger(s):
# return int(s.replace(",", ""))
# local reclaimed: 32859049984
# num local: 20999
# local gc time: 4541
# promo time: 8
def parseKiB(kibStr):
return float(int(kibStr)) * 1024.0 / 1000.0
def parseB(bytesStr):
return int(bytesStr) / 1000.0
statsPatterns = \
[ ("time", float, reCompile(r"^end-to-end\s+(\d+.\d+)s$"))
, ("space", parseKiB, reCompile(r"^\s*Maximum resident set size \(kbytes\): (\d+).*$"))
, ("num-local", int, reCompile(r"^num local: (\d+)$"))
, ("local-reclaimed", parseB, reCompile(r"^local reclaimed: (\d+)$"))
, ("local-time", int, reCompile(r"^local gc time: (\d+)$"))
, ("promo-time", int, reCompile(r"^promo time: (\d+)$"))
, ("root-reclaimed", parseB, reCompile(r"^root cc reclaimed: (\d+)$"))
, ("internal-reclaimed", parseB, reCompile(r"^internal cc reclaimed: (\d+)$"))
, ("num-root", int, reCompile(r"^num root cc: (\d+)$"))
, ("num-internal", int, reCompile(r"^num internal cc: (\d+)$"))
, ("root-time", int, reCompile(r"^root cc time: (\d+)$"))
, ("internal-time", int, reCompile(r"^internal cc time: (\d+)$"))
# , ("working-set", parseCommaInteger, reCompile(r"^max bytes live: (.*) bytes$"))
]
renameConfig = {
'mlton': 'mlton',
'mpl': 'mpl',
'mpl-cc': 'mpl-cc',
'mlton-working-set': 'mlton-working-set'
}
foundTags = set()
foundProcs = set()
def parseStats(row):
newRow = copy.deepcopy(row)
for (name, convert, pat) in statsPatterns:
m = pat.search(newRow['stdout'] + newRow['stderr'])
if m:
safeInsert(newRow, name, convert(m.group(1)))
newRow['procs'] = int(newRow.get('procs', '1'))
newRow['config'] = renameConfig[row['config']]
# try:
# newRow['space'] = float(newRow['space'])
# except KeyError:
# pass
# try:
# newRow['time'] = float(newRow['elapsed'])
# except KeyError:
# pass
foundTags.add(newRow['tag'])
foundProcs.add(newRow['procs'])
return newRow
def findTrials(data, config, tag, procs):
result = []
for row in data:
if (row['config'] == config and \
row['tag'] == tag and \
row['procs'] == procs):
result.append(row)
return result
def averageLocalGCTime(data, config, tags, procs):
tms = [ r['local-time'] for r in findTrials(data, config, tag, procs) if 'local-time' in r ]
try:
return float(sum(tms)) / len(tms) / 1000.0
except:
return None
def averagePromoTime(data, config, tags, procs):
tms = [ r['promo-time'] for r in findTrials(data, config, tag, procs) if 'promo-time' in r ]
try:
return float(sum(tms)) / len(tms) / 1000.0
except:
return None
def averageNumLocalGCs(data, config, tags, procs):
counts = [ r['num-local'] for r in findTrials(data, config, tag, procs) if 'num-local' in r ]
try:
return int(round(float(sum(counts)) / len(counts)))
except:
return None
def averageLocalReclaimed(data, config, tags, procs):
bs = [ r['local-reclaimed'] for r in findTrials(data, config, tag, procs) if 'local-reclaimed' in r ]
try:
return sum(bs) / len(bs)
except:
return None
# =====================================================================
# CC statistics
def averageRootReclaimed(data, config, tags, procs):
bs = [ r['root-reclaimed'] for r in findTrials(data, config, tag, procs) if 'root-reclaimed' in r ]
try:
return sum(bs) / len(bs)
except:
return None
def averageInternalReclaimed(data, config, tags, procs):
bs = [ r['internal-reclaimed'] for r in findTrials(data, config, tag, procs) if 'internal-reclaimed' in r ]
try:
return sum(bs) / len(bs)
except:
return None
def averageNumRootCCs(data, config, tags, procs):
bs = [ r['num-root'] for r in findTrials(data, config, tag, procs) if 'num-root' in r ]
try:
return int(round(float(sum(bs)) / len(bs)))
except:
return None
def averageNumInternalCCs(data, config, tags, procs):
bs = [ r['num-internal'] for r in findTrials(data, config, tag, procs) if 'num-internal' in r ]
try:
return int(round(float(sum(bs)) / len(bs)))
except:
return None
def averageTimeRootCC(data, config, tags, procs):
tms = [ r['root-time'] for r in findTrials(data, config, tag, procs) if 'root-time' in r ]
try:
return float(sum(tms)) / len(tms) / 1000.0
except:
return None
def averageTimeInternalCC(data, config, tags, procs):
tms = [ r['internal-time'] for r in findTrials(data, config, tag, procs) if 'internal-time' in r ]
try:
return float(sum(tms)) / len(tms) / 1000.0
except:
return None
# ======================================================================
def averageTime(data, config, tag, procs):
tms = [ r['time'] for r in findTrials(data, config, tag, procs) if 'time' in r ]
# cut out the max time to account for possible file IO slowdown
# (this should only happen the first time the file is loaded)
# if len(tms) > 1:
# maxt = max(tms)
# tms = [ t for t in tms if t != maxt ]
# take last ten runs
if len(tms) > 10:
tms = tms[-10:]
try:
return sum(tms) / len(tms)
except:
return None
def averageSpace(data, config, tag, procs):
sp = [ r['space'] for r in findTrials(data, config, tag, procs) if 'space' in r ]
if len(sp) > 10:
sp = sp[-10:]
try:
return sum(sp) / len(sp)
except:
return None
# def workingSetSize(data, tag):
# sp = [ r['working-set'] for r in findTrials(data, "mlton-working-set", tag, 1) if 'working-set' in r ]
# try:
# return sp[0] / 1000.0 # working-set is in bytes; divide by 1000 to get KB
# except:
# raise ValueError('Error processing working-set size of tag={}'.format(tag))
def tm(t):
if t is None:
return None
if t == 0.0:
return int(0)
# if t > 10.0:
# return int(round(t))
try:
# if t < 1.0:
# return round(t, 3)
if t < 10.0:
return round(t, 2)
elif t < 100.0:
return round(t, 1)
else:
return round(t)
except TypeError:
print ("[ERR] Got type error trying to round {}".format(repr(t)))
return None
def ov(x):
if x is None:
return None
return "{:.2f}".format(x)
def su(x):
if x is None:
return None
return str(int(round(x)))
def bu(x):
if x is None:
return None
return "{:.1f}".format(x)
def sp(kb):
if kb is None:
return None
num = kb
for unit in ['K','M','G']:
if num < 1000:
return "%3.1f %s" % (num, unit)
num = num / 1000
return "%3.1f %s" % (num, 'T')
# =========================================================================
delimWidth = 2
def makeline(row, widths, align):
bits = []
i = 0
while i < len(row):
j = i+1
while j < len(row) and (row[j] is None):
j += 1
availableWidth = sum(widths[i:j]) + delimWidth*(j-i-1)
s = str(row[i])
w = " " * (availableWidth - len(row[i]))
aa = align(i)
if aa == "l":
ln = s + w
elif aa == "r":
ln = w + s
elif aa == "c":
ln = w[:len(w)/2] + s + w[len(w)/2:]
else:
raise ValueError("invalid formatter: {}".format(aa))
bits.append(ln)
i = j
return (" " * delimWidth).join(bits)
def table(rows, align=None):
numCols = max(len(row) for row in rows if not isinstance(row, str))
widths = [0] * numCols
for row in rows:
# string rows are used for formatting
if isinstance(row, str):
continue
i = 0
while i < len(row):
j = i+1
while j < len(row) and (row[j] is None):
j += 1
# rw = len(stripANSI(str(row[i])))
# rw = len(str(row[i]))
rw = len(row[i])
for k in xrange(i, j):
w = (rw / (j-i)) + (1 if k < rw % (j-i) else 0)
widths[k] = max(widths[k], w)
i = j
totalWidth = sum(widths) + delimWidth*(numCols-1)
def aa(i):
try:
return align(i)
except:
return "l"
output = []
for row in rows:
if row == "-" or row == "=":
output.append(row * totalWidth)
continue
elif isinstance(row, str):
raise ValueError("bad row: {}".format(row))
output.append(makeline(row, widths, aa))
return "\n".join(output)
# =========================================================================
def mostRecentResultsFile(ws=False):
files = os.listdir("results")
pattern = r'\d{6}-\d{6}'
if ws:
pattern = r'ws-' + pattern
# A bit of a hack. Filenames are ...YYMMDD-hhmmss, so lexicographic string
# comparison is correct for finding the most recent (i.e. maximum) file
mostRecent = max(p for p in files if re.match(pattern, p))
return mostRecent
if len(sys.argv) > 1:
timingsFile = sys.argv[1]
else:
print("[INFO] no results file argument; finding most recent")
try:
mostRecent = mostRecentResultsFile()
except:
print("[ERR] could not find most recent results file\n " + \
" check that these are formatted as 'YYMMSS-hhmmss'")
sys.exit(1)
timingsFile = os.path.join('results', mostRecent)
if len(sys.argv) > 2:
workingSetFile = sys.argv[2]
else:
print("[INFO] no working-set file argument; finding most recent")
try:
mostRecent = mostRecentResultsFile(ws=True)
except:
print("[ERR] could not find most recent results/ws-* file\n " + \
" check that these are formatted as 'ws-YYMMSS-hhmmss'")
sys.exit(1)
workingSetFile = os.path.join('results', mostRecent)
print("[INFO] reading {}\n".format(timingsFile))
with open(timingsFile, 'r') as data:
resultsData = json_careful_readlines(data)
print("[INFO] reading {}\n".format(workingSetFile))
with open(workingSetFile, 'r') as data:
workingSetData = json_careful_readlines(data)
WS = [ parseStats(row) for row in workingSetData ]
D = [ parseStats(row) for row in resultsData ]
P = sorted(list(foundProcs))
maxp = max(foundProcs)
orderedTags = sorted(list(foundTags))
orderedTags = [ t for t in orderedTags if "ocaml-" not in t ]
orderedTags = [ t for t in orderedTags if t != "fib" and t != "nqueens" ]
def defaultAlign(i):
return "r" if i == 0 else "l"
headers = ['Benchmark', 'MLton', 'MPL(1)', 'MPL/CC(1)', 'MPL({})'.format(maxp), 'MPL/CC({})'.format(maxp)]
tt = [headers, "="]
for tag in orderedTags:
thisRow = [tag,
tm(averageTime(D, 'mlton', tag, 1)),
tm(averageTime(D, 'mpl', tag, 1)),
tm(averageTime(D, 'mpl-cc', tag, 1)),
tm(averageTime(D, 'mpl', tag, maxp)),
tm(averageTime(D, 'mpl-cc', tag, maxp))
]
thisRow = [thisRow[0]] + [str(x) if x is not None else "--" for x in thisRow[1:]]
tt.append(thisRow)
print("TIMINGS")
print(table(tt, defaultAlign))
print("")
headers = ['Benchmark', 'WS', 'MLton', 'MPL(1)', 'MPL/CC(1)', 'MPL({})'.format(maxp), 'MPL/CC({})'.format(maxp)]
tt = [headers, "="]
for tag in orderedTags:
thisRow = [tag,
sp(averageSpace(WS, 'mlton-working-set', tag, 1)),
sp(averageSpace(D, 'mlton', tag, 1)),
sp(averageSpace(D, 'mpl', tag, 1)),
sp(averageSpace(D, 'mpl-cc', tag, 1)),
sp(averageSpace(D, 'mpl', tag, maxp)),
sp(averageSpace(D, 'mpl-cc', tag, maxp))
]
thisRow = [ (x if x is not None else "--") for x in thisRow ]
tt.append(thisRow)
print("SPACE (MAX RESIDENCY)")
print(table(tt, defaultAlign))
print("")
h1 = ["", 'MPL(1) Local GC', None, None, None, 'MPL({}) Local GC'.format(maxp), None, None, None]
h2 = ['Benchmark'] + (['Promo', 'Collect', 'Count', 'Reclaim'] * 2)
tt = [h1, h2, "="]
for tag in orderedTags:
thisRow = [tm(averagePromoTime(D, 'mpl', tag, 1)),
tm(averageLocalGCTime(D, 'mpl', tag, 1)),
averageNumLocalGCs(D, 'mpl', tag, 1),
sp(averageLocalReclaimed(D, 'mpl', tag, 1)),
tm(averagePromoTime(D, 'mpl', tag, maxp)),
tm(averageLocalGCTime(D, 'mpl', tag, maxp)),
averageNumLocalGCs(D, 'mpl', tag, maxp),
sp(averageLocalReclaimed(D, 'mpl', tag, maxp))
]
thisRow = [tag] + [ str(x) if x is not None else None for x in thisRow ]
thisRow = [ (x if x is not None else "--") for x in thisRow ]
tt.append(thisRow)
print("MPL COLLECTION STATISTICS")
print("""\
+-------------------------------------------------------------------------+
| "Reclaim" is the number of bytes reclaimed by local collections, |
| including the impact of defragmentation. This is a cumulative measure |
| throughout execution, where each collection adds: |
| (page_size) * (num_pages_after - num_pages_before) |
+-------------------------------------------------------------------------+""")
print(table(tt, defaultAlign))
print("")
h1 = ["", 'MPL/CC(1) Local GC', None, None, None, 'MPL/CC({}) Local GC'.format(maxp), None, None, None]
h2 = ['Benchmark'] + (['Promo', 'Collect', 'Count', 'Reclaim'] * 2)
tt = [h1, h2, "="]
for tag in orderedTags:
thisRow = [tm(averagePromoTime(D, 'mpl-cc', tag, 1)),
tm(averageLocalGCTime(D, 'mpl-cc', tag, 1)),
averageNumLocalGCs(D, 'mpl-cc', tag, 1),
sp(averageLocalReclaimed(D, 'mpl-cc', tag, 1)),
tm(averagePromoTime(D, 'mpl-cc', tag, maxp)),
tm(averageLocalGCTime(D, 'mpl-cc', tag, maxp)),
averageNumLocalGCs(D, 'mpl-cc', tag, maxp),
sp(averageLocalReclaimed(D, 'mpl-cc', tag, maxp))
]
thisRow = [tag] + [ str(x) if x is not None else None for x in thisRow ]
thisRow = [ (x if x is not None else "--") for x in thisRow ]
tt.append(thisRow)
print("MPL/CC LOCAL COLLECTION STATISTICS")
print(table(tt, defaultAlign))
print("")
h1 = ["", 'MPL/CC(1) Concurrent GC', None, None, None, None, None, 'MPL/CC({}) Concurrent GC'.format(maxp), None, None, None, None, None]
h2 = ["", "Root", None, None, "Internal", None, None, "Root", None, None, "Internal", None, None]
h3 = ['Benchmark'] + (['T', '#', 'RC'] * 4)
tt = [h1, h2, h3, "="]
for tag in orderedTags:
thisRow = [ tm(averageTimeRootCC(D, 'mpl-cc', tag, 1)),
averageNumRootCCs(D, 'mpl-cc', tag, 1),
sp(averageRootReclaimed(D, 'mpl-cc', tag, 1)),
tm(averageTimeInternalCC(D, 'mpl-cc', tag, 1)),
averageNumInternalCCs(D, 'mpl-cc', tag, 1),
sp(averageInternalReclaimed(D, 'mpl-cc', tag, 1)),
tm(averageTimeRootCC(D, 'mpl-cc', tag, maxp)),
averageNumRootCCs(D, 'mpl-cc', tag, maxp),
sp(averageRootReclaimed(D, 'mpl-cc', tag, maxp)),
tm(averageTimeInternalCC(D, 'mpl-cc', tag, maxp)),
averageNumInternalCCs(D, 'mpl-cc', tag, maxp),
sp(averageInternalReclaimed(D, 'mpl-cc', tag, maxp))
]
thisRow = [tag] + [ str(x) if x is not None else None for x in thisRow ]
thisRow = [ (x if x is not None else "--") for x in thisRow ]
tt.append(thisRow)
print("MPL/CC CONCURRENT COLLECTION STATISTICS")
print(table(tt, defaultAlign))
print("")
headers = ['Benchmark', 'WS', 'MLton', 'MPL(1)', 'MPL/CC(1)', 'MPL({})'.format(maxp), 'MPL/CC({})'.format(maxp)]
tt = [headers, "="]
for tag in orderedTags:
thisRow = [tag,
sp(averageSpace(WS, 'mlton-working-set', tag, 1)),
sp(averageSpace(D, 'mlton', tag, 1)),
sp(averageSpace(D, 'mpl', tag, 1)),
sp(averageSpace(D, 'mpl-cc', tag, 1)),
sp(averageSpace(D, 'mpl', tag, maxp)),
sp(averageSpace(D, 'mpl-cc', tag, maxp))
]
thisRow = [ (x if x is not None else "--") for x in thisRow ]
tt.append(thisRow)
# percent difference (b-a)/|a|
def pcd(b, a):
try:
xx = 100.0 * (b-a) / abs(a)
result = ("+" if xx >= 0.0 else "") + ("{:.1f}%".format(xx))
if xx > 0.0:
return red(result)
else:
return result
except:
return None
def sd(x, y):
try:
return x / y
except:
return None
def ss(x, y):
try:
return x - y
except:
return None
def noLeadZero(x):
try:
if "0" == x[:1]:
return x[1:]
except:
pass
return x
header1 = ["", "Overhead", None, "Speedup({})".format(maxp), None, "Blowup(1)", None, "Blowup({})".format(maxp), None]
header2 = ['Benchmark',
'MPL',
'MPL/CC',
'MPL',
'MPL/CC',
'MPL',
'MPL/CC',
'MPL',
'MPL/CC']
tt = [header1, header2, "="]
for tag in orderedTags:
tMLton = tm(averageTime(D, 'mlton', tag, 1))
tMPL1 = tm(averageTime(D, 'mpl', tag, 1))
tMPLp = tm(averageTime(D, 'mpl', tag, maxp))
tMPLcc1 = tm(averageTime(D, 'mpl-cc', tag, 1))
tMPLccp = tm(averageTime(D, 'mpl-cc', tag, maxp))
rMLton = averageSpace(D, 'mlton', tag, 1)
rMPL1 = averageSpace(D, 'mpl', tag, 1)
rMPLp = averageSpace(D, 'mpl', tag, maxp)
rMPLcc1 = averageSpace(D, 'mpl-cc', tag, 1)
rMPLccp = averageSpace(D, 'mpl-cc', tag, maxp)
overhead = tm(sd(tMPL1, tMLton))
overheadcc = tm(sd(tMPLcc1, tMLton))
speedup = tm(sd(tMLton, tMPLp))
speedupcc = tm(sd(tMLton, tMPLccp))
blowup1 = tm(sd(rMPL1, rMLton))
blowupcc1 = tm(sd(rMPLcc1, rMLton))
blowupp = tm(sd(rMPLp, rMLton))
blowupccp = tm(sd(rMPLccp, rMLton))
row = [tag, overhead, overheadcc, speedup, speedupcc, blowup1, blowupcc1, blowupp, blowupccp]
row = [row[0]] + map(lambda x: "{:.1f}".format(x) if x is not None else "--", row[1:])
tt.append(row)
print("COMPARISON WITH MLTON")
print("Blowup(p) = (MPL(p) space) / (MLton space)")
print(table(tt, defaultAlign))
print("")
header = ["Benchmark", "Time(1)", "Time({})".format(maxp), "Space(1)", "Space({})".format(maxp)]
tt = [header, "="]
for tag in orderedTags:
# tMLton = tm(averageTime(D, 'mlton', tag, 1))
tMPL1 = tm(averageTime(D, 'mpl', tag, 1))
tMPLp = tm(averageTime(D, 'mpl', tag, maxp))
tMPLcc1 = tm(averageTime(D, 'mpl-cc', tag, 1))
tMPLccp = tm(averageTime(D, 'mpl-cc', tag, maxp))
# rMLton = averageSpace(D, 'mlton', tag, 1)
rMPL1 = averageSpace(D, 'mpl', tag, 1)
rMPLp = averageSpace(D, 'mpl', tag, maxp)
rMPLcc1 = averageSpace(D, 'mpl-cc', tag, 1)
rMPLccp = averageSpace(D, 'mpl-cc', tag, maxp)
t1 = pcd(tMPLcc1, tMPL1)
tp = pcd(tMPLccp, tMPLp)
r1 = pcd(rMPLcc1, rMPL1)
rp = pcd(rMPLccp, rMPLp)
row = [tag, t1, tp, r1, rp]
row = [x if x is not None else "--" for x in row]
tt.append(row)
print("MPL/CC versus MPL")
print(table(tt, defaultAlign))
print("")
print("[INFO] done reporting {} and {}".format(timingsFile, workingSetFile))
# ============================================================================
# def highlight(s):
# return "\\underline{\\bf" + s + "}"
def makeBold(s):
return "{\\bf" + s + "}"
def pcd(b, a):
try:
xx = int(round(100.0 * (b-a) / abs(a)))
return xx
except:
return None
def latexpcd(b, a, highlight=True):
try:
xx = pcd(b, a)
result = ("+" if xx >= 0.0 else "") + ("{}\\%".format(xx))
if highlight and (xx < 0):
return makeBold(result)
else:
return result
except Exception as e:
sys.stderr.write("[WARN] " + str(e) + "\n")
return "--"
pcdResultsFile = "figures/pcd-table.tex"
with open(pcdResultsFile, 'w') as output:
allP = [1,10,20,30,40,50,60,70]
for tag in orderedTags:
row = []
for p in allP:
mpl = tm(averageTime(D, 'mpl', tag, p))
mplcc = tm(averageTime(D, 'mpl-cc', tag, p))
rmpl = averageSpace(D, 'mpl', tag, p)
rmplcc = averageSpace(D, 'mpl-cc', tag, p)
tpcd = latexpcd(mplcc, mpl)
rpcd = latexpcd(rmplcc, rmpl)
row.append("")
row.append(tpcd)
row.append(rpcd)
output.write(tag + " & ".join(row))
output.write(" \\\\\n")
print("[INFO] wrote to {}".format(pcdResultsFile))
# ============================================================================
def fmt(xx):
if xx is None:
return "--"
elif type(xx) is str:
return xx
# elif xx < 1.0:
# return noLeadZero("{:.3f}".format(xx))
elif xx < 10.0:
return "{:.2f}".format(xx)
elif xx < 100.0:
return "{:.1f}".format(xx)
else:
return str(int(round(xx)))
pcdsT1 = []
pcdsTp = []
overheads = []
overheadsNoPrimes = []
speedups = []
timeTableResults = "figures/all-time-table.tex"
with open(timeTableResults, 'w') as output:
for tag in orderedTags:
mlton = tm(averageTime(D, 'mlton', tag, 1))
mpl1 = tm(averageTime(D, 'mpl', tag, 1))
mplp = tm(averageTime(D, 'mpl', tag, maxp))
mplcc1 = tm(averageTime(D, 'mpl-cc', tag, 1))
mplccp = tm(averageTime(D, 'mpl-cc', tag, maxp))
pcdsT1.append(pcd(mplcc1, mpl1))
pcdsTp.append(pcd(mplccp, mplp))
overheads.append(sd(mplcc1, mlton))
speedups.append(sd(mlton, mplccp))
if tag != "primes":
overheadsNoPrimes.append(sd(mplcc1, mlton))
row = \
[ mlton
, mpl1
, fmt(mplcc1) + " (" + latexpcd(mplcc1, mpl1, highlight=False) + ")"
, ov(sd(mpl1, mlton))
, ov(sd(mplcc1, mlton))
, mplp
, fmt(mplccp) + " (" + latexpcd(mplccp, mplp, highlight=False) + ")"
, su(sd(mlton, mplp))
, su(sd(mlton, mplccp))
]
# row = \
# [ mlton
# , mpl1
# , tm(sd(mpl1, mlton))
# , mplp
# , tm(sd(mlton, mplp))
# , mplcc1
# , tm(sd(mplcc1, mlton))
# , mplccp
# , tm(sd(mlton, mplccp))
# ]
row = [ fmt(x) for x in row ]
output.write(" & ".join([tag] + row))
output.write(" \\\\\n")
print("[INFO] wrote to {}".format(timeTableResults))
pcdsT1 = [x for x in pcdsT1 if x is not None]
pcdsTp = [x for x in pcdsTp if x is not None]
overheads = [x for x in overheads if x is not None]
overheadsNoPrimes = [x for x in overheadsNoPrimes if x is not None]
speedups = [x for x in speedups if x is not None]
print("AVERAGE TIME PCD 1: {}".format(int(sum(pcdsT1) / len(pcdsT1))))
print("AVERAGE TIME PCD {}: {}".format(maxp, int(sum(pcdsTp) / len(pcdsTp))))
print("AVERAGE OVERHEADS: {}".format(sum(overheads) / len(overheads)))
print("AVERAGE OVERHEADS (no primes): {}".format(sum(overheadsNoPrimes) / len(overheadsNoPrimes)))
print("AVERAGE SPEEDUPS: {}".format(sum(speedups) / len(speedups)))
# ============================================================================
# ============================================================================
def sfmt(xx):
if xx is None:
return "--"
elif type(xx) is str:
return xx
elif xx < 0.01:
return noLeadZero("{:.4f}".format(xx))
elif xx < 0.1:
return noLeadZero("{:.3f}".format(xx))
elif xx < 1.0:
return "{:.2f}".format(xx)
elif xx < 10.0:
return "{:.1f}".format(xx)
else:
return str(int(round(xx)))
def spg(kb):
try:
gb = kb / (1000.0 * 1000.0)
if gb < .01:
return round(gb, 4)
elif gb < .1:
return round(gb, 3)
elif gb < 1.0:
return round(gb, 2)
elif gb < 10.0:
return round(gb, 1)
else:
return round(gb, 0)
except:
return None
pcdsR1 = []
pcdsRp = []
spaceTableResults = "figures/all-space-table.tex"
with open(spaceTableResults, 'w') as output:
for tag in orderedTags:
ws = spg(averageSpace(WS, 'mlton-working-set', tag, 1))
mlton = spg(averageSpace(D, 'mlton', tag, 1))
mpl1 = spg(averageSpace(D, 'mpl', tag, 1))
mplp = spg(averageSpace(D, 'mpl', tag, maxp))
mplcc1 = spg(averageSpace(D, 'mpl-cc', tag, 1))
mplccp = spg(averageSpace(D, 'mpl-cc', tag, maxp))
pcdsR1.append(pcd(mplcc1, mpl1))
pcdsRp.append(pcd(mplccp, mplp))
row = \
[ mlton
, mpl1
, sfmt(mplcc1) + " (" + latexpcd(mplcc1, mpl1, highlight=True) + ")"
, bu(sd(mpl1, mlton))
, bu(sd(mplcc1, mlton))
, mplp
, sfmt(mplccp) + " (" + latexpcd(mplccp, mplp, highlight=True) + ")"
, bu(sd(mplp, mlton))
, bu(sd(mplccp, mlton))
]
row = [ sfmt(x) for x in row ]
output.write(" & ".join([tag] + row))
output.write(" \\\\\n")
print("[INFO] wrote to {}".format(spaceTableResults))
pcdsR1 = [x for x in pcdsR1 if x is not None]
pcdsRp = [x for x in pcdsRp if x is not None]
print("AVERAGE SPACE PCD 1: {}".format(int(sum(pcdsR1) / len(pcdsR1))))
print("AVERAGE SPACE PCD {}: {}".format(maxp, int(sum(pcdsRp) / len(pcdsRp))))
# ============================================================================
speedupTags = [ t for t in orderedTags if "ocaml" not in t ]
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.figure(figsize=(7,7))
# markers = ['o','v','^','<','>','s','*','d','D','+','x','|','','','','','']
colors = ['blue', 'green', 'red', 'darkturquoise', 'black', 'darkviolet', 'goldenrod', 'dimgrey']
markers = ['o','v','^','<','>','s','d','D']
linestyles = ['solid', 'dashed']
# markers = ['.'] * len(speedupTags)
procs = [1,10,20,30,40,50,60,70]
fontSize = 12
legendFontSize = 11
markerSize = 7
plt.plot(procs, procs, marker="", color="grey", linewidth=0.5)
lines = []
for (i, tag) in enumerate(speedupTags):
baseline = averageTime(D, 'mlton', tag, 1)
speedups = map(lambda p: baseline / averageTime(D, 'mpl-cc', tag, p), procs)
color = colors[i % len(colors)]
marker = markers[i % len(markers)]
linestyle = linestyles[i / len(markers)]
lines.append(plt.plot(procs, speedups, linestyle=linestyle, marker=marker, markersize=markerSize, linewidth=1, color=color))
# this sets the legend.
font = {
'size': legendFontSize,
#'family' : 'normal',
#'weight' : 'bold',
}
matplotlib.rc('font', **font)
# make sure to use truetype fonts
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
# set legend position
matplotlib.rcParams['legend.loc'] = 'upper left'
plt.xlabel('Processors', fontsize=fontSize)
plt.ylabel('Speedup', fontsize=fontSize)
plt.yticks(procs, fontsize=fontSize)
plt.xticks(procs, fontsize=fontSize)
plt.gca().grid(axis='both', linestyle='dotted')
plt.gca().set_axisbelow(True)
# plt.margins(y=10)
plt.legend([b[0] for b in lines], speedupTags)
outputName = 'figures/mpl-cc-speedups.pdf'
plt.savefig(outputName, bbox_inches='tight')
sys.stdout.write("[INFO] output written to {}\n".format(outputName))