Commits

Brian Burg committed ad3abf1

tweaks to include compartment and global GC

Comments (0)

Files changed (2)

addon/aboutgc.html

 <script type="text/javascript" src="aboutgc.js"></script>
 <script type="text/javascript" src="lib/jquery.min.js"></script>
 <script type="text/javascript" src="lib/jquery.flot.js" charset="utf-8"></script>
+<script type="text/javascript" src="lib/jquery.flot.selection.js" charset="utf-8"></script>
 <script>
 $(document).ready(function () {
 drawGraph();
 	probes.removeHandler(activeHandlers.pop());
     }
 
-    timer.clear();
+    timer.cancel();
     timer = null;
     probes = null;
 }
     probes.asyncQuery("pendingData = [];", function(e){});
     var cookie;
 
-    cookie = probes.addHandler(probes.GC_DID_START,
+    cookie = probes.addHandler(probes.COMPARTMENT_GC_DID_START,
 			       "using(env.currentTimeMS);" +
-			       "using(compartment.runtime.gcBytes);",
-			       "current = [env.currentTimeMS, 0, compartment.runtime.gcBytes, 0];");
+			       "using(runtime.gcBytes);",
+			       "current = {type: 'GC_COMPARTMENT', data: [env.currentTimeMS, 0, runtime.gcBytes, 0, ]};");
     activeHandlers.push(cookie);
 
-    cookie = probes.addHandler(probes.GC_WILL_END,
+    cookie = probes.addHandler(probes.GLOBAL_GC_DID_START,
 			       "using(env.currentTimeMS);" +
-			       "using(compartment.runtime.gcBytes);",
-			       "current[1] = env.currentTimeMS;" +
-			       "current[3] = compartment.runtime.gcBytes;" +
+			       "using(runtime.gcBytes);",
+			       "current = {type: 'GC_GLOBAL', data: [env.currentTimeMS, 0, runtime.gcBytes, 0, ]};");
+    activeHandlers.push(cookie);
+
+    cookie = probes.addHandler(probes.COMPARTMENT_GC_WILL_END,
+			       "using(env.currentTimeMS);" +
+			       "using(runtime.gcBytes);",
+			       "current.data[1] = env.currentTimeMS;" +
+			       "current.data[3] = runtime.gcBytes;" +
+			       "pendingData.push(current);");
+    activeHandlers.push(cookie);
+
+    cookie = probes.addHandler(probes.GLOBAL_GC_WILL_END,
+			       "using(env.currentTimeMS);" +
+			       "using(runtime.gcBytes);",
+			       "current.data[1] = env.currentTimeMS;" +
+			       "current.data[3] = runtime.gcBytes;" +
 			       "pendingData.push(current);");
     activeHandlers.push(cookie);
 
 
 	var heapSizeData = [];
 	var gcDurationMarks = [];
-	var startTime = dataArr[0][0];
+	var startTime = dataArr[0].data[0];
 
 	for each (origRec in dataArr) {
-	    [gcstart, gcend, heapstart, heapend] = origRec;
-	    gcstart -= startTime;
-	    gcend -= startTime;
 
-	    /* generate heap size over time */
-	    heapSizeData.push([gcstart, heapstart]);
-	    heapSizeData.push([gcend, heapend]);
+	    switch (origRec.type) {
+	    case "HEAP_RESIZE":
+		[time, oldSize, newSize] = origRec.data;
+		time -= startTime;
+		
+		heapSizeData.push([time, oldSize]);
+		heapSizeData.push([time, newSize]);
+		break;
 
-	    /* generate gc time markings */
-	    gcDurationMarks.push({ xaxis: { from: gcstart, to: gcstart }, color: '#dde' });
-	    gcDurationMarks.push({ xaxis: { from: gcstart, to: gcend }, color: '#eef' });
-	    gcDurationMarks.push({ xaxis: { from: gcend, to: gcend }, color: '#dde' });
+	    case "GC_COMPARTMENT":
+	    case "GC_GLOBAL":
+		[gcstart, gcend, heapstart, heapend] = origRec.data;
+		gcstart -= startTime;
+		gcend -= startTime;
+
+		/* generate heap size over time */
+		heapSizeData.push([gcstart, heapstart]);
+		heapSizeData.push([gcend, heapend]);
+		
+		/* generate gc time markings */
+		if (origRec.type == "GLOBAL")
+		    colors = { line: '#ded', fill: '#efe' };
+		else
+		    colors = { line: '#dde', fill: '#eef' };
+
+		gcDurationMarks.push({ xaxis: { from: gcstart, to: gcstart }, color: colors.line });
+		gcDurationMarks.push({ xaxis: { from: gcstart, to: gcend }, color: colors.fill });
+		gcDurationMarks.push({ xaxis: { from: gcend, to: gcend }, color: colors.line });
+		break;
+	    }
 	}
 
 	var options = { yaxes: [ { tickFormatter: format_bytes,
 	var durationSizeData = [];
 
 	for each (rec in dataArr) {
-	    /* generate scatter plot data of gc duration vs. reclaimed memory. */
-	    durationSizeData.push([rec[1]-rec[0], rec[2]-rec[3]]);
+	    data = rec.data;
+	    switch (rec.type) {
+	    case "GC_COMPARTMENT":
+	    case "GC_GLOBAL":
+		/* generate scatter plot data of gc duration vs. reclaimed memory. */
+		durationSizeData.push([data[1]-data[0], data[2]-data[3]]);
+		break;
+	    }
 	}
 
 	var options = { yaxes: [ { tickFormatter: format_bytes,
 	return [graphdata, options, postPlot];
     }
 
-    function preparePerfPlot(dataArr) {
-
-	var options = { yaxes: [ { 'min': 0,
-				   tickFormatter: format_ms,
-				   color: "olive",
-				 },
-				 { 'min': 0,
-				   position: 'right',
-				   tickFormatter: format_bytes,
-				   tickDecimals: 3,
-				   ticks: tick_maker(100 * 1024, 10),
-				   color: "blue",
-				 },
-                               ],
-			legend: { 'position': 'ne',
-				  'backgroundOpacity': 0.85,
-				  'backgroundColor': "yellow",
-				},
-			grid: {
-                            clickable: true,
-			},
-                      };
-	
-	var graphdata = [ { data: [ [ d[0], d[1] ] for each (d in dataArr) ],
-                            label: "GC Duration",
-                            clickable: true,
-                            color: "olive",
-			  },
-			  { data: [ [ d[0], d[2] ] for each (d in dataArr) ],
-                            label: "Memory Freed",
-                            bars: { show: true, barWidth: 500000 },
-                            clickable: true,
-                            yaxis: 2,
-                            color: "blue",
-			  }
-			];
-
-	return [graphdata, options];
-    }
-
     /* actually plot/draw now-- if data exists */
     if (!results.length) return;