Skip to content
This repository was archived by the owner on May 24, 2020. It is now read-only.

Commit

Permalink
basic gc stats
Browse files Browse the repository at this point in the history
  • Loading branch information
BFergerson committed Mar 19, 2017
1 parent 0db4d6f commit db4ab8e
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 9 deletions.
1 change: 1 addition & 0 deletions .idea/modules/jvm_mechanic.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules/jvm_mechanic_main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules/jvm_mechanic_test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ dependencies {
compile group: 'me.tomassetti', name: 'java-symbol-solver-core', version: '0.2'
compile group: 'com.beust', name: 'jcommander', version: '1.7'
compile group: 'org.nanohttpd', name: 'nanohttpd', version: '2.3.1'
compile group: 'hsqldb', name: 'hsqldb', version: '1.8.0.7'
compile group: 'commons-cli', name: 'commons-cli', version: '1.1'
}

task uberJar(type: Jar, dependsOn:[':compileJava']) {
Expand Down
20 changes: 11 additions & 9 deletions dashboard/assets/jvm_mechanic_charts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var relativeMethodRuntimeDurationConfig = {
type: 'line',
data: {
datasets: []
datasets: [],
labels: []
},
options: {
responsive: true,
Expand Down Expand Up @@ -51,7 +52,8 @@ var relativeMethodRuntimeDurationConfig = {
var absoluteMethodRuntimeDurationConfig = {
type: 'line',
data: {
datasets: []
datasets: [],
labels: []
},
options: {
responsive: true,
Expand Down Expand Up @@ -200,19 +202,17 @@ function ledgerLoaded() {
ctx = document.getElementById("total_relative_method_duration_polar_canvas").getContext("2d");
window.totalMethodDurationPolarChart = new Chart(ctx, totalMethodDurationPolarChartConfig);

updateCharts(cutOffMinutesTime);

//update charts every 5 seconds
setInterval(function() {
loadLedgerUpdates();
updateCharts(cutOffMinutesTime);

evictOldChartData(relativeMethodRuntimeDurationConfig.data, cutOffMinutesTime);
evictOldChartData(absoluteMethodRuntimeDurationConfig.data, cutOffMinutesTime);
}, 5000);
}

var sessionAccountedFor = {};
function ledgerUpdated() {
updateCharts(cutOffMinutesTime);
evictOldChartData(relativeMethodRuntimeDurationConfig.data, cutOffMinutesTime);
evictOldChartData(absoluteMethodRuntimeDurationConfig.data, cutOffMinutesTime);
}

function isEvictableData(sessionTime, cutOffMinutesTime) {
var duration = moment.duration(moment().diff(sessionTime));
Expand Down Expand Up @@ -251,6 +251,7 @@ function evictOldChartData(data, cutOffMinutesTime) {
}
}

var sessionAccountedFor = {};
var methodColorMap = {};
var totalMethodDurationMap = {};
var averageDurationMap = {};
Expand Down Expand Up @@ -367,6 +368,7 @@ function updateCharts(cutOffMinutesTime) {
var newDataset = {
label: methodNameMap[eventMethodId],
backgroundColor: newColor,
borderColor: newColor,
data: [],
fill: false
};
Expand Down
30 changes: 30 additions & 0 deletions dashboard/assets/jvm_mechanic_garbage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//config
var host = "http://localhost:9000";

loadGarbageUpdates();
//update garbage stats every 30 seconds
setInterval(function() {
loadGarbageUpdates();
}, 30000);

function loadGarbageUpdates() {
console.log("Downloading latest garbage collection stats...");

$.getJSON(host + "/gc", function(result) {
console.log("Updating GC stats...");
$("#totalGCEvents").text(result.totalGCEvents);
$("#maxHeapOccupancy").text(result.maxHeapOccupancy + "K");
$("#maxHeapSpace").text(result.maxHeapSpace + "K");
$("#maxPermMetaspaceOccupancy").text(result.maxPermMetaspaceOccupancy + "K");
$("#maxPermMetaspaceSpace").text(result.maxPermMetaspaceSpace + "K");
$("#GCThroughput").text(result.gcthroughput + "%");
$("#GCMaxPause").text(moment.duration(result.gcmaxPause).asSeconds() + " seconds");
$("#GCTotalPause").text(moment.duration(result.gctotalPause).asSeconds() + " seconds");
$("#stoppedTimeThroughput").text(result.stoppedTimeThroughput + "%");
$("#stoppedTimeMaxPause").text(moment.duration(result.stoppedTimeMaxPause).asSeconds() + " seconds");
$("#stoppedTimeTotal").text(moment.duration(result.stoppedTimeTotal).asSeconds() + " seconds");
$("#GCStoppedRatio").text(result.gcstoppedRatio + "%");
}).always(function(result) {
//todo: anything?
});
}
8 changes: 8 additions & 0 deletions dashboard/assets/jvm_mechanic_ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,17 @@ function loadLedgerUpdates(initialLoad) {
console.log("Saved ledger_data to local storage!");
});
}

if (!initialLoad && ledgerUpdated) {
ledgerUpdated0();
}
});
}

function ledgerUpdated0() {
ledgerUpdated();
}

function loadMethodNames(initialLoad) {
storage.getContents('ledger_data.method_names').then(function(content) {
console.log("Checking cache for: ledger_data.method_names");
Expand Down
85 changes: 85 additions & 0 deletions dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<script src="assets/moment.js"></script>
<script src="assets/jvm_mechanic_charts.js"></script>
<script src="assets/jvm_mechanic_ledger.js"></script>
<script src="assets/jvm_mechanic_garbage.js"></script>
<script src="assets/tether/tether.min.js"></script>
<script src="assets/bootstrap/bootstrap4-alpha3.min.js"></script>
<script src="assets/canvasjs.min.js"></script>
Expand Down Expand Up @@ -97,6 +98,90 @@
<!-- .container-fluid -->
<div style="margin-top: 10px">
<div class="container-fluid" style="width: 98%">
<div class="row">
<div class="col-sm-3">
<div class="panel panel-default">
<div class="panel-heading">General Monitoring Information</div>
<div class="panel-body">
<b>First Recorded Request:</b> then <br/>
<b>Last Recorded Request:</b> now <br/>
- <br/>
<b>Total Recorded Events:</b> 10,522 <br/>
<b>Event Recording Rate:</b> 2,040 per second <br/>
- <br/>
<b>Total Recorded Sessions:</b> 122 <br/>
<b>Session Recording Rate:</b> 20 per second <br/>
- <br/>
<b>CPU Usage - System:</b> 60.5% <br/>
<b>CPU Usage - Java:</b> 22.4% <br/>
<br/>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="panel panel-default">
<div class="panel-heading">jvm_mechanic Configuration Information</div>
<div class="panel-body">
<b>Session Sample Accuracy:</b> 100% <br/>
- <br/>
<b>Ledger file location:</b> C:\temp\jvm_mechanic.ledger <br/>
<b>Leger entry count:</b> 100 (2KB) <br/>
- <br/>
<b>Data file location:</b> C:\temp\jvm_mechanic.data <br/>
<b>Data entry count:</b> 100 (200KB) <br/>
- <br/>
<b>GC file location:</b> C:\temp\jvm_gc.log <br/>
<b>GC file size:</b> 44.0MB
<br/>
<br/>
<br/>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="panel panel-default">
<div class="panel-heading">Garbage Collection - General</div>
<div class="panel-body">
<b>Total GC Events:</b> <label id="totalGCEvents" style="margin-bottom: 0">n/a</label><br/>
<!--Event Types: PARALLEL_SCAVENGE, PARALLEL_OLD_COMPACTING <br/>-->
<b>Max Heap Occupancy:</b> <label id="maxHeapOccupancy" style="margin-bottom: 0">n/a</label><br/>
<b>Max Heap Space:</b> <label id="maxHeapSpace" style="margin-bottom: 0">n/a</label><br/>
<b>Max Perm/Metaspace Occupancy:</b> <label id="maxPermMetaspaceOccupancy"
style="margin-bottom: 0">n/a</label><br/>
<b>Max Perm/Metaspace Space:</b> <label id="maxPermMetaspaceSpace" style="margin-bottom: 0">n/a</label><br/>
<b>GC Throughput:</b> <label id="GCThroughput" style="margin-bottom: 0">n/a</label><br/>
<b>GC Max Pause:</b> <label id="GCMaxPause" style="margin-bottom: 0">n/a</label><br/>
<b>GC Total Pause:</b> <label id="GCTotalPause" style="margin-bottom: 0">n/a</label><br/>
<b>Stopped Time Throughput:</b> <label id="stoppedTimeThroughput" style="margin-bottom: 0">n/a</label><br/>
<b>Stopped Time Max Pause:</b> <label id="stoppedTimeMaxPause"
style="margin-bottom: 0">n/a</label><br/>
<b>Stopped Time Total:</b> <label id="stoppedTimeTotal" style="margin-bottom: 0">n/a</label><br/>
<b>GC/Stopped Ratio:</b> <label id="GCStoppedRatio"
style="margin-bottom: 0">n/a</label><br/>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="panel panel-default">
<div class="panel-heading">Garbage Collection - Per Session</div>
<div class="panel-body">
todo
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="panel panel-default">
<canvas id="current_relative_method_runtime_duration_canvas" height="40"></canvas>
Expand Down
Binary file added libs/garbagecat-2.0.5.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.codebrig.jvmmechanic.dashboard;

/**
* todo: this
*
* @author Brandon Fergerson <[email protected]>
*/
public class GarbageCollectionReport {

private int totalGCEvents;
private int maxHeapOccupancy;
private int maxHeapSpace;
private int maxPermMetaspaceOccupancy;
private int maxPermMetaspaceSpace;
private double GCThroughput;
private double GCMaxPause;
private double GCTotalPause;
private double stoppedTimeThroughput;
private double stoppedTimeMaxPause;
private double stoppedTimeTotal;
private double GCStoppedRatio;

public int getTotalGCEvents() {
return totalGCEvents;
}

public void setTotalGCEvents(int totalGCEvents) {
this.totalGCEvents = totalGCEvents;
}

public int getMaxHeapOccupancy() {
return maxHeapOccupancy;
}

public void setMaxHeapOccupancy(int maxHeapOccupancy) {
this.maxHeapOccupancy = maxHeapOccupancy;
}

public int getMaxHeapSpace() {
return maxHeapSpace;
}

public void setMaxHeapSpace(int maxHeapSpace) {
this.maxHeapSpace = maxHeapSpace;
}

public int getMaxPermMetaspaceOccupancy() {
return maxPermMetaspaceOccupancy;
}

public void setMaxPermMetaspaceOccupancy(int maxPermMetaspaceOccupancy) {
this.maxPermMetaspaceOccupancy = maxPermMetaspaceOccupancy;
}

public int getMaxPermMetaspaceSpace() {
return maxPermMetaspaceSpace;
}

public void setMaxPermMetaspaceSpace(int maxPermMetaspaceSpace) {
this.maxPermMetaspaceSpace = maxPermMetaspaceSpace;
}

public double getGCThroughput() {
return GCThroughput;
}

public void setGCThroughput(double GCThroughput) {
this.GCThroughput = GCThroughput;
}

public double getGCMaxPause() {
return GCMaxPause;
}

public void setGCMaxPause(double GCMaxPause) {
this.GCMaxPause = GCMaxPause;
}

public double getGCTotalPause() {
return GCTotalPause;
}

public void setGCTotalPause(double GCTotalPause) {
this.GCTotalPause = GCTotalPause;
}

public double getStoppedTimeThroughput() {
return stoppedTimeThroughput;
}

public void setStoppedTimeThroughput(double stoppedTimeThroughput) {
this.stoppedTimeThroughput = stoppedTimeThroughput;
}

public double getStoppedTimeMaxPause() {
return stoppedTimeMaxPause;
}

public void setStoppedTimeMaxPause(double stoppedTimeMaxPause) {
this.stoppedTimeMaxPause = stoppedTimeMaxPause;
}

public double getStoppedTimeTotal() {
return stoppedTimeTotal;
}

public void setStoppedTimeTotal(double stoppedTimeTotal) {
this.stoppedTimeTotal = stoppedTimeTotal;
}

public double getGCStoppedRatio() {
return GCStoppedRatio;
}

public void setGCStoppedRatio(double GCStoppedRatio) {
this.GCStoppedRatio = GCStoppedRatio;
}

}
Loading

0 comments on commit db4ab8e

Please sign in to comment.