Skip to content
Permalink
Browse files
7000: Update third party library used in flightrecorder.flameview
Co-authored-by: Miro Wengner <miro.wengner@gmail.com>
Reviewed-by: hirt
  • Loading branch information
Guru Hb and mirage22 committed Dec 22, 2020
1 parent 46a5590 commit 2ede603b0a6ffd2c5053242d35bf135520707e9f
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 71 deletions.
@@ -65,55 +65,31 @@
<goal>wget</goal>
</goals>
<configuration>
<url>https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.css</url>
<url>https://cdn.jsdelivr.net/npm/d3-flame-graph@4.0.6/dist/d3-flamegraph.css</url>
<unpack>false</unpack>
<outputDirectory>${download-maven-plugin.output}</outputDirectory>
</configuration>
</execution>
<execution>
<id>ie-html5shiv-js</id>
<id>d3-v6-js</id>
<phase>${download-maven-plugin.phase}</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js</url>
<url>https://d3js.org/d3.v6.min.js</url>
<unpack>false</unpack>
<outputDirectory>${download-maven-plugin.output}</outputDirectory>
</configuration>
</execution>
<execution>
<id>ie-respond-js</id>
<id>d3-flamegraph-tooltip-js</id>
<phase>${download-maven-plugin.phase}</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://oss.maxcdn.com/respond/1.4.2/respond.min.js</url>
<unpack>false</unpack>
<outputDirectory>${download-maven-plugin.output}</outputDirectory>
</configuration>
</execution>
<execution>
<id>d3-v4-js</id>
<phase>${download-maven-plugin.phase}</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://d3js.org/d3.v4.min.js</url>
<unpack>false</unpack>
<outputDirectory>${download-maven-plugin.output}</outputDirectory>
</configuration>
</execution>
<execution>
<id>d3-tip-js</id>
<phase>${download-maven-plugin.phase}</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.9.1/d3-tip.min.js</url>
<url>https://cdn.jsdelivr.net/npm/d3-flame-graph@4.0.6/dist/d3-flamegraph-tooltip.js</url>
<unpack>false</unpack>
<outputDirectory>${download-maven-plugin.output}</outputDirectory>
</configuration>
@@ -125,7 +101,7 @@
<goal>wget</goal>
</goals>
<configuration>
<url>https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.min.js</url>
<url>https://cdn.jsdelivr.net/npm/d3-flame-graph@4.0.6/dist/d3-flamegraph.js</url>
<unpack>false</unpack>
<outputDirectory>${download-maven-plugin.output}</outputDirectory>
</configuration>
@@ -114,17 +114,19 @@ private static String createNodeJsonProps(AggregatableFrame frame, double value)
sb.append(addQuotes("p")).append(": ").append(addQuotes(packageName));
sb.append(",");
}
sb.append(addQuotes("v")).append(": ").append(addQuotes(String.valueOf((int) value)));
sb.append(addQuotes("v")).append(": ").append(String.valueOf((int) value));
return sb.toString();
}

