summaryrefslogtreecommitdiff
path: root/tools/gc_activity.html
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2016-11-23 17:31:53 -0800
committerScott Shawcroft <scott.shawcroft@gmail.com>2016-11-23 17:31:53 -0800
commita8fbad5d8bfd6c0abca8a6759785c61d1f553b3f (patch)
tree15bbb65ac1626096e3f91e2ff0f0b116ddc76871 /tools/gc_activity.html
parentea1320bee7fbd0f895e8afe528e4b528489b2c5e (diff)
Add heap analysis scripts based on GDB breakpoint logs.
Diffstat (limited to 'tools/gc_activity.html')
-rw-r--r--tools/gc_activity.html137
1 files changed, 137 insertions, 0 deletions
diff --git a/tools/gc_activity.html b/tools/gc_activity.html
new file mode 100644
index 000000000..ec0ccbf88
--- /dev/null
+++ b/tools/gc_activity.html
@@ -0,0 +1,137 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <style>
+
+ html, body, svg {
+ margin: 0px;
+ min-height: 100%;
+ height: 100%;
+ width: 100%;
+ }
+
+ .chart rect {
+ fill: steelblue;
+ }
+
+ .axis text {
+ font: 10px sans-serif;
+ }
+
+ .axis path,
+ .axis line {
+ fill: none;
+ stroke: #000;
+ shape-rendering: crispEdges;
+ }
+
+ div.tooltip {
+ position: absolute;
+ # text-align: center;
+ # width: 60px;
+ # height: 28px;
+ padding: 2px;
+ font: 12px sans-serif;
+ background: lightsteelblue;
+ border: 0px;
+ }
+
+ </style>
+ </head>
+ <body>
+ <svg class="chart"></svg>
+ <script src="https://d3js.org/d3.v4.js"></script>
+ <script>
+ var barHeight = 2;
+
+ var chart = d3.select(".chart");
+
+ var margin = {top: 20, right: 30, bottom: 30, left: 40},
+ width = chart.style("width").replace("px", "") - margin.left - margin.right,
+ height = chart.style("height").replace("px", "") - margin.top - margin.bottom;
+
+ var x = d3.scaleLinear().range([0, width]);
+ var y = d3.scaleLinear().range([0, height]);
+
+ var chart = chart.append("g")
+ .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
+
+ var xAxis = d3.axisBottom().scale(x);
+ var yAxis = d3.axisLeft().scale(y);
+
+ var div = d3.select("body").append("div")
+ .attr("class", "tooltip")
+ .style("opacity", 0);
+
+ d3.json("/allocation_history.json", function(error, data) {
+ console.log(data[0]);
+ x.domain([0, d3.max(data, function(d) { return d.end_time; })]);
+ y.domain([0, d3.max(data, function(d) { return d.start_block + d.size; })]);
+
+ chart.append("g")
+ .attr("class", "x axis")
+ .attr("transform", "translate(0," + height + ")")
+ .call(xAxis);
+
+ chart.append("g")
+ .attr("class", "y axis")
+ .call(yAxis);
+
+ var bar = chart.selectAll("g")
+ .data(data)
+ .enter().append("g")
+ .attr("transform", function(d, i) { return "translate(" + x(d.start_time) + "," + y(d.start_block) + ")"; });
+
+ bar.append("rect")
+ .attr("width", function(d) { return x(d.end_time - d.start_time); })
+ .attr("height", function(d) { return y(d.size) - 1; })
+ .on("mouseover", function(d) {
+ var trace = "";
+ for (var i = 0, len = d.start_trace.length; i < len; i++) {
+ var frame = d.start_trace[i];
+ trace += frame[2] + " " + frame[1] + "<br/>";
+ }
+ trace += "<br/>End Trace:<br/>";
+ for (var i = 0, len = d.end_trace.length; i < len; i++) {
+ var frame = d.end_trace[i];
+ trace += frame[2] + " " + frame[1] + "<br/>";
+ }
+ var side = "left";
+ var other_side = "right";
+ var pos_x = x(d.start_time) + margin.left;
+ if (width - pos_x < 300) {
+ side = "right";
+ other_side = "left";
+ pos_x = width - x(d.start_time) + margin.right;
+ }
+ var pos_y = (height - y(d.start_block) + margin.bottom)
+ var edge = "bottom";
+ var other_edge = "top";
+ if ((height - pos_y) < 300) {
+ edge = "top";
+ other_edge = "bottom";
+ pos_y = y(d.start_block) + margin.top + y(d.size);
+ }
+ div.style("opacity", 1)
+ .html("Start block: " + d.start_block + " Size: " + d.size + " blocks<br/><br/>" + trace)
+ .style(side, pos_x + "px")
+ .style(other_side, null)
+ .style(edge, pos_y + "px")
+ .style(other_edge, null);
+ });
+
+ // bar.append("text")
+ // .attr("x", function(d) { return x(d.value) - 3; })
+ // .attr("y", barHeight / 2)
+ // .attr("dy", ".35em")
+ // .text(function(d) { return d.value; });
+ });
+
+ function type(d) {
+ d.value = +d.value; // coerce to number
+ return d;
+ }
+ </script>
+ </body>
+</html>