This repository has been archived by the owner on Oct 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
slimyet.js
2225 lines (2026 loc) · 72.4 KB
/
slimyet.js
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
/* -*- fill-column: 80; js-indent-level: 2; -*- */
/*
* Copyright © 2012 Mozilla Corporation
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
// Vars from query or hash in form #key[:val],...
var gQueryVars = (function () {
var ret = {};
function expand(target, outer, inner) {
var vars = target.split(outer);
for (var x in vars) {
x = vars[x].split(inner);
ret[decodeURIComponent(x[0]).toLowerCase()] = x.length > 1 ? decodeURIComponent(x[1]) : true;
}
}
if (document.location.search)
expand(document.location.search.slice(1), '&', '=')
if (document.location.hash)
expand(document.location.hash.slice(1), ',', ':')
return ret;
})();
// /mobile/ is an alias for ?mobile
(function () {
if (document.location.pathname.indexOf('/mobile') == 0)
gQueryVars['mobile'] = true;
// Set proper link to inactive
var inactive = gQueryVars['mobile'] ? '/mobile/' : '/';
$(function () {
inactive = $("#navbar a[href='"+inactive+"']");
inactive.replaceWith($('<span>').addClass('inactive').text(inactive.text()));
});
})();
/*
* Annotations to draw on the graph. Format:
* {
* // Anything Date.parse recognizes *or* numeric unix timestamp
* 'date': "Feb 1 2012 GMT",
* // HTML content of tooltip message
* 'msg': '
* We fixed something to do with images sometime before \
* <a href="https://hg.mozilla.org/integration/mozilla-inbound/rev/3fdc1c14a8ce">3fdc1c14a8ce</a> \
* <p style="color:grey">This is grey text</p> \
* <p class="small">yay</p> \
* ',
* // Optional, disable on desktop or mobile:
* 'desktop': false,
* 'mobile': false,
* // Show only on some graphs (default all):
* 'whitelist': [ "Explicit Memory", "Resident Memory" ]
* }
*/
var gAnnotations = (function() {
function annoFormat(msg, bugnum) {
if (bugnum)
msg += "<br><small>bug " + bugnum + "</small>";
// Twelve digit lowercase hex -> rev link
msg = msg.replace(/(\b)([a-f0-9]{12})(\b)/g,
'$1<a href="https://hg.mozilla.org/integration/mozilla-inbound/rev/$2">' +
'$2</a>$3');
// Bug 12345 -> Bug link
msg = msg.replace(/[bB]ug ([0-9]+)/g,
'<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=$1">' +
'$&</a>');
return msg;
}
var annotations = [
{
'date': 1364362111,
'mobile': false,
'msg': annoFormat('Decommitted memory is now excluded from explicit',
831588),
// No effect on resident
'whitelist': [ "Explicit Memory", "Miscellaneous Measurements" ]
},
{
'date': 'Thu May 30 18:33:47 2013 -0700',
'msg': annoFormat('Images layerization change caused ~40MB regression',
867770),
},
{
'date': 'Mon Jun 03 07:57:31 2013 -0700',
'msg': annoFormat('Image layerization regression fixed', 878062),
},
{
'date': 'Mon Jul 29 17:08:01 2013 GMT',
'msg': annoFormat('Added heap overhead to explicit; this increased ' +
'explicit without increasing our memory usage.', 898558)
},
// *************************** Desktop Annotations ***************************
{
'date': 1363993909,
'mobile': false,
'msg': annoFormat('Multithreaded image decoding leak fixed', 853390)
},
{
'date': 1363788676,
'mobile': false,
'msg': annoFormat('Multithreaded image decoding caused us ' +
'to leak some documents', 716140)
},
{
'date': 'Jan 28 2013 GMT',
'mobile': false,
'msg': annoFormat('15-20 MiB regression in the after-test lines, ' +
'likely caused by bug 820602.', 842756)
},
{
'date': 'Fri, 07 Dec 2012 GMT',
'mobile': false,
'msg': annoFormat('New HTMLElement bindings caused ~20MB regression ' +
'in peak memory consumption', 833518)
},
{
'date': 'Tue, 18 Dec 2012 04:34:31 GMT',
'mobile': false,
'msg': annoFormat('~40MB regression (~11%) due to leaked windows', 820602)
},
{
'date': 1395887394,
'mobile': false,
'msg': annoFormat('Generational GC enabled on desktop', 619558)
},
// *************************** Mobile Annotations ****************************
{
'date': 1357139813,
'desktop': false,
'msg': annoFormat('Updated android NDK from r5c to r8c.', 828650)
},
{
'date': 1357743011,
'desktop': false,
'msg': annoFormat('Some crypto stuff is now being loaded on startup.',
824023)
},
{
'date': 1358920410,
'desktop': false,
'msg': annoFormat('Some graphics code is loaded earlier, moving the ' +
'Start memory usage up but leaving StartSettled as-is.',
828126)
},
{
'date': 1358593871,
'desktop': false,
'msg': annoFormat('Regression from adding new fonts. Tradeoff ' +
'accepted for increased readability. Some of this ' +
'was later reduced in bug 844669.', 831354)
},
{
'date': 1359474609,
'desktop': false,
'msg': annoFormat('Regression from OS.File debug code, backed out in ' +
'8728de36d4a8.', 828201)
},
{
'date': 1361788819,
'desktop': false,
'msg': annoFormat('Regression from graphite font shaping, tracked in ' +
'bug 846832 and corrected in 6a0bcaa622f0.', 700023)
},
{
'date': 1361831517,
'desktop': false,
'msg': annoFormat('Giant drop-spike is a result of the low-memory ' +
'<a href="https://staktrace.com/spout/entry.php?id=782">'+
'tab zombification</a> behaviour.')
},
{
'date': 1361917561,
'desktop': false,
'msg': annoFormat('Giant drop-spike is a result of the low-memory ' +
'<a href="https://staktrace.com/spout/entry.php?id=782">'+
'tab zombification</a> behaviour.')
},
{
'date': 1361918975,
'desktop': false,
'msg': annoFormat('Switched device running the test to a Galaxy Nexus; ' +
'baseline values expected to change.')
},
{
'date': 1362421422,
'desktop': false,
'msg': annoFormat('Improvement from turning off graphite in fonts.', 846832)
},
{
'date': 1362416958,
'desktop': false,
'msg': annoFormat('Improvement from analysis of font-related memory usage.',
844669)
},
{
'date': 1363491479,
'desktop': false,
'msg': annoFormat('Improvement from zones landing', 759585)
},
{
'date': 1364566105,
'desktop': false,
'msg': annoFormat('Regression from Push service landing. Tracked in bug ' +
'857135 and corrected in fc8267682725.', 822712)
},
{
'date': 1364841472,
'desktop': false,
'msg': annoFormat('Regression being tracked in bug 862390.')
},
{
'date': 1365454665,
'desktop': false,
'msg': annoFormat('Improvement from removing push-related components from ' +
'Android build.', 857135)
},
{
'date': 1364908990,
'desktop': false,
'msg': annoFormat('Small regression from turning on IonMonkey for ARMv6 ' +
'Android builds.', 855839)
},
{
'date': 1365004235,
'desktop': false,
'msg': annoFormat('Small regression (resident-only) from baseline compiler ' +
'landing and making libxul bigger.')
},
{
'date': 1366048480,
'desktop': false,
'msg': annoFormat('Regression being tracked in bug 862403.')
},
{
'date': 1369031534,
'desktop': false,
'msg': annoFormat('On-demand decompression causes us to double-count things. ' +
'The regression here is not actually a regression.', 848764)
},
{
'date': 1369763440,
'desktop': false,
'msg': annoFormat('Enabling 24-bit colour on Android causes a memory regression. ' +
'It was backed out in 495b385ae811 for test failures.', 803299)
},
{
'date': 1369838059,
'desktop': false,
'msg': annoFormat('Enabling 24-bit colour on Android causes a memory regression. ' +
'It was backed out in 281dc9793a73 for Tch and Tpan regressions.', 803299)
},
{
'date': 1372195899,
'desktop': false,
'msg': annoFormat('Fonts are now loaded directly from the omnijar and decompressed ' +
'in memory. This has an acceptable non-startup memory regression.', 878674)
},
{
'date': 1373588395,
'desktop': false,
'msg': annoFormat('Elfhack enabled, memory gained.', 892355)
},
{
'date': 1374146101,
'desktop': false,
'msg': annoFormat('Elfhack disabled, memory lost.', 894885)
},
{
'date': 1374669205,
'desktop': false,
'msg': annoFormat('Elfhack re-enabled, memory re-gained.', 894885)
},
{
'date': 1374806525,
'desktop': false,
'msg': annoFormat('Static initializers added in bug 894448, fixed in bug 899368', 899134)
},
{
'date': 1375117971,
'desktop': false,
'msg': annoFormat('Increase in GC heap memory, marked WONTFIX', 899584)
},
{
'date': 1375142305,
'desktop': false,
'msg': annoFormat('Static initializer fixup', 899368)
},
{
'date': 1376300292,
'desktop': false,
'msg': annoFormat('Addon manager change', 906747)
},
{
'date': 1377312199,
'desktop': false,
'msg': annoFormat('More static constructors added', 909338)
},
{
'date': 1377545370,
'desktop': false,
'msg': annoFormat('Static constructors removed', 909328)
},
{
'date': 1377877508,
'desktop': false,
'msg': annoFormat('Updated Fennec profile used in AWSY harness')
},
{
'date': 1391544327,
'desktop': false,
'msg': annoFormat('Bug 625383 caused AWSY runs to frequently hit timeout and fail', 971001)
},
{
'date': 1392122504,
'desktop': false,
'msg': annoFormat('Updated Fennec profile used in AWSY harness')
},
{
'date': 1392153656,
'desktop': false,
'msg': annoFormat('Backed out bug 625383', 971001)
},
{
'date': 1394684478,
'desktop': false,
'msg': annoFormat('Bug 979101 caused devtools to load on startup', 983129)
},
{
'date': 1394765950,
'desktop': false,
'msg': annoFormat('Backed out bug 979101', 983129)
},
{
'date': 1397539462,
'desktop': false,
'msg': annoFormat('Fix incorrect memory report for images', 995880)
},
{
'date': 1400197141,
'desktop': false,
'msg': annoFormat('New cache turned on', 1013333)
},
{
'date': 1400602677,
'desktop': false,
'msg': annoFormat('Update Fennec profile used in AWSY harness')
},
{
'date': 1411541780,
'msg': annoFormat('45MB memory regression from suggestions for ReferenceError', 947044)
},
{
'date': 1411669939,
'msg': annoFormat('Bug 947044 backed out for regressions', 947044)
},
{
'date': 1412132897,
'msg': annoFormat('Resource timing was causing leaks', 1002855)
},
{
'date': 1413895805,
'msg': annoFormat('Resource timing leak fixed', 1064706)
},
{
'date': 1415326632,
'msg': annoFormat('imgStatusTracker simplification caused BF cache to retain pages for longer', 1084136)
},
{
'date': 1418534275,
'msg': annoFormat('Doing more compartmental GCs breaks decommitting of arenas', 1052793)
},
{
'date': 1420739696,
'msg': annoFormat('Backed out bug 1052793 to fix regression', 1052793)
},
{
'date': 1421897779,
'msg': annoFormat('Workaround for bug 1084136 landed on central', 1084136)
},
{
'date': 'Wed Feb 11 22:09:25 2015 GMT',
'msg': 'Switching AWSY to marionette reenabled bfcache, this caused memory usage to go up.'
}
// The 'date' timestamps in the list above can be obtained from the page at
// http://hg.mozilla.org/integration/mozilla-inbound/json-pushes?changeset=<cset>
// where <cset> is the appropriate inbound change.
];
// Turn dates into date objects, sort by date
for (var i = 0; i < annotations.length; i++) {
var anno = annotations[i];
var date = new Date(typeof(anno['date']) == "number"
? anno['date'] * 1000
: anno['date']);
anno['date'] = date;
}
annotations.sort(function(a, b) {
a = a['date'].getTime();
b = b['date'].getTime();
return (a < b) ? -1 : (a == b) ? 0 : 1;
});
return annotations;
})();
// Width in pixels of highlight (zoom) selector
var gHighlightWidth = gQueryVars['zoomwidth'] ? +gQueryVars['zoomwidth'] : 400;
// Offset between tooltip and cursor
var gTooltipOffset = 'tooltipoffset' in gQueryVars ? +gQueryVars['tooltipoffset'] : 10;
// Coalesce datapoints to keep them under this many per zoom level.
// Default to 150, or 0 (disabled) if nocondense is supplied
var gMaxPoints = gQueryVars['maxpoints'] ? +gQueryVars['maxpoints'] : (gQueryVars['nocondense'] ? 0 : 150);
// How much time between successfully tested builds on the graph should result
// in a disjointed line. Default 24h
var gDisjointTime = 'disjointtime' in gQueryVars ? +gQueryVars['disjointtime'] : (60 * 60 * 24);
// Merge tooltips if their position is within this many pixels
var gAnnoMergeDist = 'annotationmerge' in gQueryVars ? +gQueryVars['annotationmerge'] : 50;
// How many xaxis ticks there should be, ticks will be averaged to this density
var gTickDensity = 'tickdensity' in gQueryVars ? +gQueryVars['tickdensity'] : 20;
// 10-class paired qualitative color scheme from http://colorbrewer2.org/.
// Ordered so that the important memory lines are given more prominent colors.
var gDefaultColors = [
"#A6CEE3", /* light blue */
"#B2DF8A", /* light green */
"#FB9A99", /* light red */
"#FDBF6F", /* light orange */
"#33A02C", /* dark green */
"#1F78B4", /* dark blue */
"#E31A1C", /* dark red */
"#6A3D9A", /* dark purple */
"#FF7F00", /* dark orange */
"#CAB2D6", /* light purple */
];
var gDarkColorsFirst = [
"#1F78B4", /* dark blue */
"#33A02C", /* dark green */
"#E31A1C", /* dark red */
"#6A3D9A", /* dark purple */
"#FF7F00", /* dark orange */
"#A6CEE3", /* light blue */
"#B2DF8A", /* light green */
"#FB9A99", /* light red */
"#CAB2D6", /* light purple */
"#FDBF6F", /* light orange */
];
// Dates mozilla-central *branched* to form various release trees. Used to
// determine date placement on the X-axis of graphs
// See: https://wiki.mozilla.org/RapidRelease/Calendar
var gReleases = [
{dateStr: "2011-03-03", name: "Fx 4"},
{dateStr: "2011-04-12", name: "Fx 5"},
{dateStr: "2011-05-24", name: "Fx 6"},
{dateStr: "2011-07-05", name: "Fx 7"},
{dateStr: "2011-08-16", name: "Fx 8"},
{dateStr: "2011-09-27", name: "Fx 9"},
{dateStr: "2011-11-08", name: "Fx 10"},
{dateStr: "2011-12-20", name: "Fx 11"},
{dateStr: "2012-01-31", name: "Fx 12"},
{dateStr: "2012-03-13", name: "Fx 13"},
{dateStr: "2012-04-24", name: "Fx 14"},
{dateStr: "2012-06-05", name: "Fx 15"},
{dateStr: "2012-07-16", name: "Fx 16"},
{dateStr: "2012-08-27", name: "Fx 17"},
{dateStr: "2012-10-08", name: "Fx 18"},
{dateStr: "2012-11-19", name: "Fx 19"},
{dateStr: "2013-01-07", name: "Fx 20"},
{dateStr: "2013-02-18", name: "Fx 21"},
{dateStr: "2013-04-01", name: "Fx 22"},
{dateStr: "2013-05-13", name: "Fx 23"},
{dateStr: "2013-06-24", name: "Fx 24"},
{dateStr: "2013-08-05", name: "Fx 25"},
{dateStr: "2013-09-16", name: "Fx 26"},
{dateStr: "2013-10-28", name: "Fx 27"},
{dateStr: "2013-12-09", name: "Fx 28"},
{dateStr: "2014-02-03", name: "Fx 29"},
{dateStr: "2014-03-17", name: "Fx 30"},
{dateStr: "2014-04-28", name: "Fx 31"},
{dateStr: "2014-06-09", name: "Fx 32"},
{dateStr: "2014-07-21", name: "Fx 33"},
{dateStr: "2014-09-02", name: "Fx 34"},
{dateStr: "2014-10-13", name: "Fx 35"},
{dateStr: "2014-11-24", name: "Fx 36"},
{dateStr: "2015-01-12", name: "Fx 37"},
{dateStr: "2015-02-23", name: "Fx 38"},
{dateStr: "2015-04-06", name: "Fx 39"},
{dateStr: "2015-05-18", name: "Fx 40"},
{dateStr: "2015-06-29", name: "Fx 41"},
{dateStr: "2015-08-10", name: "Fx 42"}
];
// Create gReleases[x].date objects
(function() {
for (var i = 0; i < gReleases.length; i++) {
// Seconds from epoch.
gReleases[i].date = Date.parse(gReleases[i].dateStr) / 1000;
}
})();
// Lookup gReleases by date
var gReleaseLookup = function() {
var lookup = {};
for (var i = 0; i < gReleases.length; i++) {
lookup[gReleases[i].date] = gReleases[i].name;
}
return lookup;
}();
// Which series from series.json to graph where with what label. See
// /data/areweslimyet.json and comments below. These are exported from the full
// test database by create_graph_json.py
var gSeries = {
"Resident Memory" : {
'StartMemoryResidentV2': "RSS: Fresh start",
'StartMemoryResidentSettledV2': "RSS: Fresh start [+30s]",
'MaxMemoryResidentV2': "RSS: After TP5",
'MaxMemoryResidentSettledV2': "RSS: After TP5 [+30s]",
'MaxMemoryResidentForceGCV2': "RSS: After TP5 [+30s, forced GC]",
'EndMemoryResidentV2': "RSS: After TP5, tabs closed",
'EndMemoryResidentSettledV2': "RSS: After TP5, tabs closed [+30s]",
'EndMemoryResidentForceGCV2': "RSS: After TP5, tabs closed [+30s, forced GC]"
},
"Explicit Memory" : {
'StartMemoryV2': "Explicit: Fresh start",
'StartMemorySettledV2': "Explicit: Fresh start [+30s]",
'MaxMemoryV2': "Explicit: After TP5",
'MaxMemorySettledV2': "Explicit: After TP5 [+30s]",
'MaxMemoryForceGCV2': "Explicit: After TP5 [+30s, forced GC]",
'EndMemoryV2': "Explicit: After TP5, tabs closed",
'EndMemorySettledV2': "Explicit: After TP5, tabs closed [+30s]",
'EndMemoryForceGCV2': "Explicit: After TP5, tabs closed [+30s, forced GC]"
},
"Miscellaneous Measurements" : {
'MaxHeapUnclassifiedV2': "Heap Unclassified: After TP5 [+30s]",
'MaxJSV2': "JS: After TP5 [+30s]",
'MaxImagesV2': "Images: After TP5 [+30s]"
}
};
var gHgBaseUrl = 'https://hg.mozilla.org/integration/mozilla-inbound';
// Select android data. Use the same gSeries, but s/After TP5/After tabs/ and
// prepend 'Android' to series names.
if (gQueryVars['mobile']) {
for (var series in gSeries) {
for (var dp in gSeries[series]) {
gSeries[series]['Android'+dp] = gSeries[series][dp].replace("After TP5", "After tabs");
delete gSeries[series][dp];
}
}
}
// gGraphData pulls /data/<series>.json which has a *condensed* series of builds
// and associated data-lines. After a certain zoom level we need to pull in the
// full-resolution data into gFullData. gGraphData['allseries'] contains info on
// the sub-series that can be fetched for gFullData.
//
// The pre-condensed datapoints and ones we fetch ourselves all have
// min/median/max data, and the revision-range and time-range. See the
// /data/areweslimyet.json file.
//
// _getInvolvedSeries() - Determines if our zoom level justifies using
// full data series, lists them (none means 'just use gGraphData')
// Plot.SetZoomRange() - Changes the zoom level, if _getInvolvedSeries() advises
// use of series we don't have, fire off requests for them. Once those have
// completed, re-render the graph (graph will zoom in, then re-render with
// more points when they arrive)
//
// Plot._buildSeries() - Builds a series using the logic:
// - *if* we *dont* have gFullData for all ranges involved
// - Merge every N condensed-points in gGraphData OR
// - Show all condensed-points in gGraphData [slightly more zoomed]
// - *if* gFullData has the data for all series involved:
// - Merge those points outselves OR
// - Show every datapoint (all the way zoomed in)
var gGraphData;
var gFullData = {};
// 'per build data' is /data/<buildname>.json. <buildname> is usually a
// changeset id, but doesn't need to be (although the tooltip assumes they are)
// It primarily contains a dump of the about:memory reporters, and is only used
// for the data-dump you get when clicking on a tooltip. This is fetched/cached
// by getPerBuildData()
var gPerBuildData = {};
// List of *top-level* plots that should be zoom-sync'd
var gZoomSyncPlots = {};
// Range of all non-null datapoints.
var gDataRange;
// ObjectURLs that have been allocated and need to be cleared.
var gObjectURLs = [];
//
// Utility
//
// Shorthand for $(document.createElement(<e>))[.attr(<attrs>)[.css(<css>)]]
jQuery.new = function(e, attrs, css) {
var ret = jQuery(document.createElement(e));
if (attrs) ret.attr(attrs);
if (css) ret.css(css);
return ret;
};
// Log message/error to console if available
function logMsg(obj) {
if (window.console && window.console.log) {
window.console.log(obj);
}
}
function logError(obj) {
if (window.console) {
if (window.console.error)
window.console.error(obj)
else if (window.console.log)
window.console.log("ERROR: " + obj);
}
}
// Takes a second-resolution unix timestamp, prints a UTCDate. If the date
// is exactly midnight, remove the "00:00:00 GMT" (we have a lot of timestamps
// condensed to day-resolution)
function prettyDate(aTimestamp) {
// If the date is exactly midnight, remove the time portion.
// (overview data is coalesced by day by default)
return new Date(aTimestamp * 1000).toUTCString().replace('00:00:00 GMT', '');
}
function mkDelta(mem, lastmem) {
var delta = mem - lastmem;
var obj = $.new('span').addClass('delta');
if (delta < 0) {
obj.text('Δ -'+formatBytes(-delta));
obj.addClass('neg');
} else {
obj.text('Δ '+formatBytes(delta));
obj.addClass('pos');
}
if (Math.abs(delta) / mem > 0.02)
obj.addClass('significant');
return obj;
}
function mkHgLink(rev) {
return $.new('a', { 'class': 'buildlink', 'target': '_blank' })
.attr('href', gHgBaseUrl + "/rev/" + rev.slice(0,12))
.text(rev);
}
// float 12039123.439 -> String "12,039,123.44"
// (commas and round %.02)
function prettyFloat(aFloat) {
var ret = Math.round(aFloat * 100).toString();
if (ret == "0") return ret;
if (ret.length < 3)
ret = (ret.length < 2 ? "00" : "0") + ret;
var clen = (ret.length - 2) % 3;
ret = ret.slice(0, clen) + ret.slice(clen, -2).replace(/[0-9]{3}/g, ',$&') + '.' + ret.slice(-2);
return clen ? ret : ret.slice(1);
}
// Takes a int number of bytes, converts to appropriate units (B/KiB/MiB/GiB),
// returns a prettyFloat()'d string
// formatBytes(923044592344234) -> "859,652.27GiB"
function formatBytes(raw) {
if (raw / 1024 < 2) {
return prettyFloat(raw) + "B";
} else if (raw / Math.pow(1024, 2) < 2) {
return prettyFloat(raw / 1024) + "KiB";
} else if (raw / Math.pow(1024, 3) < 2) {
return prettyFloat(raw / Math.pow(1024, 2)) + "MiB";
} else {
return prettyFloat(raw / Math.pow(1024, 3)) + "GiB";
}
}
// Pass to progress on $.ajax to show the progress div for this request
function dlProgress() {
var xhr = $.ajaxSettings.xhr();
var url;
if (xhr) {
xhr._open = xhr.open;
xhr.open = function() {
if (arguments.length >= 2)
url = arguments[1];
return this._open.apply(this, arguments);
};
xhr.addEventListener("progress", function(e) {
// We can't use e.total because it is bogus for gzip'd data: Firefox sets
// loaded to the decompressed data but total to compressed, and chromium
// doesn't set total.
if (e.loaded) {
if (e.loaded == e.total) {
$('#dlProgress').empty();
} else {
$('#dlProgress').text("Downloading " + url + " - " +
formatBytes(e.loaded));
}
}
}, false);
}
return xhr;
}
// Round unix timestamp to the nearest midnight UTC. (Not *that day*'s midnight)
function roundDay(date) {
return Math.round(date / (24 * 60 * 60)) * 24 * 60 * 60;
}
// Round a date (seconds since epoch) up to the next day.
function roundDayUp(date) {
return Math.ceil(date / (24 * 60 * 60)) * 24 * 60 * 60;
}
// Round a date (seconds since epoch) down to the previous day.
function roundDayDown(date) {
return Math.floor(date / (24 * 60 * 60)) * 24 * 60 * 60;
}
// Get the full time range covered by two (possibly condensed) build_info structs
function getBuildTimeRange(firstbuild, lastbuild)
{
var range = [];
if ('timerange' in firstbuild && firstbuild['timerange'][0] < firstbuild['time'])
range.push(firstbuild['timerange'][0]);
else
range.push(firstbuild['time']);
if ('timerange' in lastbuild && lastbuild['timerange'][1] > lastbuild['time'])
range.push(lastbuild['timerange'][1]);
else
range.push(lastbuild['time']);
return range;
}
//
// For the about:memory-esque display
//
// Expand a tree node
function treeExpandNode(node, noanimate) {
if (!node.is('.hasChildren')) return;
var subtree = node.find('.subtree');
if (!subtree.length) {
var subtree = $.new('div').addClass('subtree').hide();
memoryTreeNode(subtree, node.data('nodeData'),
node.data('select'),
node.data('path'),
node.data('depth'));
subtree.appendTo(node);
}
if (noanimate)
subtree.show();
else
subtree.slideDown(250);
node.children('.treeNodeTitle').find('.treeExpandClicker').text('[-]');
}
// Collapse a tree node
function treeCollapseNode(node) {
node.children('.subtree').slideUp(250);
node.children('.treeNodeTitle').find('.treeExpandClicker').text('[+]');
}
// Collapse/Expand a tree node
function treeToggleNode(node) {
if (node.find('.subtree:visible').length)
treeCollapseNode(node);
else
treeExpandNode(node);
}
// Create a about:memory-esque tree of values from a list of nodes.
// The 'datapoint' value is the name of the point to highlight within the tree.
// This is a wrapper for memoryTreeNode()
function makeMemoryTree(title, path, nodes, datapoint) {
var memoryTree = $.new('div', { class: 'memoryTree' }, { display: 'none' });
// memoryTree title
var treeTitle = $.new('div', { class: 'treeTitle' }).appendTo(memoryTree);
$.new('h3').text(title)
.appendTo(treeTitle);
// datapoint subtitle
$.new('div').addClass('highlight')
.text(datapoint.replace(/\//g, ' -> '))
.appendTo(treeTitle);
memoryTreeNode(memoryTree, nodes, datapoint, path);
return memoryTree;
}
// Render a memory tree into <target>, with node data <data>. The node specified
// by <select> should be highlighted. <path> is an array of strings indicating
// path of this branch in the overall tree. <depth> represents how many levels
// deep this branch is in the overall tree.
function memoryTreeNode(target, data, select, path, depth) {
if (depth === undefined)
depth = 0;
// TODO Use 'mixed' units as an indicator of container nodes instead of hard
// coding.
var showVal = depth >= 2;
var showPct = depth >= 3;
// if select is passed as "a/b/c", split it so it is an array
if (typeof(select) == "string") {
select = select.split('/');
}
function defval(obj) {
if (typeof(obj) == 'number')
return obj
return obj['_val'] == undefined ? null : obj['_val'];
}
// Sort nodes
var rows = [];
for (var node in data) {
// Nodes starting with _ are not children (_val, _sum, _units)
if (node[0] == '_')
continue;
rows.push(node);
}
if (showVal) {
// Sort by memory size
rows.sort(function (a, b) {
var av = defval(data[a]) == null ? 0 : defval(data[a]);
var bv = defval(data[b]) == null ? 0 : defval(data[b]);
return bv - av;
});
} else {
// Sort reverse alphanumeric
rows = rows.sort(function (a, b) { return a == b ? 0 : a < b ? 1 : -1 });
}
// Add rows
var parentval = defval(data);
var node;
while (node = rows.shift()) {
path.push(node);
var leaf = true;
if (typeof(data[node]) != 'number') {
for (var key in data[node])
if (key[0] !== '_')
leaf = false
}
var treeNode = $.new('div')
.addClass('treeNode')
.data('nodeData', data[node])
.data('depth', depth + 1)
.data('path', path);
var nodeTitle = $.new('div')
.addClass('treeNodeTitle')
.appendTo(treeNode);
// Add value if inside a memNode
var val = defval(data[node]);
if (showVal && val != null) {
// Value
var prettyval;
if (data[node] instanceof Object && '_units' in data[node]) {
if (data[node]['_units'] == 'pct')
// 'percent' memory reporters are fixed point
prettyval = (val / 100).toFixed(2) + '%';
else if (data[node]['_units'] == 'cnt')
// 'count' memory reporters are unitless
prettyval = val
else
logError("unknown unit type " + data[node]['_units']);
} else {
// Default unit is bytes
prettyval = formatBytes(val);
}
$.new('span').addClass('treeValue')
.text(prettyval)
.appendTo(nodeTitle);
// Percentage of parent node
var pct = "("+prettyFloat(100* (val / parentval))+"%)";
if (showPct && parentval != null) {
$.new('span').addClass('treeValuePct')
.text(pct)
.appendTo(nodeTitle);
}
}
// Add label
var title = node;
var subtitle;
if (subtitle = /^(.+)\((.+)\)$/.exec(node)) {
title = subtitle[1];
subtitle = subtitle[2];
}
var label = $.new('span').addClass('treeNodeLabel')
.appendTo(nodeTitle).text(title);
if (subtitle) {
$.new('span').addClass('subtitle').text(' '+subtitle).appendTo(label);
}
// Add treeExpandClicker and click handler if node has children
var expandClick = $.new('span').addClass('treeExpandClicker');
nodeTitle.prepend(expandClick);
if (!leaf) {
expandClick.text('[+]');
nodeTitle.click(function () { treeToggleNode($(this).parent()); });
treeNode.addClass('hasChildren');
}
// Add an export element to each checkpoint.
if (depth == 1) {
var memoryReportName = path.join('_') + '_memory_report.gz';
var exportClick = $.new('a', { 'href': '#', 'class': 'button' })
.text(' [export]');
exportClick.data('checkpoint', data[node]);
exportClick.data('reportName', memoryReportName);
nodeTitle.append(exportClick);
exportClick.click(function() {
var worker = new Worker("/about_memory_worker.js");
$(this).text(' [exporting...]');
$(this).attr('href', null);
worker.onmessage = function(aEvent) {
var url = window.URL.createObjectURL(aEvent.data);
this.downloadLink.text(' [download]');
this.downloadLink.attr('href', url);
this.downloadLink.attr('download', this.downloadLink.data('reportName'));
this.downloadLink.unbind('click');
gObjectURLs.push(url);
}
worker.downloadLink = $(this);
worker.postMessage({
filename: memoryReportName,
checkpoint: $(this).data('checkpoint'),
});
return false;
});
}
// Handle selecting a start node
if (select && node == select[0]) {
if (select.length == 1) {
treeNode.addClass('highlight');
} else {
treeNode.data('select', select.splice(1));
}
treeExpandNode(treeNode, true);
}
path.pop();
target.append(treeNode);
}
}
// If this range is 'zoomed' enough to warrant using full-resolution data
// (based on gMaxPoints), return the list of gFullData series names that would
// be needed. Return false if overview data is sufficient for this range.
// It's up to the caller to call getFullSeries(name) to start downloading any
// of these that arn't downloaded.
function _getInvolvedSeries(range) {
var ret = [];
var groupdist = Math.round((range[1] - range[0]) / gMaxPoints);
// Unless the requested grouping distance is < 80% of the overview data's
// distance, don't pull in more
if (!gQueryVars['nocondense'] && isFinite(groupdist) &&
groupdist / gGraphData['condensed'] > 0.8)
return null;
for (var x in gGraphData['allseries']) {
var s = gGraphData['allseries'][x];
if (range[1] >= s['fromtime'] && range[0] <= s['totime'])
ret.push(s['dataname']);
}
return ret;
}
// Helper to call _getInvolvedSeries and call GetFullSeries on all results, with
// final callback.