private static String createJsonProps(String frameName, String description) {
private static String createJsonProps(String frameName, String description, double value) {
StringBuilder sb = new StringBuilder();
sb.append(addQuotes("n")).append(": ").append(addQuotes(frameName));
sb.append(",");
sb.append(addQuotes("p")).append(": ").append(addQuotes(""));
sb.append(",");
sb.append(addQuotes("d")).append(": ").append(addQuotes(description));
sb.append(",");
sb.append(addQuotes("v")).append(": ").append(String.valueOf((int) value));
return sb.toString();
}

@@ -151,7 +153,8 @@ private static String createRootNodeJson(IItemCollection events) {
Map<String, Long> eventCountsByType = countEventsByType(events);
String rootTitle = createRootNodeTitle(eventCountsByType);
String rootDescription = createRootNodeDescription(eventCountsByType);
return createJsonProps(rootTitle, rootDescription);
return createJsonProps(rootTitle, rootDescription,
eventCountsByType.values().stream().mapToLong(Long::longValue).sum());
}

private static String createRootNodeTitle(Map<String, Long> eventCountsByType) {
@@ -120,33 +120,27 @@ public class FlameGraphView extends ViewPart implements ISelectionListener {
private static final String TOOLTIP_DESCRIPTION = getFlameviewMessage(FLAMEVIEW_SELECT_HTML_TOOLTIP_DESCRIPTION);
private static final String HTML_PAGE;
static {
// from: https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.css
// from: https://cdn.jsdelivr.net/npm/d3-flame-graph@4.0.6/dist/d3-flamegraph.css
String cssD3Flamegraph = "jslibs/d3-flamegraph.css";
// from: https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js
String jsHtml5shiv = "jslibs/html5shiv.min.js";
// from: https://oss.maxcdn.com/respond/1.4.2/respond.min.js
String jsRespond = "jslibs/respond.min.js";
// from: https://d3js.org/d3.v4.min.js
String jsD3V4 = "jslibs/d3.v4.min.js";
// from: https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.9.1/d3-tip.min.js
String jsD3Tip = "jslibs/d3-tip.min.js";
// from: https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.min.js
String jsD3FlameGraph = "jslibs/d3-flamegraph.min.js";
// from: https://d3js.org/d3.v6.min.js
String jsD3V6 = "jslibs/d3.v6.min.js";
// from: https://cdn.jsdelivr.net/npm/d3-flame-graph@4.0.6/dist/d3-flamegraph-tooltip.js
String jsD3Tip = "jslibs/d3-flamegraph-tooltip.js";
// from: https://cdn.jsdelivr.net/npm/d3-flame-graph@4.0.6/dist/d3-flamegraph.js
String jsD3FlameGraph = "jslibs/d3-flamegraph.js";
// jmc flameview coloring, tooltip and other functions
String jsFlameviewName = "flameview.js";
String cssFlameview = "flameview.css";

String jsIeLibraries = loadLibraries(jsHtml5shiv, jsRespond);
String jsD3Libraries = loadLibraries(jsD3V4, jsD3Tip, jsD3FlameGraph);
String jsD3 = loadLibraries(jsD3V6, jsD3FlameGraph, jsD3Tip);
String styleheets = loadLibraries(cssD3Flamegraph, cssFlameview);
String jsFlameviewColoring = fileContent(jsFlameviewName);

String magnifierIcon = getIconBase64(ImageConstants.ICON_MAGNIFIER);

// formatter arguments for the template: %1 - CSSs stylesheets, %2 - IE9 specific scripts,
// %3 - Search Icon Base64, %4 - 3rd party scripts, %5 - Flameview Coloring,
HTML_PAGE = String.format(fileContent("page.template"), styleheets, jsIeLibraries, magnifierIcon, jsD3Libraries,
jsFlameviewColoring);
// formatter arguments for the template: %1 - CSSs stylesheets,
// %2 - Search Icon Base64, %3 - 3rd party scripts, %4 - Flameview Coloring,
HTML_PAGE = String.format(fileContent("page.template"), styleheets, magnifierIcon, jsD3, jsFlameviewColoring);
}

private static final int MODEL_EXECUTOR_THREADS_NUMBER = 3;
@@ -1,3 +1,4 @@

/*
Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, Datadog, Inc. All rights reserved.
@@ -146,7 +147,7 @@ const adjustTip = function(d) {
var tipMessage = "".concat(d.data.n, htmlTagBr);

if (nodeContainsChildren(d.data)) {
if (d.data.v === undefined) {
if (d.data.d && d.data.d.includes("|")) {
tipMessage += createRootTable(d.data.d);
} else {
tipMessage += createNodeTipTable(d.data);
@@ -4,10 +4,6 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">%1$s</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script>%2$s</script>
<![endif]-->
<style type="text/css" media="print">
body {
background: #fff;
@@ -22,11 +18,15 @@
<body>
<div id="search" align="right">
<input type="text" id="searchInput" size="30" onfocusout="executeSearch()" value="">
<img src="data:image/png;base64, %3$s" width="12" height="12">
<img src="data:image/png;base64, %2$s" width="12" height="12">
</div>
<div id="chart"></div>
<script type="text/javascript">%4$s</script>
<script type="text/javascript">%5$s</script>
<script type="text/javascript">
%3$s
</script>
<script type="text/javascript">
%4$s
</script>
<script type="text/javascript">

const minSearchTextSize = 3;
@@ -59,22 +59,18 @@
tootlipDescription = dt;
};

const tip = d3.tip()
.direction("s")
.offset([8, 0])
.attr('class', 'd3-flame-graph-tip')
.html(adjustTip);
const tip = flamegraph.tooltip.defaultFlamegraphTooltip()
.html(adjustTip);

function processGraph(jsonObj, viewInverted) {
flameGraph = d3.flamegraph()
flameGraph = flamegraph()
.width(windowSize())
.cellHeight(18)
.transitionDuration(320)
.minFrameSize(5)
.transitionEase(d3.easeCubic)
.sort(true)
.title("")
.differential(false)
.inverted(viewInverted)
.tooltip(tip)
.color(colorCell);
@@ -182,4 +178,4 @@

</script>
</body>
</html>
</html>
@@ -1 +1 @@
{"n": "468 events of 21 types: Recording Setting[255], Java Monitor Wait[108], Thread Allocation Statistics[44]...","p": "","d": "255:Recording Setting|108:Java Monitor Wait|44:Thread Allocation Statistics|9:Socket Read|9:Class Loading Statistics|9:Exception Statistics|9:Java Thread Statistics|8:CPU Load|3:Allocation in new TLAB|2:Method Profiling Sample|12:Others... (11 types)|", "c": [ {"n": "AbstractCollection.toArray()","p": "java.util","v": "24", "c": [ {"n": "ArrayList.<init>(Collection)","p": "java.util","v": "24", "c": [ {"n": "JFRImpl.getRecordings()","p": "oracle.jrockit.jfr","v": "24", "c": [ {"n": "MetaProducer.onNewChunk()","p": "oracle.jrockit.jfr","v": "24", "c": [ {"n": "JFRImpl.onNewChunk()","p": "oracle.jrockit.jfr","v": "24", "c": [ ]}]}]}]}]},{"n": "TimerThread.mainLoop()","p": "java.util","v": "112", "c": [ {"n": "TimerThread.run()","p": "java.util","v": "112", "c": [ ]}]},{"n": "Arrays.copyOfRange(char[], int, int)","p": "java.util","v": "104", "c": [ {"n": "String.<init>(char[], int, int)","p": "java.lang","v": "104", "c": [ {"n": "StringBuilder.toString()","p": "java.lang","v": "104", "c": [ {"n": "ObjectInputStream$BlockDataInputStream.readUTFBody(long)","p": "java.io","v": "104", "c": [ {"n": "ObjectInputStream$BlockDataInputStream.readUTF()","p": "java.io","v": "104", "c": [ {"n": "ObjectInputStream.readString(boolean)","p": "java.io","v": "104", "c": [ {"n": "ObjectInputStream.readObject0(boolean)","p": "java.io","v": "104", "c": [ {"n": "ObjectInputStream.readObject()","p": "java.io","v": "104", "c": [ {"n": "ObjectName.readObject(ObjectInputStream)","p": "javax.management","v": "104", "c": [ {"n": "GeneratedMethodAccessor3.invoke(Object, Object[])","p": "sun.reflect","v": "104", "c": [ {"n": "DelegatingMethodAccessorImpl.invoke(Object, Object[])","p": "sun.reflect","v": "104", "c": [ {"n": "Method.invoke(Object, Object[])","p": "java.lang.reflect","v": "104", "c": [ {"n": "ObjectStreamClass.invokeReadObject(Object, ObjectInputStream)","p": "java.io","v": "104", "c": [ {"n": "ObjectInputStream.readSerialData(Object, ObjectStreamClass)","p": "java.io","v": "104", "c": [ {"n": "ObjectInputStream.readOrdinaryObject(boolean)","p": "java.io","v": "104", "c": [ {"n": "ObjectInputStream.readObject0(boolean)","p": "java.io","v": "104", "c": [ {"n": "ObjectInputStream.readObject()","p": "java.io","v": "104", "c": [ {"n": "UnicastRef.unmarshalValue(Class, ObjectInput)","p": "sun.rmi.server","v": "104", "c": [ {"n": "UnicastServerRef.dispatch(Remote, RemoteCall)","p": "sun.rmi.server","v": "104", "c": [ {"n": "Transport$1.run()","p": "sun.rmi.transport","v": "104", "c": [ {"n": "Transport$1.run()","p": "sun.rmi.transport","v": "104", "c": [ {"n": "AccessController.doPrivileged(PrivilegedExceptionAction, AccessControlContext)","p": "java.security","v": "104", "c": [ {"n": "Transport.serviceCall(RemoteCall)","p": "sun.rmi.transport","v": "104", "c": [ {"n": "TCPTransport.handleMessages(Connection, boolean)","p": "sun.rmi.transport.tcp","v": "104", "c": [ {"n": "TCPTransport$ConnectionHandler.run0()","p": "sun.rmi.transport.tcp","v": "104", "c": [ {"n": "TCPTransport$ConnectionHandler.run()","p": "sun.rmi.transport.tcp","v": "104", "c": [ {"n": "ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker)","p": "java.util.concurrent","v": "104", "c": [ {"n": "ThreadPoolExecutor$Worker.run()","p": "java.util.concurrent","v": "104", "c": [ {"n": "Thread.run()","p": "java.lang","v": "104", "c": [ ]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}
{"n": "468 events of 21 types: Recording Setting[255], Java Monitor Wait[108], Thread Allocation Statistics[44]...","p": "","d": "255:Recording Setting|108:Java Monitor Wait|44:Thread Allocation Statistics|9:Socket Read|9:Class Loading Statistics|9:Exception Statistics|9:Java Thread Statistics|8:CPU Load|3:Allocation in new TLAB|2:Method Profiling Sample|12:Others... (11 types)|","v": 468, "c": [ {"n": "AbstractCollection.toArray()","p": "java.util","v": 24, "c": [ {"n": "ArrayList.<init>(Collection)","p": "java.util","v": 24, "c": [ {"n": "JFRImpl.getRecordings()","p": "oracle.jrockit.jfr","v": 24, "c": [ {"n": "MetaProducer.onNewChunk()","p": "oracle.jrockit.jfr","v": 24, "c": [ {"n": "JFRImpl.onNewChunk()","p": "oracle.jrockit.jfr","v": 24, "c": [ ]}]}]}]}]},{"n": "TimerThread.mainLoop()","p": "java.util","v": 112, "c": [ {"n": "TimerThread.run()","p": "java.util","v": 112, "c": [ ]}]},{"n": "Arrays.copyOfRange(char[], int, int)","p": "java.util","v": 104, "c": [ {"n": "String.<init>(char[], int, int)","p": "java.lang","v": 104, "c": [ {"n": "StringBuilder.toString()","p": "java.lang","v": 104, "c": [ {"n": "ObjectInputStream$BlockDataInputStream.readUTFBody(long)","p": "java.io","v": 104, "c": [ {"n": "ObjectInputStream$BlockDataInputStream.readUTF()","p": "java.io","v": 104, "c": [ {"n": "ObjectInputStream.readString(boolean)","p": "java.io","v": 104, "c": [ {"n": "ObjectInputStream.readObject0(boolean)","p": "java.io","v": 104, "c": [ {"n": "ObjectInputStream.readObject()","p": "java.io","v": 104, "c": [ {"n": "ObjectName.readObject(ObjectInputStream)","p": "javax.management","v": 104, "c": [ {"n": "GeneratedMethodAccessor3.invoke(Object, Object[])","p": "sun.reflect","v": 104, "c": [ {"n": "DelegatingMethodAccessorImpl.invoke(Object, Object[])","p": "sun.reflect","v": 104, "c": [ {"n": "Method.invoke(Object, Object[])","p": "java.lang.reflect","v": 104, "c": [ {"n": "ObjectStreamClass.invokeReadObject(Object, ObjectInputStream)","p": "java.io","v": 104, "c": [ {"n": "ObjectInputStream.readSerialData(Object, ObjectStreamClass)","p": "java.io","v": 104, "c": [ {"n": "ObjectInputStream.readOrdinaryObject(boolean)","p": "java.io","v": 104, "c": [ {"n": "ObjectInputStream.readObject0(boolean)","p": "java.io","v": 104, "c": [ {"n": "ObjectInputStream.readObject()","p": "java.io","v": 104, "c": [ {"n": "UnicastRef.unmarshalValue(Class, ObjectInput)","p": "sun.rmi.server","v": 104, "c": [ {"n": "UnicastServerRef.dispatch(Remote, RemoteCall)","p": "sun.rmi.server","v": 104, "c": [ {"n": "Transport$1.run()","p": "sun.rmi.transport","v": 104, "c": [ {"n": "Transport$1.run()","p": "sun.rmi.transport","v": 104, "c": [ {"n": "AccessController.doPrivileged(PrivilegedExceptionAction, AccessControlContext)","p": "java.security","v": 104, "c": [ {"n": "Transport.serviceCall(RemoteCall)","p": "sun.rmi.transport","v": 104, "c": [ {"n": "TCPTransport.handleMessages(Connection, boolean)","p": "sun.rmi.transport.tcp","v": 104, "c": [ {"n": "TCPTransport$ConnectionHandler.run0()","p": "sun.rmi.transport.tcp","v": 104, "c": [ {"n": "TCPTransport$ConnectionHandler.run()","p": "sun.rmi.transport.tcp","v": 104, "c": [ {"n": "ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker)","p": "java.util.concurrent","v": 104, "c": [ {"n": "ThreadPoolExecutor$Worker.run()","p": "java.util.concurrent","v": 104, "c": [ {"n": "Thread.run()","p": "java.lang","v": 104, "c": [ ]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}

0 comments on commit 2ede603

Please sign in to comment.