Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a1f7b8e4a | ||
|
|
8128696c0b | ||
|
|
dead47e0fb | ||
|
|
56730dc7b5 | ||
|
|
26eab2e657 | ||
|
|
8fee26589d | ||
|
|
9653401b4b | ||
|
|
4f6c675504 | ||
|
|
cced4fcb51 | ||
|
|
904da2ac6b | ||
|
|
746166ccb4 | ||
|
|
e9de87c0c3 | ||
|
|
a53a141dd2 | ||
|
|
c6b5c877f1 | ||
|
|
8d846a01e7 | ||
|
|
a23400b85e | ||
|
|
df5fb83354 | ||
|
|
90b7c78643 | ||
|
|
80c3993b7e | ||
|
|
b81be14adf | ||
|
|
f86d1a415b | ||
|
|
c00b6c25de | ||
|
|
4713106ac9 | ||
|
|
c89fea8de5 | ||
|
|
0309f3dfd3 | ||
|
|
5ec58fd873 | ||
|
|
1fda752243 | ||
|
|
ff305e1d16 | ||
|
|
5cc4721e66 | ||
|
|
fee03218d1 | ||
|
|
dade9b2283 | ||
|
|
db9ec2e59e | ||
|
|
f0a7a36825 | ||
|
|
6f869d3eff | ||
|
|
462988d8de | ||
|
|
73b5e97c39 | ||
|
|
41121aa64f | ||
|
|
2519bf4307 | ||
|
|
09bf0f025b | ||
|
|
12dfaba106 |
@@ -1,855 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<style>
|
||||
:root {--bg: #ffffff; --fg: #000000; --hl-bg: #ffffe0; --hl-border: #ffc000; --link: #0366d6; --legend-bg: #ffffe0; --legend-border: #666666}
|
||||
:root.dark {--bg: #1e1e1e; --fg: #cccccc; --hl-bg: #3a3a00; --hl-border: #8a7000; --link: #58a6ff; --legend-bg: #333333; --legend-border: #888888}
|
||||
body {margin: 0; padding: 10px 10px 22px 10px; background-color: var(--bg); color: var(--fg)}
|
||||
h1 {margin: 5px 0 0 0; font-size: 18px; font-weight: normal; text-align: center}
|
||||
header {margin: -22px 0 6px 0}
|
||||
button {border: none; background: none; width: 24px; height: 24px; cursor: pointer; margin: 0; padding: 2px 0 0 0; text-align: center}
|
||||
button:hover {background-color: var(--hl-bg); outline: 1px solid var(--hl-border); border-radius: 4px}
|
||||
dl {margin: 0 4px 8px 4px}
|
||||
dt {margin: 1px; padding: 2px 0; font-weight: bold}
|
||||
dd {margin: 1px; padding: 2px 4px}
|
||||
dl.frames {float: left; width: 160px}
|
||||
dl.frames > dd {color: #000000}
|
||||
dl.hotkeys {clear: left; border-top: 1px solid var(--legend-border)}
|
||||
dl.hotkeys > dt {float: left; clear: left; width: 158px; margin-right: 4px; text-align: right}
|
||||
dl.hotkeys > dd {float: left}
|
||||
p {position: fixed; bottom: 0; margin: 0; padding: 2px 3px 2px 3px; outline: 1px solid var(--hl-border); display: none; overflow: hidden; white-space: nowrap; background-color: var(--hl-bg); color: var(--fg)}
|
||||
a {color: var(--link)}
|
||||
#legend {padding: 4px; border-radius: 4px; background: var(--legend-bg); border: 1px solid var(--legend-border); display: none}
|
||||
#hl {position: absolute; display: none; overflow: hidden; white-space: nowrap; pointer-events: none; background-color: var(--hl-bg); outline: 1px solid var(--hl-border); height: 15px}
|
||||
#hl span {padding: 0 3px 0 3px}
|
||||
#status {left: 0}
|
||||
#match {right: 0}
|
||||
#reset {cursor: pointer}
|
||||
#canvas {width: 100%; height: 576px}
|
||||
</style>
|
||||
<script>
|
||||
{
|
||||
let theme;
|
||||
try { theme = localStorage.getItem('flame-theme'); } catch (ignored) {}
|
||||
if (theme ? theme === 'dark' : matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body style='font: 12px Verdana, sans-serif'>
|
||||
<h1>CPU profile</h1>
|
||||
<header style='float: left'>
|
||||
<button id='inverted' title='Invert (I)'><svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 392 392'><path d='M196,36 L316,156 L76,156 Z' fill='#004d80'/><path d='M196,356 L76,236 L316,236 Z' fill='#004d80'/><path d='M196,54 L298,156 L94,156 Z' fill='#ff8d40'/><path d='M196,338 L94,236 L298,236 Z' fill='#40b2ff'/><rect x='94' y='188' width='204' height='16' fill='#004d80'/></svg></button>
|
||||
<button id='search' title='Search (Ctrl+F)'><svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='-39.3 -39.3 471.1 471.1'><circle cx='147.7' cy='147.8' r='125.9' fill='#fff'/><path fill='#40b2ff' d='M370.7 348.7c0 1.4-1.6 6.3-7.2 12.3-6.2 6.7-12.5 9.8-14.7 9.8h-.1c-19.5-1.6-62-43.2-109.6-106.8 9.2-7.2 17.5-15.5 24.6-24.6 63.6 47.6 105.2 90.2 106.8 109.6z'/><path fill='#ff8d40' d='M208.7 86.9l-14.5 14.5c-17.1 17.1-46.5 5-46.5-19.3V61.6c-49 0-88.4 40.8-86.1 90.2 2 43.9 38.1 80 82 82 49.5 2.3 90.2-37.2 90.2-86.1 0-23.7-9.6-45.2-25.1-60.8z'/><path fill='#004d80' d='M276.1 221c12.3-21.5 19.5-46.5 19.5-73.2C295.6 66.3 229.2.1 147.7.1S0 66.3 0 147.9s66.3 147.7 147.7 147.7c26.6 0 51.5-7.1 73.2-19.5 39.8 53.3 91.9 113.5 126.1 116.4 12.3.5 22.9-6.7 32.8-16.7 5.2-5.6 13.8-16.9 12.8-28.8-2.9-34.1-63.1-86.2-116.4-126.1zM147.7 273.8c-69.5 0-125.9-56.5-125.9-125.9S78.3 21.9 147.7 21.9 273.6 78.4 273.6 147.8s-56.4 126-125.9 126zm215.9 87.2c-6.2 6.7-12.4 9.8-14.7 9.8h-.1c-19.5-1.6-62-43.2-109.6-106.8 9.2-7.2 17.5-15.5 24.6-24.6 63.6 47.6 105.2 90.2 106.8 109.6 0 1.4-1.6 6.3-7.2 12.4z'/></svg></button>
|
||||
<button id='darkmode' title='Toggle dark mode (D)'><svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'><path d='M10 4a6 6 0 0 1 0 12z' fill='#ff8d40'/><path d='M10 4a6 6 0 0 0 0 12z' fill='#ffffff'/><circle cx='10' cy='10' r='8' fill='none' stroke='#004d80'/></svg></button>
|
||||
<button id='info'><svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'><circle cx='10' cy='10' r='8' stroke='#004d80' fill='none'/><path d='M10 5.5c-1.25 0-2.25 1-2.25 2.25H9a1.25 1.25 0 0 1 2.5 0c0 .65-.55 1-1 1.2-.7.35-1.25.85-1.25 1.8V11h1.5v-.25c0-.37.29-.65.68-.83.73-.34 1.32-.87 1.32-2.17 0-1.25-1.5-2.25-2.75-2.25' fill='#ff8d40' stroke='#ff8d40' stroke-width='.6' stroke-linecap='round' stroke-linejoin='round'/><circle cx='10' cy='13.5' r='1.2' fill='#ff8d40'/></svg></button>
|
||||
</header>
|
||||
<header style='float: right'>Produced by <a href='https://github.com/async-profiler/async-profiler'>async-profiler</a></header>
|
||||
<div id='legend' style='position: absolute'>
|
||||
<dl class='frames'>
|
||||
<dt>Frame types</dt>
|
||||
<dd style='background-color: #e17d00'>Kernel</dd>
|
||||
<dd style='background-color: #e15a5a'>Native</dd>
|
||||
<dd style='background-color: #c8c83c'>C++ (VM)</dd>
|
||||
<dd style='background-color: #50e150'>Java compiled</dd>
|
||||
<dd style='background-color: #cce880'>Java compiled by C1</dd>
|
||||
<dd style='background-color: #50cccc'>Inlined</dd>
|
||||
<dd style='background-color: #b2e1b2'>Interpreted</dd>
|
||||
</dl>
|
||||
<dl class='frames'>
|
||||
<dt>Allocation profile</dt>
|
||||
<dd style='background-color: #50cccc'>Allocated class</dd>
|
||||
<dd style='background-color: #e17d00'>Allocation outside TLAB</dd>
|
||||
<dt>Lock profile</dt>
|
||||
<dd style='background-color: #50cccc'>Lock class</dd>
|
||||
<dt> </dt>
|
||||
<dt>Search</dt>
|
||||
<dd style='background-color: #ee00ee'>Matches regexp</dd>
|
||||
</dl>
|
||||
<dl class='hotkeys'>
|
||||
<dt>Click frame</dt><dd>Zoom into frame</dd>
|
||||
<dt>Ctrl/Alt+Click</dt><dd>Remove stack</dd>
|
||||
<dt>0</dt><dd>Reset zoom</dd>
|
||||
<dt>I</dt><dd>Invert graph</dd>
|
||||
<dt>Ctrl+F</dt><dd>Search</dd>
|
||||
<dt>N</dt><dd>Next match</dd>
|
||||
<dt>Shift+N</dt><dd>Previous match</dd>
|
||||
<dt>Esc</dt><dd>Cancel search</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<canvas id='canvas'></canvas>
|
||||
<div id='hl'><span></span></div>
|
||||
<p id='status'></p>
|
||||
<p id='match'>Matched: <span id='matchval'></span> <span id='reset' title='Clear'>❌</span></p>
|
||||
<script>
|
||||
// Copyright The async-profiler authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
'use strict';
|
||||
let root, px, pattern;
|
||||
let level0 = 0, left0 = 0, width0 = 0, d = 0;
|
||||
let nav = [], navIndex, matchval;
|
||||
let inverted = false;
|
||||
const U = undefined;
|
||||
const maxdiff = -1;
|
||||
const levels = Array(36);
|
||||
for (let h = 0; h < levels.length; h++) {
|
||||
levels[h] = [];
|
||||
}
|
||||
|
||||
const canvas = document.getElementById('canvas');
|
||||
const c = canvas.getContext('2d');
|
||||
const hl = document.getElementById('hl');
|
||||
const status = document.getElementById('status');
|
||||
|
||||
const canvasWidth = canvas.offsetWidth;
|
||||
const canvasHeight = canvas.offsetHeight;
|
||||
canvas.style.width = canvasWidth + 'px';
|
||||
canvas.width = canvasWidth * (devicePixelRatio || 1);
|
||||
canvas.height = canvasHeight * (devicePixelRatio || 1);
|
||||
if (devicePixelRatio) c.scale(devicePixelRatio, devicePixelRatio);
|
||||
c.font = document.body.style.font;
|
||||
|
||||
const palette = [
|
||||
[0xb2e1b2, 20, 20, 20],
|
||||
[0x50e150, 30, 30, 30],
|
||||
[0x50cccc, 30, 30, 30],
|
||||
[0xe15a5a, 30, 40, 40],
|
||||
[0xc8c83c, 30, 30, 10],
|
||||
[0xe17d00, 30, 30, 0],
|
||||
[0xcce880, 20, 20, 20],
|
||||
];
|
||||
|
||||
function getColor(p) {
|
||||
const v = Math.random();
|
||||
return '#' + (p[0] + ((p[1] * v) << 16 | (p[2] * v) << 8 | (p[3] * v))).toString(16);
|
||||
}
|
||||
|
||||
function getDiffColor(diff) {
|
||||
if (diff === U) return '#ffdd33';
|
||||
if (diff === 0) return '#e0e0e0';
|
||||
const v = Math.round(128 * (maxdiff - Math.abs(diff)) / maxdiff) + 96;
|
||||
return diff > 0 ? 'rgb(255,' + v + ',' + v + ')' : 'rgb(' + v + ',' + v + ',255)';
|
||||
}
|
||||
|
||||
function f(key, level, left, width, inln, c1, int) {
|
||||
levels[level0 = level].push({level, left: left0 += left, width: width0 = width || width0,
|
||||
color: maxdiff >= 0 ? getDiffColor(d) : getColor(palette[key & 7]),
|
||||
title: cpool[key >>> 3],
|
||||
details: (d ? (d > 0 ? ', +' : ', ') + d : '') + (int ? ', int=' + int : '') + (c1 ? ', c1=' + c1 : '') + (inln ? ', inln=' + inln : '')
|
||||
});
|
||||
}
|
||||
|
||||
function u(key, width, inln, c1, int) {
|
||||
f(key, level0 + 1, 0, width, inln, c1, int)
|
||||
}
|
||||
|
||||
function n(key, width, inln, c1, int) {
|
||||
f(key, level0, width0, width, inln, c1, int)
|
||||
}
|
||||
|
||||
function samples(n) {
|
||||
return n === 1 ? '1 sample' : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' samples';
|
||||
}
|
||||
|
||||
function pct(a, b) {
|
||||
return a >= b ? '100' : (100 * a / b).toFixed(2);
|
||||
}
|
||||
|
||||
function findFrame(frames, x) {
|
||||
let left = 0;
|
||||
let right = frames.length - 1;
|
||||
|
||||
while (left <= right) {
|
||||
const mid = (left + right) >>> 1;
|
||||
const f = frames[mid];
|
||||
|
||||
if (f.left > x) {
|
||||
right = mid - 1;
|
||||
} else if (f.left + f.width <= x) {
|
||||
left = mid + 1;
|
||||
} else {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
if (frames[left] && (frames[left].left - x) * px < 0.5) return frames[left];
|
||||
if (frames[right] && (x - (frames[right].left + frames[right].width)) * px < 0.5) return frames[right];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function removeStack(left, width) {
|
||||
for (let h = 0; h < levels.length; h++) {
|
||||
const frames = levels[h], newFrames = [];
|
||||
for (let i = 0; i < frames.length; i++) {
|
||||
const f = frames[i];
|
||||
if (f.left >= left + width) {
|
||||
f.left -= width;
|
||||
} else if (f.left + f.width > left) {
|
||||
if ((f.width -= width) <= 0 && h) continue;
|
||||
}
|
||||
newFrames.push(f);
|
||||
}
|
||||
levels[h] = newFrames;
|
||||
}
|
||||
}
|
||||
|
||||
function search(r) {
|
||||
if (r === true && (r = prompt('Enter regexp to search:', '')) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
pattern = r ? RegExp(r) : undefined;
|
||||
const matched = render(root, nav = []);
|
||||
navIndex = -1;
|
||||
document.getElementById('matchval').textContent = matchval = pct(matched, root.width) + '%';
|
||||
document.getElementById('match').style.display = r ? 'inline-block' : 'none';
|
||||
}
|
||||
|
||||
function render(newRoot, nav) {
|
||||
const bg = getComputedStyle(document.documentElement).getPropertyValue('--bg');
|
||||
|
||||
if (root) {
|
||||
c.fillStyle = bg;
|
||||
c.fillRect(0, 0, canvasWidth, canvasHeight);
|
||||
}
|
||||
|
||||
root = newRoot || levels[0][0];
|
||||
px = canvasWidth / root.width;
|
||||
|
||||
const x0 = root.left;
|
||||
const x1 = x0 + root.width;
|
||||
const marked = [];
|
||||
|
||||
function mark(f) {
|
||||
return marked[f.left] || (marked[f.left] = f);
|
||||
}
|
||||
|
||||
function totalMarked() {
|
||||
let total = 0;
|
||||
let left = 0;
|
||||
Object.keys(marked).sort(function(a, b) { return a - b; }).forEach(function(x) {
|
||||
if (+x >= left) {
|
||||
const m = marked[x];
|
||||
if (nav) nav.push(m);
|
||||
total += m.width;
|
||||
left = +x + m.width;
|
||||
}
|
||||
});
|
||||
return total;
|
||||
}
|
||||
|
||||
function drawFrame(f, y) {
|
||||
if (f.left < x1 && f.left + f.width > x0) {
|
||||
c.fillStyle = pattern && f.title.match(pattern) && mark(f) ? '#ee00ee' : f.color;
|
||||
c.fillRect((f.left - x0) * px, y, f.width * px, 15);
|
||||
|
||||
if (f.width * px >= 21) {
|
||||
const chars = Math.floor(f.width * px / 7);
|
||||
const title = f.title.length <= chars ? f.title : f.title.substring(0, chars - 2) + '..';
|
||||
c.fillStyle = '#000000';
|
||||
c.fillText(title, Math.max(f.left - x0, 0) * px + 3, y + 12, f.width * px - 6);
|
||||
}
|
||||
|
||||
if (f.level < root.level) {
|
||||
c.fillStyle = bg + '80';
|
||||
c.fillRect((f.left - x0) * px, y, f.width * px, 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let h = 0; h < levels.length; h++) {
|
||||
const y = inverted ? h * 16 : canvasHeight - (h + 1) * 16;
|
||||
const frames = levels[h];
|
||||
for (let i = 0; i < frames.length; i++) {
|
||||
drawFrame(frames[i], y);
|
||||
}
|
||||
}
|
||||
|
||||
return totalMarked();
|
||||
}
|
||||
|
||||
function unpack(cpool) {
|
||||
for (let i = 1; i < cpool.length; i++) {
|
||||
cpool[i] = cpool[i - 1].substring(0, cpool[i].charCodeAt(0) - 32) + cpool[i].substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
canvas.onmousemove = function() {
|
||||
const h = Math.floor((inverted ? event.offsetY : (canvasHeight - event.offsetY)) / 16);
|
||||
if (h >= 0 && h < levels.length) {
|
||||
const f = findFrame(levels[h], event.offsetX / px + root.left);
|
||||
if (f) {
|
||||
if (f !== root) getSelection().removeAllRanges();
|
||||
hl.style.left = (Math.max(f.left - root.left, 0) * px + canvas.offsetLeft) + 'px';
|
||||
hl.style.width = (Math.min(f.width, root.width) * px) + 'px';
|
||||
hl.style.top = ((inverted ? h * 16 : canvasHeight - (h + 1) * 16) + canvas.offsetTop) + 'px';
|
||||
hl.firstChild.textContent = f.title;
|
||||
hl.style.display = 'block';
|
||||
canvas.title = f.title + '\n(' + samples(f.width) + f.details + ', ' + pct(f.width, levels[0][0].width) + '%)';
|
||||
canvas.style.cursor = 'pointer';
|
||||
canvas.onclick = function() {
|
||||
if ((event.altKey || event.ctrlKey) && h >= root.level && h > 0) {
|
||||
removeStack(f.left, f.width);
|
||||
root.width > f.width ? render(root) : render();
|
||||
} else if (f !== root) {
|
||||
render(f);
|
||||
}
|
||||
canvas.onmousemove();
|
||||
};
|
||||
status.textContent = 'Function: ' + canvas.title;
|
||||
status.style.display = 'inline-block';
|
||||
return;
|
||||
}
|
||||
}
|
||||
canvas.onmouseout();
|
||||
}
|
||||
|
||||
canvas.onmouseout = function() {
|
||||
hl.style.display = 'none';
|
||||
status.style.display = 'none';
|
||||
canvas.title = '';
|
||||
canvas.style.cursor = '';
|
||||
canvas.onclick = null;
|
||||
}
|
||||
|
||||
canvas.ondblclick = function() {
|
||||
getSelection().selectAllChildren(hl);
|
||||
}
|
||||
|
||||
document.getElementById('inverted').onclick = function() {
|
||||
inverted = !inverted;
|
||||
render();
|
||||
}
|
||||
|
||||
document.getElementById('search').onclick = function() {
|
||||
search(true);
|
||||
}
|
||||
|
||||
document.getElementById('reset').onclick = function() {
|
||||
search(false);
|
||||
}
|
||||
|
||||
document.getElementById('darkmode').onclick = function() {
|
||||
const theme = document.documentElement.classList.toggle('dark') ? 'dark' : 'light';
|
||||
try { localStorage.setItem('flame-theme', theme); } catch (ignored) {}
|
||||
render(root);
|
||||
}
|
||||
|
||||
const btnInfo = document.getElementById('info');
|
||||
const legend = document.getElementById('legend');
|
||||
|
||||
btnInfo.onmouseover = function() {
|
||||
legend.style.left = (btnInfo.offsetLeft + 24) + 'px';
|
||||
legend.style.top = (btnInfo.offsetTop + 24) + 'px';
|
||||
legend.style.display = 'block';
|
||||
}
|
||||
|
||||
btnInfo.onmouseout = function() {
|
||||
legend.style.display = 'none';
|
||||
}
|
||||
|
||||
window.onkeydown = function(event) {
|
||||
if ((event.ctrlKey || event.metaKey) && event.key === 'f') {
|
||||
event.preventDefault();
|
||||
search(true);
|
||||
return false;
|
||||
} else if (event.key === 'Escape') {
|
||||
search(false);
|
||||
} else if ((event.key === 'n' || event.key === 'N') && nav.length > 0) {
|
||||
navIndex = (navIndex + (event.shiftKey ? nav.length - 1 : 1)) % nav.length;
|
||||
render(nav[navIndex]);
|
||||
document.getElementById('matchval').textContent = matchval + ' (' + (navIndex + 1) + ' of ' + nav.length + ')';
|
||||
window.scroll(0, inverted ? root.level * 16 : canvasHeight - (root.level + 1) * 16);
|
||||
canvas.onmousemove();
|
||||
return false;
|
||||
} else if (event.key === 'i') {
|
||||
canvas.onmouseout();
|
||||
document.getElementById('inverted').onclick();
|
||||
return false;
|
||||
} else if (event.key === 'd') {
|
||||
document.getElementById('darkmode').onclick();
|
||||
return false;
|
||||
} else if (event.key === '0') {
|
||||
canvas.onmouseout();
|
||||
root = levels[0][0];
|
||||
search(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const cpool = [
|
||||
'all',
|
||||
' C2Compiler::compile_method',
|
||||
'!ompilation::Compilation',
|
||||
'-compile_java_method',
|
||||
'5method',
|
||||
'-emit_code_body',
|
||||
'&e::Code_Gen',
|
||||
'+mpile',
|
||||
')Optimize',
|
||||
'\'Broker::compiler_thread_loop',
|
||||
'/invoke_compiler_on_method',
|
||||
'\'r::compile_method',
|
||||
'"ntiguousSpace::allocate',
|
||||
' DefNewGeneration::FastEvacuateFollowersClosure::do_void',
|
||||
'2collect',
|
||||
'4py_to_survivor_space',
|
||||
' GenCollectedHeap::collect_generation',
|
||||
'2do_collection',
|
||||
'2satisfy_failed_allocation',
|
||||
'#eration::promote',
|
||||
' InstanceKlass::allocate_objArray',
|
||||
'"terpreterRuntime::anewarray',
|
||||
' JVM_ArrayCopy',
|
||||
'!avaThread::run',
|
||||
'$_sun_nio_ch_FileDispatcherImpl_read0',
|
||||
' Matcher::match',
|
||||
'!emAllocator::allocate',
|
||||
' ObjArrayAllocator::initialize',
|
||||
'!ffsetTableContigSpace::allocate',
|
||||
' Parse::Parse',
|
||||
'\'do_all_blocks',
|
||||
'*call',
|
||||
'*one_block',
|
||||
'/ytecode',
|
||||
'%Generator::generate',
|
||||
'!haseCFG::do_global_code_motion',
|
||||
'*global_code_motion',
|
||||
'*schedule_late',
|
||||
'4ocal',
|
||||
'&haitin::Register_Allocate',
|
||||
'.Split',
|
||||
'.build_ifg_physical',
|
||||
'.elide_copy',
|
||||
'.interfere_with_live',
|
||||
'.merge_multidefs',
|
||||
'.post_allocate_copy_removal',
|
||||
'%IdealLoop::Dominators',
|
||||
'0build_and_optimize',
|
||||
'6loop_early',
|
||||
';late',
|
||||
';tree',
|
||||
'0optimize',
|
||||
'0remix_address_expressions',
|
||||
'0split_if_with_blocks',
|
||||
'D_post',
|
||||
'Fre',
|
||||
'&terGVN::optimize',
|
||||
'.subsume_node',
|
||||
'.transform_old',
|
||||
'%Live::add_liveout',
|
||||
'+compute',
|
||||
'%MacroExpand::expand_macro_nodes',
|
||||
'!redictedCallGenerator::generate',
|
||||
' TenuredGeneration::allocate',
|
||||
'!hread::call_run',
|
||||
' VMThread::evaluate_operation',
|
||||
'*inner_execute',
|
||||
'*run',
|
||||
'"_GenCollectForAllocation::doit',
|
||||
'#Operation::evaluate',
|
||||
' __GI_read',
|
||||
'"handle_mm_fault',
|
||||
'"memcpy_sse2_unaligned_erms',
|
||||
'%set_avx2_unaligned_erms',
|
||||
' aci_CopyRight',
|
||||
'!sm_exc_page_fault',
|
||||
' clear_huge_page',
|
||||
'&page_erms',
|
||||
'&subpage',
|
||||
'"one3',
|
||||
'!opy_page_to_iter',
|
||||
'%user_enhanced_fast_string',
|
||||
' demo8/FileConverter$$Lambda$3.0x00007ffab9001000.apply',
|
||||
'<4.0x00007ffab9001240.applyAsInt',
|
||||
'4Entry.<init>',
|
||||
':equals',
|
||||
':hashCode',
|
||||
'3.convertFile',
|
||||
';List',
|
||||
'4main',
|
||||
'4readInput',
|
||||
'4saveResult',
|
||||
'!o_huge_pmd_anonymous_page',
|
||||
'#syscall_64',
|
||||
'#user_addr_fault',
|
||||
' entry_SYSCALL_64_after_hwframe',
|
||||
'!xc_page_fault',
|
||||
' filemap_read',
|
||||
' handle_mm_fault',
|
||||
' java/io/BufferedReader.fill',
|
||||
'7readLine',
|
||||
')yteArrayOutputStream.ensureCapacity',
|
||||
'>toByteArray',
|
||||
'>write',
|
||||
'(DataOutputStream.write',
|
||||
'>Int',
|
||||
'>UTF',
|
||||
'(InputStreamReader.read',
|
||||
'%lang/Integer.parseInt',
|
||||
'*String.<init>',
|
||||
'1decodeASCII',
|
||||
'1hashCode',
|
||||
'1length',
|
||||
'1substring',
|
||||
'0Latin1.hashCode',
|
||||
'7newString',
|
||||
'0UTF16.compress',
|
||||
'+ystem$2.decodeASCII',
|
||||
'0.arraycopy',
|
||||
'*ThreadLocal.get',
|
||||
'%nio/charset/CharsetDecoder.decode',
|
||||
')file/Files.readAllLines',
|
||||
'%util/ArrayList$ArrayListSpliterator.tryAdvance',
|
||||
'3.add',
|
||||
'4grow',
|
||||
'4sort',
|
||||
'/s.copyOf',
|
||||
'7Range',
|
||||
'1sort',
|
||||
'*Comparator$$Lambda$5.0x00007ffab90494b0.compare',
|
||||
'4.lambda$comparingInt$7b0bb60$1',
|
||||
'*HashMap$Node.<init>',
|
||||
'1.hash',
|
||||
'2newNode',
|
||||
'2put',
|
||||
'5Val',
|
||||
'2resize',
|
||||
'.Set.add',
|
||||
'*TimSort.binarySort',
|
||||
'2mergeAt',
|
||||
'7Collapse',
|
||||
'7ForceCollapse',
|
||||
'7Hi',
|
||||
'7Lo',
|
||||
'2sort',
|
||||
'*stream/AbstractPipeline.copyInto',
|
||||
'JWithCancel',
|
||||
'Bevaluate',
|
||||
'BwrapAndCopyInto',
|
||||
'1Collectors$$Lambda$7.0x00007ffab904a268.accept',
|
||||
'1DistinctOps$1$2.accept',
|
||||
'Aend',
|
||||
'1ReduceOps$3ReducingSink.accept',
|
||||
';ReduceOp.evaluateSequential',
|
||||
'3ferencePipeline$3$1.accept',
|
||||
'B.collect',
|
||||
'CforEachWithCancel',
|
||||
'1Sink$ChainedReference.end',
|
||||
'2liceOps$1$1.accept',
|
||||
'2ortedOps$RefSortingSink.accept',
|
||||
'Jend',
|
||||
'!long_disjoint_arraycopy',
|
||||
' ksys_read',
|
||||
' new_sync_read',
|
||||
' oop_arraycopy',
|
||||
' start_thread',
|
||||
'!un/nio/ch/ChannelInputStream.read',
|
||||
'+FileChannelImpl.read',
|
||||
'/DispatcherImpl.read',
|
||||
'B0',
|
||||
'+IOUtil.read',
|
||||
'6IntoNativeBuffer',
|
||||
'+Util.getTemporaryDirectBuffer',
|
||||
')s/StreamDecoder.implRead',
|
||||
'9read',
|
||||
'=Bytes',
|
||||
'+UTF_8$Decoder.decodeArrayLoop',
|
||||
'?Loop',
|
||||
' thread_native_entry',
|
||||
' vfs_read',
|
||||
'!oid ContiguousSpace::oop_since_save_marks_iterate<DefNewScanClosure>',
|
||||
'%OopOopIterateDispatch<DefNewScanClosure>::Table::oop_oop_iterate<InstanceKlass, narrowOop>',
|
||||
'fObjArrayKlass, narrowOop>',
|
||||
'AYoungerGenClosure>::Table::oop_oop_iterate<InstanceKlass, narrowOop>'
|
||||
];
|
||||
unpack(cpool);
|
||||
|
||||
n(3,584)
|
||||
f(635,1,1,178)
|
||||
u(1323)
|
||||
u(1428)
|
||||
u(516)
|
||||
u(188,70)
|
||||
u(76)
|
||||
f(84,7,2,68)
|
||||
f(12,8,2,63)
|
||||
u(60)
|
||||
u(52,36)
|
||||
f(204,11,3,2)
|
||||
n(284,7)
|
||||
u(292)
|
||||
f(300,13,1,2)
|
||||
n(308,4)
|
||||
f(316,11,4,24)
|
||||
f(324,12,6,2)
|
||||
n(332,9)
|
||||
f(348,13,5,4)
|
||||
f(356,12,4,2)
|
||||
n(364)
|
||||
u(340)
|
||||
f(484,12,2,3)
|
||||
u(476)
|
||||
f(68,10,3,23)
|
||||
f(412,11,2,16)
|
||||
f(380,12,1,15)
|
||||
f(372,13,1,3)
|
||||
n(388,2)
|
||||
n(396)
|
||||
n(404)
|
||||
n(428,5)
|
||||
f(436,14,1,2)
|
||||
n(444)
|
||||
u(420)
|
||||
f(452,11,2,3)
|
||||
u(468)
|
||||
f(460,13,1,2)
|
||||
f(492,11,2)
|
||||
u(452)
|
||||
u(468)
|
||||
f(276,10,2,4)
|
||||
u(236)
|
||||
u(244)
|
||||
u(260)
|
||||
u(268)
|
||||
u(252)
|
||||
f(500,16,1,3)
|
||||
f(500,17,1,2)
|
||||
u(276)
|
||||
u(236)
|
||||
u(244)
|
||||
u(260)
|
||||
u(268)
|
||||
u(252)
|
||||
f(92,8,2,3)
|
||||
u(20)
|
||||
u(36)
|
||||
u(28)
|
||||
f(44,12,1,2)
|
||||
f(540,5,2,108)
|
||||
u(532)
|
||||
u(524)
|
||||
u(556)
|
||||
u(548)
|
||||
u(148)
|
||||
u(140)
|
||||
u(132)
|
||||
u(116)
|
||||
u(108)
|
||||
f(1444,15,12,50)
|
||||
f(1452,16,1,22)
|
||||
f(124,17,2,20)
|
||||
f(156,18,10,8)
|
||||
f(228,19,2,2)
|
||||
n(508)
|
||||
n(605)
|
||||
u(773)
|
||||
u(757)
|
||||
u(789)
|
||||
u(573)
|
||||
u(741)
|
||||
u(613)
|
||||
u(629)
|
||||
u(621)
|
||||
f(579,18,2)
|
||||
f(1460,16,2,27)
|
||||
f(124,17,11,16)
|
||||
f(156,18,13,3)
|
||||
u(605)
|
||||
u(773)
|
||||
u(757)
|
||||
u(789)
|
||||
u(573)
|
||||
u(741)
|
||||
u(613)
|
||||
u(629)
|
||||
u(621)
|
||||
f(1468,15,3,46)
|
||||
f(124,16,19,27)
|
||||
f(100,17,10,4)
|
||||
n(156,13)
|
||||
f(228,18,1,2)
|
||||
n(605,10)
|
||||
u(773)
|
||||
u(757)
|
||||
u(789)
|
||||
u(573)
|
||||
u(741)
|
||||
u(613)
|
||||
u(629)
|
||||
f(621,26,1,9)
|
||||
f(713,1,9,405)
|
||||
u(697)
|
||||
u(705,229)
|
||||
f(1241,4,1,228)
|
||||
u(1177)
|
||||
u(1225)
|
||||
u(1185)
|
||||
u(1161)
|
||||
u(1169)
|
||||
u(1249,107)
|
||||
f(977,11,2,105)
|
||||
f(1233,12,2,103,2,0,0)
|
||||
u(657,13)
|
||||
f(674,14,4,9,8,0,0)
|
||||
f(866,15,1,3)
|
||||
u(866)
|
||||
f(906,15,3,5,4,0,0)
|
||||
u(906,3,2,0,0)
|
||||
u(922)
|
||||
f(1018,18,1,2)
|
||||
f(922,16,2)
|
||||
f(1201,13,2,90,2,0,0)
|
||||
u(1098,87,57,0,0)
|
||||
u(1074,87,59,0,0)
|
||||
u(1057,4)
|
||||
u(689)
|
||||
f(890,18,1,3)
|
||||
f(914,19,1,2)
|
||||
f(1082,16,2,83,59,1,0)
|
||||
f(682,17,41,2)
|
||||
n(1066,17)
|
||||
u(1050)
|
||||
f(1089,17,17,23,0,0,2)
|
||||
f(1265,14,23,3)
|
||||
u(1273)
|
||||
u(985)
|
||||
u(985)
|
||||
u(993)
|
||||
u(993)
|
||||
u(1009)
|
||||
u(1008)
|
||||
u(172)
|
||||
u(164)
|
||||
u(212)
|
||||
u(220)
|
||||
u(587)
|
||||
u(605)
|
||||
u(773)
|
||||
u(757)
|
||||
u(789)
|
||||
u(573)
|
||||
u(741)
|
||||
u(613)
|
||||
u(629)
|
||||
u(621)
|
||||
f(1257,10,3,121)
|
||||
u(1209)
|
||||
u(1257)
|
||||
u(1281)
|
||||
f(1001,14,1,117)
|
||||
u(1025)
|
||||
u(1153)
|
||||
u(1105,21,0,1,0)
|
||||
f(1034,18,13,4)
|
||||
u(1042)
|
||||
f(666,20,1,3)
|
||||
f(1315,18,3,4)
|
||||
f(1121,17,4,73)
|
||||
u(1113)
|
||||
u(1137,16)
|
||||
f(1034,20,14,2,1,0,0)
|
||||
u(1042)
|
||||
f(1145,19,2,57,0,2,1)
|
||||
f(1033,20,54,3)
|
||||
u(1042)
|
||||
u(666)
|
||||
f(1129,17,3,23)
|
||||
u(1113)
|
||||
u(1137)
|
||||
f(1033,20,18,5,1,0,0)
|
||||
u(1042)
|
||||
u(666)
|
||||
f(1218,14,5,3,1,0,0)
|
||||
u(1194,3,1,0,0)
|
||||
u(986,3,1,0,0)
|
||||
f(985,17,1,2)
|
||||
u(993)
|
||||
u(993)
|
||||
u(1009)
|
||||
u(1008)
|
||||
u(172)
|
||||
u(164)
|
||||
u(212)
|
||||
u(220)
|
||||
f(721,3,2,107)
|
||||
u(969)
|
||||
u(969)
|
||||
f(801,6,4,97)
|
||||
u(801,97,0,0,1)
|
||||
f(793,8,77,14)
|
||||
u(857,14,1,0,0)
|
||||
u(1393,14,1,0,0)
|
||||
f(1385,11,1,13)
|
||||
u(961,3)
|
||||
u(1417)
|
||||
u(1409)
|
||||
u(938)
|
||||
u(882)
|
||||
f(1401,12,3,10,2,0,0)
|
||||
u(1329,10,3,0,0)
|
||||
u(1329,10,3,0,0)
|
||||
u(1329,10,3,0,0)
|
||||
u(1337,10,3,1,0)
|
||||
f(1361,17,2,8,2,0,0)
|
||||
u(1361,8,2,0,0)
|
||||
u(1369,6)
|
||||
u(1345)
|
||||
u(1353)
|
||||
u(195)
|
||||
u(563)
|
||||
u(765)
|
||||
u(749)
|
||||
f(1301,26,1,5)
|
||||
u(1437)
|
||||
f(1309,28,1,4)
|
||||
u(781)
|
||||
f(645,30,1,3)
|
||||
u(653)
|
||||
f(1378,19,3,2)
|
||||
u(954)
|
||||
u(1291)
|
||||
f(874,8,2,6,5,0,0)
|
||||
u(874,6,5,0,0)
|
||||
u(930,6,5,0,0)
|
||||
f(985,6,6)
|
||||
u(985)
|
||||
u(993)
|
||||
u(993)
|
||||
u(1009)
|
||||
u(1008,6,0,1,4)
|
||||
f(172,12,2,4)
|
||||
u(164)
|
||||
u(212)
|
||||
u(220)
|
||||
u(587)
|
||||
f(605,17,1,3)
|
||||
u(773)
|
||||
u(757)
|
||||
u(789)
|
||||
u(573)
|
||||
u(741)
|
||||
u(613)
|
||||
u(629)
|
||||
u(621)
|
||||
f(729,3,3,69,0,2,1)
|
||||
f(817,4,21,2)
|
||||
u(1009)
|
||||
u(945)
|
||||
u(179)
|
||||
u(595)
|
||||
f(842,4,2,8,5,0,0)
|
||||
f(826,5,1,7,5,0,0)
|
||||
f(809,6,5,2)
|
||||
u(1008,2,0,0,1)
|
||||
f(849,4,2,38)
|
||||
u(849,38,0,0,2)
|
||||
f(834,6,12,23,21,0,0)
|
||||
f(826,7,6,17,15,1,0)
|
||||
f(898,6,17,3)
|
||||
|
||||
search();
|
||||
</script></body></html>
|
||||
|
Before Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 135 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 134 KiB |
|
Before Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 236 KiB |
|
Before Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 271 KiB |
|
Before Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 19 KiB |
132
.clang-tidy
@@ -1,132 +0,0 @@
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-assert-side-effect,
|
||||
bugprone-bool-pointer-implicit-conversion,
|
||||
bugprone-chained-comparison,
|
||||
bugprone-copy-constructor-init,
|
||||
bugprone-incorrect-roundings,
|
||||
bugprone-infinite-loop,
|
||||
bugprone-integer-division,
|
||||
bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||
bugprone-misplaced-pointer-arithmetic-in-alloc,
|
||||
bugprone-misplaced-widening-cast,
|
||||
bugprone-non-zero-enum-to-bool-conversion,
|
||||
bugprone-pointer-arithmetic-on-polymorphic-object,
|
||||
bugprone-posix-return,
|
||||
bugprone-redundant-branch-condition,
|
||||
bugprone-return-const-ref-from-parameter,
|
||||
bugprone-sizeof-container,
|
||||
bugprone-standalone-empty,
|
||||
bugprone-string-literal-with-embedded-nul,
|
||||
bugprone-string-integer-assignment,
|
||||
bugprone-suspicious-include,
|
||||
bugprone-suspicious-memset-usage,
|
||||
bugprone-suspicious-missing-comma,
|
||||
bugprone-suspicious-realloc-usage,
|
||||
bugprone-suspicious-semicolon,
|
||||
bugprone-suspicious-string-compare,
|
||||
bugprone-swapped-arguments,
|
||||
bugprone-terminating-continue,
|
||||
bugprone-too-small-loop-variable,
|
||||
bugprone-undefined-memory-manipulation,
|
||||
bugprone-undelegated-constructor,
|
||||
bugprone-unhandled-self-assignment,
|
||||
bugprone-unused-raii,
|
||||
bugprone-unused-return-value,
|
||||
bugprone-use-after-move,
|
||||
bugprone-virtual-near-miss,
|
||||
cppcoreguidelines-misleading-capture-default-by-value,
|
||||
cppcoreguidelines-pro-type-const-cast,
|
||||
cppcoreguidelines-slicing,
|
||||
cert-oop58-cpp,
|
||||
cert-flp30-c,
|
||||
misc-confusable-identifiers,
|
||||
misc-definitions-in-headers,
|
||||
misc-header-include-cycle,
|
||||
misc-misplaced-const,
|
||||
misc-non-copyable-objects,
|
||||
misc-redundant-expression,
|
||||
misc-static-assert,
|
||||
misc-unconventional-assign-operator,
|
||||
misc-unused-alias-decls,
|
||||
performance-avoid-endl,
|
||||
performance-faster-string-find,
|
||||
performance-for-range-copy,
|
||||
performance-implicit-conversion-in-loop,
|
||||
performance-inefficient-algorithm,
|
||||
performance-inefficient-string-concatenation,
|
||||
performance-inefficient-vector-operation,
|
||||
performance-move-const-arg,
|
||||
performance-move-constructor-init,
|
||||
performance-no-automatic-move,
|
||||
performance-noexcept-destructor,
|
||||
performance-noexcept-move-constructor,
|
||||
performance-noexcept-swap,
|
||||
performance-trivially-destructible,
|
||||
performance-type-promotion-in-math-fn,
|
||||
performance-unnecessary-copy-initialization,
|
||||
performance-unnecessary-value-param,
|
||||
readability-avoid-return-with-void-value,
|
||||
readability-avoid-unconditional-preprocessor-if,
|
||||
readability-const-return-type,
|
||||
readability-container-contains,
|
||||
readability-container-data-pointer,
|
||||
readability-container-size-empty,
|
||||
readability-delete-null-pointer,
|
||||
readability-duplicate-include,
|
||||
readability-function-size,
|
||||
readability-identifier-naming,
|
||||
readability-misleading-indentation,
|
||||
readability-misplaced-array-index,
|
||||
readability-named-parameter,
|
||||
readability-operators-representation,
|
||||
readability-qualified-auto,
|
||||
readability-redundant-access-specifiers,
|
||||
readability-redundant-casting,
|
||||
readability-redundant-control-flow,
|
||||
readability-redundant-declaration,
|
||||
readability-redundant-function-ptr-dereference,
|
||||
readability-redundant-preprocessor,
|
||||
readability-redundant-string-cstr,
|
||||
readability-redundant-string-init,
|
||||
readability-reference-to-constructed-temporary,
|
||||
readability-simplify-subscript-expr,
|
||||
readability-static-accessed-through-instance,
|
||||
readability-static-definition-in-anonymous-namespace,
|
||||
readability-string-compare,
|
||||
readability-uniqueptr-delete-release,
|
||||
readability-use-anyofallof,
|
||||
# TODO: Consider these
|
||||
# bugprone-switch-missing-default-case
|
||||
# bugprone-multi-level-implicit-pointer-conversion
|
||||
# bugprone-branch-clone
|
||||
# cert-err33-c
|
||||
# cppcoreguidelines-narrowing-conversions
|
||||
# cppcoreguidelines-init-variables
|
||||
# cppcoreguidelines-explicit-virtual-functions
|
||||
# cppcoreguidelines-special-member-functions
|
||||
# llvm-include-order
|
||||
# misc-const-correctness
|
||||
# modernize-*
|
||||
# performance-enum-size
|
||||
# readability-function-cognitive-complexity
|
||||
# readability-else-after-return
|
||||
# readability-convert-member-functions-to-static
|
||||
# readability-math-missing-parentheses
|
||||
# readability-non-const-parameter
|
||||
# readability-redundant-member-init
|
||||
# readability-simplify-boolean-expr
|
||||
# misc-include-cleaner
|
||||
# google-explicit-constructor
|
||||
# cppcoreguidelines-virtual-class-destructor
|
||||
# readability-make-member-function-const
|
||||
HeaderFilterRegex: "*"
|
||||
CheckOptions:
|
||||
- key: readability-identifier-naming.LocalVariableCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.LocalVariableIgnoredRegexp
|
||||
value: '(KB|Thread|setDaemon|klassOop|nVMs|loadLibrary|getTicksFrequency|counterTime|System|M|R|s_)'
|
||||
- key: readability-identifier-naming.PrivateMemberPrefix
|
||||
value: _
|
||||
- key: readability-identifier-naming.ConstexprVariableCase
|
||||
value: UPPER_CASE
|
||||
51
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
@@ -1,51 +0,0 @@
|
||||
---
|
||||
name: "🐛 Bug Report"
|
||||
description: Report a bug
|
||||
title: "(short issue description)"
|
||||
assignees: []
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: What is the problem? A clear and concise description of the bug.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: behavior
|
||||
attributes:
|
||||
label: Expected vs. actual behavior
|
||||
description: |
|
||||
What did you expect to happen? What happened instead?
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Reproduction Steps
|
||||
description: |
|
||||
Step-by-step instructions how to reproduce the issue. Attach a code sample if available.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional Information/Context
|
||||
description: |
|
||||
Anything else that might be relevant for troubleshooting this bug: profiles, screenshots, etc.
|
||||
validations:
|
||||
required: false
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Async-profiler version
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: environment
|
||||
attributes:
|
||||
label: Environment details
|
||||
description: |
|
||||
OS name and version, JDK version, CPU architecture. Is an application running in a container?
|
||||
validations:
|
||||
required: false
|
||||
6
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,6 +0,0 @@
|
||||
---
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 💬 General Question
|
||||
url: https://github.com/async-profiler/async-profiler/discussions
|
||||
about: Please ask and answer questions as a discussion thread
|
||||
14
.github/ISSUE_TEMPLATE/documentation.yml
vendored
@@ -1,14 +0,0 @@
|
||||
---
|
||||
name: "📕 Documentation Issue"
|
||||
description: Report an issue in the profiler documentation
|
||||
title: "(short issue description)"
|
||||
labels: [documentation]
|
||||
assignees: []
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the issue
|
||||
description: A clear and concise description of the issue.
|
||||
validations:
|
||||
required: true
|
||||
39
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -1,39 +0,0 @@
|
||||
---
|
||||
name: 🚀 Feature Request
|
||||
description: Suggest an idea for this project
|
||||
title: "(short issue description)"
|
||||
labels: [enhancement]
|
||||
assignees: []
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the feature
|
||||
description: A clear and concise description of the feature you are proposing.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: use-case
|
||||
attributes:
|
||||
label: Use Case
|
||||
description: |
|
||||
Why do you need this feature? For example: "I'm always frustrated when..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Proposed Solution
|
||||
description: |
|
||||
Suggest how to implement the addition or change. Provide references to alternative solutions, if any.
|
||||
validations:
|
||||
required: false
|
||||
- type: checkboxes
|
||||
id: ack
|
||||
attributes:
|
||||
label: Acknowledgements
|
||||
options:
|
||||
- label: I may be able to implement this feature request
|
||||
required: false
|
||||
- label: This feature might incur a breaking change
|
||||
required: false
|
||||
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,17 +0,0 @@
|
||||
### Description
|
||||
|
||||
|
||||
### Related issues
|
||||
|
||||
|
||||
### Motivation and context
|
||||
|
||||
|
||||
### How has this been tested?
|
||||
|
||||
|
||||
---
|
||||
|
||||
By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].
|
||||
|
||||
[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
|
||||
83
.github/workflows/build.yml
vendored
@@ -1,83 +0,0 @@
|
||||
name: build-template
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
platform:
|
||||
type: string
|
||||
required: true
|
||||
runner:
|
||||
type: string
|
||||
required: true
|
||||
container-image:
|
||||
type: string
|
||||
required: false
|
||||
|
||||
env:
|
||||
build_java_distribution: corretto
|
||||
build_java_version: 11
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ inputs.runner }}
|
||||
container:
|
||||
image: ${{ inputs.container-image && format('public.ecr.aws/async-profiler/asprof-builder-{0}', inputs.container-image) || '' }}
|
||||
name: "build and unit test (${{ inputs.platform }})"
|
||||
steps:
|
||||
- name: Run container setup
|
||||
if: inputs.container-image != ''
|
||||
run: "[ ! -f /root/setup.sh ] || /root/setup.sh"
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: ${{ env.build_java_distribution }}
|
||||
java-version: ${{ env.build_java_version }}
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
- name: Build and unit test
|
||||
id: build
|
||||
run: |
|
||||
set -x
|
||||
HASH=${GITHUB_SHA:0:7}
|
||||
case "${{ inputs.platform }}" in
|
||||
macos*)
|
||||
brew install gcovr
|
||||
make COMMIT_TAG=$HASH FAT_BINARY=true release coverage -j
|
||||
;;
|
||||
*)
|
||||
make COMMIT_TAG=$HASH CC=/usr/local/musl/bin/musl-gcc release coverage -j
|
||||
echo "debug_archive=$(find . -type f -name "async-profiler-*-debug*" -exec basename {} \;)" >> $GITHUB_OUTPUT
|
||||
;;
|
||||
esac
|
||||
echo "archive=$(find . -type f -name "async-profiler-*" -not -name "*-debug*" -exec basename {} \;)" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
env:
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
- name: Set artifact name
|
||||
id: set_artifact_name
|
||||
run: echo "artifact_name=async-profiler-${{ inputs.platform }}-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
env:
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
- name: Upload binaries
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.set_artifact_name.outputs.artifact_name }}
|
||||
path: ${{ steps.build.outputs.archive }}
|
||||
if-no-files-found: error
|
||||
- name: Upload debug info
|
||||
uses: actions/upload-artifact@v4
|
||||
if: inputs.platform != 'macos'
|
||||
with:
|
||||
name: ${{ steps.set_artifact_name.outputs.artifact_name }}-debug
|
||||
path: ${{ steps.build.outputs.debug_archive }}
|
||||
if-no-files-found: error
|
||||
- name: Upload coverage report
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-coverage-${{ inputs.platform }}
|
||||
path: build/test/coverage/
|
||||
if-no-files-found: error
|
||||
48
.github/workflows/clang-tidy-review.yml
vendored
@@ -1,48 +0,0 @@
|
||||
name: clang-tidy-review
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- code-check
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
clang-tidy-results:
|
||||
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: "public.ecr.aws/async-profiler/asprof-code-check:latest"
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
actions: read
|
||||
steps:
|
||||
- name: Download code-check artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: code-check-artifacts
|
||||
path: /tmp/code-check-artifacts/
|
||||
- name: Read PR information
|
||||
id: pr_info
|
||||
run: |
|
||||
cd /tmp/code-check-artifacts
|
||||
echo "pr_id=$(cat pr-id.txt)" >> "$GITHUB_OUTPUT"
|
||||
echo "pr_head_repo=$(cat pr-head-repo.txt)" >> "$GITHUB_OUTPUT"
|
||||
echo "pr_head_sha=$(cat pr-head-sha.txt)" >> "$GITHUB_OUTPUT"
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ steps.pr_info.outputs.pr_head_repo }}
|
||||
ref: ${{ steps.pr_info.outputs.pr_head_sha }}
|
||||
persist-credentials: false
|
||||
- name: Run clang-tidy-pr-comments action
|
||||
uses: platisd/clang-tidy-pr-comments@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
clang_tidy_fixes: /tmp/code-check-artifacts/clang-tidy-fixes.yml
|
||||
pull_request_id: ${{ steps.pr_info.outputs.pr_id }}
|
||||
python_path: python
|
||||
auto_resolve_conversations: true
|
||||
suggestions_per_comment: 100
|
||||
49
.github/workflows/code-check.yml
vendored
@@ -1,49 +0,0 @@
|
||||
name: code-check
|
||||
|
||||
on:
|
||||
- pull_request
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
cpp-lint:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: "public.ecr.aws/async-profiler/asprof-code-check:latest"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
- name: Mark repo as safe for Git
|
||||
run: git config --global --add safe.directory $GITHUB_WORKSPACE
|
||||
- name: Fetch base branch
|
||||
run: |
|
||||
git remote add upstream "https://github.com/${{ github.event.pull_request.base.repo.full_name }}"
|
||||
git fetch --no-tags --no-recurse-submodules upstream "${{ github.event.pull_request.base.ref }}"
|
||||
- name: Create artifacts directory
|
||||
run: |
|
||||
mkdir code-check-artifacts/
|
||||
echo "${{ github.event.number }}" > code-check-artifacts/pull-request-id.txt
|
||||
- name: Run clang-tidy
|
||||
run: |
|
||||
set pipefail
|
||||
make cpp-lint-diff \
|
||||
DIFF_BASE="$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")" \
|
||||
CLANG_TIDY_ARGS_EXTRA="-export-fixes code-check-artifacts/clang-tidy-fixes.yml"
|
||||
shell: bash
|
||||
- name: Save PR information
|
||||
run: |
|
||||
echo "${{ github.event.number }}" > code-check-artifacts/pr-id.txt
|
||||
echo "${{ github.event.pull_request.head.repo.full_name }}" > code-check-artifacts/pr-head-repo.txt
|
||||
echo "${{ github.event.pull_request.head.sha }}" > code-check-artifacts/pr-head-sha.txt
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: code-check-artifacts
|
||||
path: code-check-artifacts/
|
||||
28
.github/workflows/compare-binary-sizes.yml
vendored
@@ -1,28 +0,0 @@
|
||||
name: compare-binary-sizes
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [CI]
|
||||
types: [completed]
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
actions: read
|
||||
env:
|
||||
GH_TOKEN: "${{ github.token }}"
|
||||
REPO: "${{ github.repository }}"
|
||||
PR_SHA: "${{ github.event.workflow_run.head_sha }}"
|
||||
jobs:
|
||||
compare:
|
||||
if: ${{ github.event.workflow_run.event == 'pull_request' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: |
|
||||
gh api "repos/${REPO}/contents/scripts/compare-binary-sizes.sh" -H 'Accept: application/vnd.github.raw' > compare.sh
|
||||
read pr base_sha < <(gh api "repos/${REPO}/commits/${PR_SHA}/pulls" --jq '.[0] | "\(.number) \(.base.sha)"')
|
||||
function find-archive() { find "${1}" -type f \( -name "async-profiler-*${2}.tar.gz" -o -name "async-profiler-*${2}.zip" \) ! -name '*-debug*' | head -n1; }
|
||||
for p in linux-x64 linux-arm64 macos; do
|
||||
gh run download -R "${REPO}" -n "async-profiler-${p}-${base_sha:0:7}" -D "base/${p}" 2>/dev/null || continue
|
||||
gh run download -R "${REPO}" -n "async-profiler-${p}-${PR_SHA:0:7}" -D "pr/${p}" 2>/dev/null || continue
|
||||
bash compare.sh "$(find-archive "base/${p}" "${p}")" "$(find-archive "pr/${p}" "${p}")" >> report.md
|
||||
done
|
||||
gh pr comment "${pr}" -R "${REPO}" --body-file report.md --edit-last --create-if-none
|
||||
21
.github/workflows/cpp.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: C++ CI
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2.1.0
|
||||
with:
|
||||
distribution: "adopt"
|
||||
java-version: "11"
|
||||
- run: sudo sysctl kernel.perf_event_paranoid=1
|
||||
- run: make
|
||||
- run: make test
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
path: build/
|
||||
119
.github/workflows/integ.yml
vendored
@@ -1,119 +0,0 @@
|
||||
name: integration-test-template
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
test-platform:
|
||||
type: string
|
||||
required: true
|
||||
platform:
|
||||
type: string
|
||||
required: true
|
||||
architecture:
|
||||
type: string
|
||||
required: false
|
||||
java-version:
|
||||
type: string
|
||||
required: true
|
||||
java-distribution:
|
||||
type: string
|
||||
required: false
|
||||
default: "corretto"
|
||||
runner:
|
||||
type: string
|
||||
required: true
|
||||
container-image:
|
||||
type: string
|
||||
required: false
|
||||
container-volumes:
|
||||
type: string
|
||||
required: false
|
||||
use-builtin-jdk:
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
retry-count:
|
||||
type: number
|
||||
required: false
|
||||
default: 0
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
integration-test:
|
||||
runs-on: ${{ inputs.runner }}
|
||||
container:
|
||||
image: ${{ inputs.container-image && format('public.ecr.aws/async-profiler/asprof-builder-{0}', inputs.container-image) || '' }}
|
||||
options: --privileged
|
||||
volumes: ${{ fromJSON(inputs.container-volumes || '[]') }}
|
||||
name: "${{ inputs.test-platform }}, ${{ inputs.java-distribution }} ${{ inputs.java-version }}"
|
||||
steps:
|
||||
- name: Run container setup
|
||||
if: inputs.container-image != ''
|
||||
run: "[ ! -f /root/setup.sh ] || /root/setup.sh"
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
# https://github.com/actions/setup-java/issues/678#issuecomment-2446279753
|
||||
if: ${{ !inputs.use-builtin-jdk }}
|
||||
with:
|
||||
distribution: ${{ inputs.java-distribution }}
|
||||
java-version: ${{ inputs.java-version }}
|
||||
architecture: ${{ inputs.architecture }}
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
- name: Set variables
|
||||
id: set_variables
|
||||
run: |
|
||||
echo "short_sha=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
|
||||
echo "artifact_name=async-profiler-${{ inputs.platform }}-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
env:
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
- name: Download async-profiler release artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.set_variables.outputs.artifact_name }}
|
||||
path: async_profiler_release
|
||||
- name: Download async-profiler JAR artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: async-profiler-jars
|
||||
path: jar_artifacts
|
||||
- name: Extract async-profiler artifact
|
||||
id: extract_artifact
|
||||
run: |
|
||||
release_archive=$(basename $(find async_profiler_release -type f -iname "async-profiler-*" ))
|
||||
case "${{ inputs.runner }}" in
|
||||
macos*)
|
||||
unzip async_profiler_release/$release_archive
|
||||
;;
|
||||
*)
|
||||
tar xvf async_profiler_release/$release_archive
|
||||
;;
|
||||
esac
|
||||
echo "jars_directory=jar_artifacts" >> $GITHUB_OUTPUT
|
||||
echo "release_directory=$(basename $(find . -type d -iname "async-profiler-*" ))" >> $GITHUB_OUTPUT
|
||||
- name: Download Protobuf Java runtime
|
||||
run: |
|
||||
mkdir -p test/deps
|
||||
cd test/deps
|
||||
curl -L -O "https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/$PB_JAVA_VERSION/protobuf-java-$PB_JAVA_VERSION.jar"
|
||||
env:
|
||||
PB_JAVA_VERSION: "4.31.1"
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
mkdir -p build/jar
|
||||
cp ${{ steps.extract_artifact.outputs.jars_directory }}/* build/jar
|
||||
make build/test.jar
|
||||
cp -r ${{ steps.extract_artifact.outputs.release_directory }}/bin build
|
||||
cp -r ${{ steps.extract_artifact.outputs.release_directory }}/lib build
|
||||
make test-java TEST_THREADS=2 RETRY_COUNT=${{ inputs.retry-count }} -j
|
||||
- name: Upload integration test logs
|
||||
uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: integration-test-logs-${{ inputs.test-platform }}-${{ inputs.java-version }}-${{ steps.set_variables.outputs.short_sha }}
|
||||
path: |
|
||||
build/test/logs/
|
||||
hs_err*.log
|
||||
59
.github/workflows/linters.yml
vendored
@@ -1,59 +0,0 @@
|
||||
name: lint
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
license-header:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check license headers
|
||||
uses: apache/skywalking-eyes/header@v0.6.0
|
||||
markdown:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install prettier
|
||||
run: |
|
||||
npm install -g prettier@3.4.2
|
||||
make check-md
|
||||
eof-newline:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: EOF newline check
|
||||
env:
|
||||
offenders_path: /tmp/eof_newline_offenders.txt
|
||||
run: |
|
||||
find . -path './.git' -prune -o -exec file --mime-type {} + | grep 'text/' | awk -F: '{print $1}' | while read -r file; do
|
||||
# Read last byte and verify it's a newline
|
||||
if [ -s "$file" ] && [ "$(tail -c1 "$file" | wc -l)" -eq 0 ]; then
|
||||
echo "$file" >> "$offenders_path"
|
||||
fi
|
||||
done
|
||||
if [ -s "$offenders_path" ]; then
|
||||
cat "$offenders_path"
|
||||
exit 1
|
||||
fi
|
||||
trailing-spaces:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Trailing spaces check
|
||||
env:
|
||||
offenders_path: /tmp/trailing_space_offenders.txt
|
||||
run: |
|
||||
grep -rIlE --exclude-dir=.git '[[:blank:]]+$' . > "$offenders_path" || true
|
||||
if [ -s "$offenders_path" ]; then
|
||||
cat "$offenders_path"
|
||||
exit 1
|
||||
fi
|
||||
209
.github/workflows/test-and-publish-nightly.yml
vendored
@@ -1,209 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on: # We are very liberal in terms of triggering builds. This should be revisited if we start seeing a lot of queueing
|
||||
- push
|
||||
- pull_request
|
||||
- workflow_dispatch
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build-jars:
|
||||
runs-on: ubuntu-latest
|
||||
name: build / jars
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
- name: Build JARs
|
||||
run: make jar
|
||||
- name: Upload JARs
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: async-profiler-jars
|
||||
path: build/jar/*
|
||||
if-no-files-found: error
|
||||
|
||||
build-linux-arm64:
|
||||
name: build / linux-arm64
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
platform: linux-arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
container-image: "arm:latest"
|
||||
|
||||
build-linux-x64:
|
||||
name: build / linux-x64
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
platform: linux-x64
|
||||
runner: ubuntu-latest
|
||||
container-image: x86:latest
|
||||
|
||||
build-macos:
|
||||
name: build / macos
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
platform: macos
|
||||
runner: macos-15
|
||||
|
||||
integ-linux-x64:
|
||||
name: integ / linux-x64
|
||||
needs: [build-linux-x64, build-jars]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
test-platform: [linux-x64]
|
||||
java-version: [8, 11, 17, 21, 25]
|
||||
java-distribution: [corretto]
|
||||
container-image: [x86:latest]
|
||||
include:
|
||||
- test-platform: linux-x64-alpine
|
||||
container-image: alpine:corretto-11
|
||||
use-builtin-jdk: true
|
||||
java-distribution: corretto
|
||||
java-version: 11
|
||||
- test-platform: linux-x64-AL2
|
||||
container-image: amazonlinux:2
|
||||
# GHA provides Node.js by attaching a volume to the container. The container path is
|
||||
# '/__e/node20', and it's not writable unless we override it via 'container.volumes'.
|
||||
container-volumes: '["/tmp/node20:/__e/node20"]'
|
||||
java-version: 11
|
||||
java-distribution: corretto
|
||||
- test-platform: linux-x64-AL2023
|
||||
container-image: amazonlinux:2023
|
||||
java-version: 11
|
||||
java-distribution: corretto
|
||||
- test-platform: linux-x64-alpaquita
|
||||
container-image: alpaquita:x86_64-liberica-21
|
||||
use-builtin-jdk: true
|
||||
java-distribution: liberica
|
||||
java-version: 21
|
||||
uses: ./.github/workflows/integ.yml
|
||||
with:
|
||||
platform: linux-x64
|
||||
test-platform: ${{ matrix.test-platform }}
|
||||
runner: ubuntu-latest
|
||||
container-image: ${{ matrix.container-image }}
|
||||
container-volumes: ${{ matrix.container-volumes || '' }}
|
||||
java-version: ${{ matrix.java-version }}
|
||||
java-distribution: ${{ matrix.java-distribution }}
|
||||
use-builtin-jdk: ${{ matrix.use-builtin-jdk || false }}
|
||||
|
||||
integ-linux-arm64:
|
||||
name: integ / linux-arm64
|
||||
needs: [build-linux-arm64, build-jars]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
test-platform: [linux-arm64]
|
||||
java-version: [8, 11, 17, 21, 25]
|
||||
java-distribution: [corretto]
|
||||
container-image: [arm:latest]
|
||||
uses: ./.github/workflows/integ.yml
|
||||
with:
|
||||
platform: linux-arm64
|
||||
test-platform: ${{ matrix.test-platform }}
|
||||
runner: ubuntu-24.04-arm
|
||||
container-image: ${{ matrix.container-image }}
|
||||
container-volumes: ${{ matrix.container-volumes || '' }}
|
||||
java-version: ${{ matrix.java-version }}
|
||||
java-distribution: ${{ matrix.java-distribution }}
|
||||
|
||||
integ-macos:
|
||||
name: integ / macos
|
||||
needs: [build-macos, build-jars]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- runner: macos-15
|
||||
test-platform: macos-arm64
|
||||
java-version: "11"
|
||||
- runner: macos-15
|
||||
test-platform: macos-arm64
|
||||
java-version: "21"
|
||||
- runner: macos-15-intel
|
||||
test-platform: macos-x64
|
||||
java-version: "17"
|
||||
architecture: x64
|
||||
retry-count: 1
|
||||
uses: ./.github/workflows/integ.yml
|
||||
with:
|
||||
platform: macos
|
||||
test-platform: ${{ matrix.test-platform }}
|
||||
runner: ${{ matrix.runner }}
|
||||
java-version: ${{ matrix.java-version }}
|
||||
architecture: ${{ matrix.architecture || '' }}
|
||||
retry-count: ${{ matrix.retry-count || 0 }}
|
||||
|
||||
publish-only-on-push:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
permissions:
|
||||
contents: write
|
||||
name: publish (nightly)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [integ-linux-x64, integ-linux-arm64, integ-macos]
|
||||
steps:
|
||||
- name: Download async-profiler binaries and jars
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: 'async-profiler-*'
|
||||
merge-multiple: 'true'
|
||||
- name: Delete previous release and publish new release
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
const fs = require('fs').promises;
|
||||
const commonOptions = {
|
||||
owner: "async-profiler",
|
||||
repo: "async-profiler",
|
||||
};
|
||||
let previousRelease = undefined;
|
||||
try {
|
||||
previousRelease = await github.rest.repos.getReleaseByTag({
|
||||
...commonOptions,
|
||||
tag: "nightly",
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("No previous nightly release");
|
||||
// ignore, there was no previous nightly release
|
||||
}
|
||||
if (previousRelease !== undefined) {
|
||||
// delete previous release and nightly tag
|
||||
await github.rest.repos.deleteRelease({
|
||||
...commonOptions,
|
||||
release_id: previousRelease.data.id,
|
||||
});
|
||||
await github.rest.git.deleteRef({...commonOptions, ref: "tags/nightly"});
|
||||
}
|
||||
// create draft release
|
||||
const newReleaseId = (await github.rest.repos.createRelease({
|
||||
...commonOptions,
|
||||
tag_name: "nightly",
|
||||
target_commitish: "${{ github.sha }}",
|
||||
name: "Nightly builds",
|
||||
body: "Async-profiler binaries published automatically from the latest sources in `master` upon a successful build.",
|
||||
prerelease: true,
|
||||
draft: true,
|
||||
})).data.id;
|
||||
// upload binaries and jars to draft release
|
||||
for (const archiveName of await fs.readdir(process.cwd())) {
|
||||
await github.rest.repos.uploadReleaseAsset({
|
||||
...commonOptions,
|
||||
release_id: newReleaseId,
|
||||
name: archiveName,
|
||||
data: await fs.readFile(archiveName),
|
||||
});
|
||||
}
|
||||
// publish release
|
||||
await github.rest.repos.updateRelease({
|
||||
...commonOptions,
|
||||
release_id: newReleaseId,
|
||||
draft: false,
|
||||
});
|
||||
4
.gitignore
vendored
@@ -6,7 +6,3 @@
|
||||
/test/*.class
|
||||
.vscode
|
||||
*.iml
|
||||
/src/api/**/*.class
|
||||
.gdb_history
|
||||
async-profiler-*.tar.gz
|
||||
async-profiler-*.zip
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
header:
|
||||
- paths:
|
||||
- 'src/jattach'
|
||||
license:
|
||||
content: |
|
||||
Copyright The jattach authors
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
comment: on-failure
|
||||
|
||||
- paths:
|
||||
- 'src'
|
||||
- 'test'
|
||||
paths-ignore:
|
||||
- 'src/jattach'
|
||||
- 'src/res'
|
||||
- '**/MANIFEST.MF'
|
||||
- 'test/**/*.collapsed'
|
||||
license:
|
||||
content: |
|
||||
Copyright The async-profiler authors
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
comment: on-failure
|
||||
11
.travis.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
language: cpp
|
||||
|
||||
dist: bionic
|
||||
|
||||
sudo: required
|
||||
|
||||
before_install:
|
||||
- sudo apt-get install default-jdk
|
||||
- sudo bash -c 'echo 1 > /proc/sys/kernel/perf_event_paranoid'
|
||||
|
||||
script: make && make test
|
||||
312
CHANGELOG.md
@@ -1,309 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [4.4] - 2026-04-20
|
||||
|
||||
### Features
|
||||
|
||||
- #1553: Differential Flame Graphs
|
||||
|
||||
### Improvements
|
||||
|
||||
- #1705: `memlimit` option to limit size of the call trace storage
|
||||
- #1706: Extend syntax of `-j` option to truncate deep stacks
|
||||
- #1720: FlameGraph: Dark mode toggle
|
||||
- #1672: FlameGraph: Use Ctrl+Click in addition to Alt+Click to remove stacks
|
||||
- #1684: Unwind ARM64 generated stubs on JDK 26+
|
||||
- #1676: Make `dwarf` stack walking mode an alias for `vm`
|
||||
- #1671: An option to select TLAB based AllocTracer engine with JDK 11+
|
||||
- #1670: Move converter Main class to the one.convert package
|
||||
- #1660: Provide non-aggregated samples in OTLP converter
|
||||
- #1701, #1682: Speed-up stack walking
|
||||
|
||||
### Breaking changes
|
||||
|
||||
- #1673: Permanently remove `check` command
|
||||
- #1675: Remove unsafe AsyncGetCallTrace recovery tricks along with `safemode` option
|
||||
- #1677: Remove `cstack=lbr` option
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- #1727: Allocation profile has wrong units in OTLP format
|
||||
- #1716: Wall-clock Heatmap does not count samples correctly
|
||||
- #1715: Fix Zing crash when profiling cpu+wall together
|
||||
- #1708: Another fix for correct vDSO unwinding on ARM64
|
||||
- #1707: Workaround for JFR shutdown race
|
||||
- #1699: Allow negative keys in JFR constant pool
|
||||
- #1697: Ensure remaining buffer is sufficient for event data in JfrReader
|
||||
- #1657: Re-enable workaround for a long attach on JDK 8
|
||||
- #1654: Prefer perf-events engine when record-cpu or target-cpu are selected
|
||||
- #1585: Scale perf counters in case of multiplexing
|
||||
- #1528: Add a hard-coded limit on the maximum number of jmethodIDs
|
||||
- #1203: Fix "Instance field not found" when using `-Xcheck:jni` on JDK 8
|
||||
- Do not walk past virtual thread continuation barriers
|
||||
|
||||
## [4.3] - 2026-01-20
|
||||
|
||||
### Features
|
||||
|
||||
- #1547: Native lock profiling
|
||||
- #1566: Filter cpu/wall profiles by latency
|
||||
- #1568: Expose async-profiler metrics in Prometheus format
|
||||
- #1628: async-profiler.jar as Java agent; remote control via JMX
|
||||
|
||||
### Improvements
|
||||
|
||||
- #1140: FlameGraph improvements: legend, hot keys, new toolbar icons
|
||||
- #1530: Timezone switcher between Local and UTC time in Heatmaps
|
||||
- #1582: Support `--include`/`--exclude` options for JFR to Heatmap/OTLP/pprof conversion
|
||||
- #1624: Compatibility with OTLP v1.9.0
|
||||
- #1629: Harden crash protection in StackWalker
|
||||
|
||||
### Breaking changes
|
||||
|
||||
- #1277: New `timeSpan` field in WallClockSample events
|
||||
- #1518: Deprecate `check` command
|
||||
- #1590: Support compilation on modern JDKs. Drop JDK 7 support
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- #1599: Workaround for the kernel PERF_EVENT_IOC_REFRESH bug
|
||||
- #1596: Do not block any signals during execution of a custom crash handler
|
||||
- #1584: JfrReader loops on corrupted recordings
|
||||
- #1555: Parse FlameGraph title from HTML input
|
||||
- #1621: `loop` and `timeout` options do not work together
|
||||
- #1641: Unwind vDSO correctly on Linux-ARM64
|
||||
- #1648: Fix stop sequence in Profiler::start
|
||||
- #1575: Fix CodeCache memory leak in lock profiling while looping
|
||||
- #1558: Fix record-cpu bug when kernel stacks are not available
|
||||
- #1651: Do not record CPU frame for non-perf samples
|
||||
- #1614, #1615, #1617, #1623: Fix races related to VM termination
|
||||
|
||||
## [4.2.1] - 2025-11-22
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- #1599: Workaround for the kernel PERF_EVENT_IOC_REFRESH bug
|
||||
- #1596: Do not block any signals during execution of a custom crash handler
|
||||
|
||||
## [4.2] - 2025-10-20
|
||||
|
||||
### Features
|
||||
|
||||
- Java Method Tracing and Latency Profiling
|
||||
* #1421: Latency profiling
|
||||
* #1435: Allow wildcards in Instrument profiling engine
|
||||
* #1499: `--trace` option with per-method latency threshold
|
||||
- System-wide process sampling on Linux
|
||||
* #1411: `--proc` option to record `profiler.ProcessSample` events
|
||||
- VMStructs stack walker by default
|
||||
* #1539: Use VMStructs stack walking mode by default
|
||||
* #1537: Support `comptask` and `vtable` features
|
||||
* #1517: Use JavaFrameAnchor to find top Java frame
|
||||
* #1449: Special handling of prologue and epilogue of compiled methods
|
||||
|
||||
### Improvements
|
||||
|
||||
- #1475: Add `CPUTimeSample` event support to jfrconv
|
||||
- #1414: Per-thread flamegraph option in JFR heatmap converter
|
||||
- #1526: Expose JfrReader dictionary that maps osThreadId to javaThreadId
|
||||
- #1448: Thread name in OpenTelemetry output
|
||||
- #1413: Add `time_nanos` and `duration_nanos` to OTLP profiles
|
||||
- #1450: Unwind dylib stubs as empty frames on macOS
|
||||
- #1416: Add synthetic symbols for Mach-O stubs/trampolines
|
||||
- Allow cross-compilation for 32-bit platforms
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- #1515: Fix UnsatisfiedLinkError when tmpdir is set to a relative path
|
||||
- #1500: Detect if `calloc` calls `malloc` for nativemem profiling
|
||||
- #1427: Re-implement SafeAccess crash protection
|
||||
- #1417: Two wall-clock profilers interfere with each other
|
||||
|
||||
### Project Infrastructure
|
||||
|
||||
- #1527: GHA: replace macos-13 with macos-15-intel
|
||||
- #1510: Add option to retry tests
|
||||
- #1508: Add more GHA jobs to cover JDK versions on ARM
|
||||
- #1502: Fix job dependencies between integration tests and builds
|
||||
- #1466: Add Liberica JDK on Alpaquita Linux to the CI
|
||||
- Made integration tests more stable overall
|
||||
|
||||
## [4.1] - 2025-07-21
|
||||
|
||||
### Features
|
||||
- Experimental support for the OpenTelemetry profiling signal
|
||||
* #1188: OTLP output format and `dumpOtlp` Java API
|
||||
* #1336: JFR to OTLP converter
|
||||
- JDK 25 support
|
||||
* #1222: Update VMStructs for JDK 25
|
||||
- Productize native memory profiling
|
||||
* #1193: Full `nativemem` support on macOS
|
||||
* #1254: Fixed Nativemem tests on Alpine
|
||||
* #1269: Native memory profiling now works with `jemalloc`
|
||||
* #1323: `nativemem` shows allocations inside async-profiler itself
|
||||
|
||||
### Improvements
|
||||
- #1174: Detect JVM in non-Java application and attach to it
|
||||
- #1223: Native API to add custom events in JFR recording
|
||||
- #1259: `--all` option to collect all possible events simultaneously
|
||||
- #1286: Record which CPU a sample was taken on
|
||||
- #1299: Skip last 10% allocations for leak detection
|
||||
- #1300: Allow profiling kprobes/uprobes with `--fdtransfer`
|
||||
- #1366: Rewrite `jfrconv` executable to shell
|
||||
- #1400: Unwind checksum and digest intrinsics on ARM64
|
||||
- #1357, #1389: VMStructs-based stack unwinding for `alloc` and `nativemem` profiling
|
||||
|
||||
### Bug fixes
|
||||
- #1251: `--ttsp` option does not work on Alpine
|
||||
- #1264: Guard hook installation with dlopen/dlclose
|
||||
- #1319: SIGSEGV in PerfEvents::walk
|
||||
- #1350: Disable JFR OldObjectSample event in jfrsync mode
|
||||
- #1358: Do not dereference jmethodIDs on JDK 26
|
||||
- #1374: Correctly check if profiler is preloaded
|
||||
- #1380: Workaround clang type promotion bug
|
||||
- #1387: JFR writer crashes when using cstack=vmx
|
||||
- #1393: Improve stack walking termination logic: no endless `unknown` frames
|
||||
- Stack unwinding fixes for ARM64
|
||||
|
||||
### Project Infrastructure
|
||||
- #1129: Command-line option to filter tests
|
||||
- #1262: Include `asprof.h` in async-profiler release package
|
||||
- #1271: Release additional binaries with debug symbols
|
||||
- #1274: Add Corretto 8 to the test matrix
|
||||
- #1246, #1226: Run tests on Amazon Linux and Alpine Linux
|
||||
- #1360: Auto-generated clang-tidy review comments
|
||||
- #1373: Save all generated test logs for debug purposes
|
||||
- Fixed flaky tests (#1282, #1307, #1376)
|
||||
|
||||
## [4.0] - 2025-04-08
|
||||
|
||||
### Features
|
||||
- #895, #905: `jfrconv` binary and numerous converter enhancements
|
||||
- #944: Interactive Heatmap
|
||||
- #1064: Native memory leak profiler
|
||||
- #1002: An option to display instruction addresses
|
||||
- #1007: Optimize wall clock profiling
|
||||
- #1073: Productize VMStructs-based stack walker: `--cstack vm/vmx`
|
||||
- #1169: C API for accessing thread-local profiling context
|
||||
|
||||
### Improvements
|
||||
- #923: Support JDK 23+
|
||||
- #952: Solve musl and glibc compatibility issues; link `libstdc++` statically
|
||||
- #955: `--libpath` option to specify path to `libasyncProfiler.so` in a container
|
||||
- #1018: `--grain` converter option to coarsen flame graphs
|
||||
- #1046: `--nostop` option to continue profiling outside `--begin`/`--end` window
|
||||
- #1178: `--inverted` option to flip flame graphs vertically
|
||||
- #1009: Allows collecting allocation and live object traces at the same time
|
||||
- #925: An option to accumulate JFR events in memory instead of flushing to a file
|
||||
- #929: Load symbols from debuginfod cache
|
||||
- #982: Sample contended locks by overflowing interval bucket
|
||||
- #993: Filter native frames in allocation profile
|
||||
- #896: FlameGraph: `Alt+Click` to remove stacks
|
||||
- #1097: FlameGraph: `N`/`Shift+N` to navigate through search results
|
||||
- #1182: Retain by-thread grouping when reversing FlameGraph
|
||||
- #1167: Log when no samples are collected
|
||||
- #1044: Fall back to `ctimer` for CPU profiling when perf_events are unavailable
|
||||
- #1068: Count missed samples when estimating total CPU time in `ctimer` mode
|
||||
- #1142: Use counter-timer register for timestamps on ARM64
|
||||
- #1123: Support `clock=tsc` without a JVM
|
||||
- #1070: Demangle Rust v0 symbols
|
||||
- #1007: Use `ExecutionSample` event for CPU profiling and `WallClockSample` for Wall clock profiling
|
||||
- #1011: Obtain `can_generate_sampled_object_alloc_events` JVMTI capability only when needed
|
||||
- #1013: Intercept java.util.concurrent locks more efficiently
|
||||
- #759: Discover available profiling signal automatically
|
||||
- #884: Record event timestamps early
|
||||
- #885: Print error message if JVM fails to load libasyncProfiler
|
||||
- #892: Resolve tracepoint id in `asprof`
|
||||
- Suppress dynamic attach warning on JDK 21+
|
||||
|
||||
### Bug fixes
|
||||
- #1143: Crash on macOS when using thread filter
|
||||
- #1125: Fixed parsing concurrently loaded libraries
|
||||
- #1095: jfr print fails when a recording has empty pools
|
||||
- #1084: Fixed Logging related races
|
||||
- #1074: Parse both .rela.dyn and .rela.plt sections
|
||||
- #1003: Support both tracefs and debugfs for kernel tracepoints
|
||||
- #986: Profiling output respects loglevel
|
||||
- #981: Avoid JVM crash by deleting JNI refs after `GetMethodDeclaringClass`
|
||||
- #934: Fix crash on Zing in a native thread
|
||||
- #843: Fix race between parsing and concurrent unloading of shared libraries
|
||||
- #1147, #1151: Deadlocks with jemalloc and tcmalloc profilers
|
||||
- Stack walking fixes for ARM64
|
||||
- Converter fixes for `jfrsync` profiles
|
||||
- Fixed parsing non-PIC executables and shared objects with non-standard section layout
|
||||
- Fixed recursion in `pthread_create` when using native profiling API
|
||||
- Fixed crashes on Alpine when profiling native apps
|
||||
- Fixed warnings with `-Xcheck:jni`
|
||||
- Fixed "Unsupported JVM" on OpenJ9 JDK 21
|
||||
- Fixed DefineClass crash on OpenJ9
|
||||
- JfrReader should handle custom events properly
|
||||
- Handle truncated JFRs
|
||||
|
||||
### Project Infrastructure
|
||||
- Restructure and update documentation
|
||||
- Implement test framework; add new integration tests
|
||||
- Unit test framework for C++ code
|
||||
- Run CI on all supported platforms
|
||||
- Test multiple JDK versions in CI
|
||||
- Add GHA to validate license headers
|
||||
- Add Markdown checker and formatter
|
||||
- Add Issue and Pull Request templates
|
||||
- Add Contributing Guidelines and Code of Conduct
|
||||
- Run static analyzer and fix found issues (#1034, #1039, #1049, #1051, #1098)
|
||||
- Provide Dockerfile for building async-profiler release packages
|
||||
- Publish nightly builds automatically
|
||||
|
||||
## [3.0] - 2024-01-20
|
||||
|
||||
### Features
|
||||
- #724: Binary launcher `asprof`
|
||||
- #751: Profile non-Java processes
|
||||
- #795: AsyncGetCallTrace replacement
|
||||
- #719: Classify execution samples into categories in JFR converter
|
||||
- #855: `ctimer` mode for accurate profiling without perf_events
|
||||
- #740: Profile CPU + Wall clock together
|
||||
- #736: Show targets of vtable/itable calls
|
||||
- #777: Show JIT compilation task
|
||||
- #644: RISC-V port
|
||||
- #770: LoongArch64 port
|
||||
|
||||
### Improvements
|
||||
- #733: Make the same `libasyncProfiler` work with both glibc and musl
|
||||
- #734: Support raw PMU event descriptors
|
||||
- #759: Configure alternative profiling signal
|
||||
- #761: Parse dynamic linking structures
|
||||
- #723: `--clock` option to select JFR timestamp source
|
||||
- #750: `--jfrsync` may specify a list of JFR events
|
||||
- #849: Parse concatenated multi-chunk JFRs
|
||||
- #833: Time-to-safepoint JFR event
|
||||
- #832: Normalize names of hidden classes / lambdas
|
||||
- #864: Reduce size of HTML Flame Graph
|
||||
- #783: Shutdown asprof gracefully on SIGTERM
|
||||
- Better demangling of C++ and Rust symbols
|
||||
- DWARF unwinding for ARM64
|
||||
- `JfrReader` can parse in-memory buffer
|
||||
- Support custom events in `JfrReader`
|
||||
- An option to read JFR file by chunks
|
||||
- Record `GCHeapSummary` events in JFR
|
||||
|
||||
### Bug fixes
|
||||
- Workaround macOS crashes in SafeFetch
|
||||
- Fixed attach to OpenJ9 on macOS
|
||||
- Support `UseCompressedObjectHeaders` aka Lilliput
|
||||
- Fixed allocation profiling on JDK 20.0.x
|
||||
- Fixed context-switches profiling
|
||||
- Prefer ObjectSampler to TLAB hooks for allocation profiling
|
||||
- Improved accuracy of ObjectSampler in `--total` mode
|
||||
- Make Flame Graph status line and search results always visible
|
||||
- `loop` and `timeout` options did not work in some modes
|
||||
- Restart interrupted poll/epoll_wait syscalls
|
||||
- Fixed stack unwinding issues on ARM64
|
||||
- Workaround for stale jmethodIDs
|
||||
- Calculate ELF base address correctly
|
||||
- Do not dump redundant threads in a JFR chunk
|
||||
- `check` action prints result to a file
|
||||
- Annotate JFR unit types with `@ContentType`
|
||||
|
||||
## [2.9] - 2022-11-27
|
||||
|
||||
### Features
|
||||
@@ -506,7 +202,7 @@
|
||||
### Features
|
||||
- Converters between different output formats:
|
||||
- JFR -> nflx (FlameScope)
|
||||
- Collapsed stacks -> HTML 5 Flame Graph
|
||||
- Collapsed stacks -> HTML 5 Flame Graph
|
||||
|
||||
### Improvements
|
||||
- `profiler.sh` no longer requires bash (contributed by @cfstras)
|
||||
@@ -590,7 +286,7 @@
|
||||
### Features
|
||||
- Interactive Call tree and Backtrace tree in HTML format (contributed by @rpulle)
|
||||
- Experimental support for Java Flight Recorder (JFR) compatible output
|
||||
|
||||
|
||||
### Improvements
|
||||
- Added units: `ms`, `us`, `s` and multipliers: `K`, `M`, `G` for interval argument
|
||||
- API and command-line option `-v` for profiler version
|
||||
@@ -604,7 +300,7 @@
|
||||
|
||||
### Features
|
||||
- Profiling of native functions, e.g. malloc
|
||||
|
||||
|
||||
### Improvements
|
||||
- JDK 9, 10, 11 support for heap profiling with accurate stack traces
|
||||
- `root` can now profile Java processes of any user
|
||||
@@ -616,7 +312,7 @@
|
||||
- Produce SVG files out of the box; flamegraph.pl is no longer needed
|
||||
- Profile ReentrantLock contention
|
||||
- Java API
|
||||
|
||||
|
||||
### Improvements
|
||||
- Allocation and Lock profiler now works on JDK 7, too
|
||||
- Faster dumping of results
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
## Code of Conduct
|
||||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
|
||||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
|
||||
opensource-codeofconduct@amazon.com with any additional questions or comments.
|
||||
@@ -1,59 +0,0 @@
|
||||
# Contributing Guidelines
|
||||
|
||||
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
|
||||
documentation, we greatly value feedback and contributions from our community.
|
||||
|
||||
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
|
||||
information to effectively respond to your bug report or contribution.
|
||||
|
||||
|
||||
## Security issue notifications
|
||||
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public GitHub issue.
|
||||
|
||||
|
||||
## Reporting Bugs/Feature Requests
|
||||
|
||||
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
|
||||
|
||||
When filing an issue, please check [existing open](https://github.com/async-profiler/async-profiler/issues), or [recently closed](https://github.com/async-profiler/async-profiler/issues?q=is%3Aissue+is%3Aclosed), issues to make sure somebody else hasn't already
|
||||
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
|
||||
|
||||
* A reproducible test case or series of steps
|
||||
* The version of our code being used
|
||||
* Any modifications you've made relevant to the bug
|
||||
* Anything unusual about your environment or deployment
|
||||
|
||||
|
||||
## Contributing via Pull Requests
|
||||
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
|
||||
|
||||
1. You are working against the latest source on the *master* branch.
|
||||
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
|
||||
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
|
||||
|
||||
To send us a pull request, please:
|
||||
|
||||
1. Fork the repository.
|
||||
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
|
||||
3. Ensure local tests pass.
|
||||
4. Commit to your fork using clear commit messages.
|
||||
5. Send us a pull request, answering any default questions in the pull request interface.
|
||||
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
|
||||
|
||||
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
|
||||
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
|
||||
|
||||
|
||||
## Finding contributions to work on
|
||||
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/async-profiler/async-profiler/labels/help%20wanted) issues is a great place to start.
|
||||
|
||||
|
||||
## Code of Conduct
|
||||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
|
||||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
|
||||
opensource-codeofconduct@amazon.com with any additional questions or comments.
|
||||
|
||||
|
||||
## Licensing
|
||||
|
||||
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
|
||||
347
Makefile
@@ -1,338 +1,171 @@
|
||||
PROFILER_VERSION ?= 4.4
|
||||
PROFILER_VERSION=2.9-bpf
|
||||
|
||||
ifeq ($(COMMIT_TAG),true)
|
||||
PROFILER_VERSION := $(PROFILER_VERSION)-$(shell git rev-parse --short=7 HEAD)
|
||||
else ifneq ($(COMMIT_TAG),)
|
||||
PROFILER_VERSION := $(PROFILER_VERSION)-$(COMMIT_TAG)
|
||||
endif
|
||||
|
||||
TMP_DIR=/tmp
|
||||
COMMA=,
|
||||
PACKAGE_NAME=async-profiler-$(PROFILER_VERSION)-$(OS_TAG)-$(ARCH_TAG)
|
||||
PACKAGE_DIR=$(TMP_DIR)/$(PACKAGE_NAME)
|
||||
DEBUG_PACKAGE_NAME=$(PACKAGE_NAME)-debug
|
||||
DEBUG_PACKAGE_DIR=$(PACKAGE_DIR)-debug
|
||||
PACKAGE_DIR=/tmp/$(PACKAGE_NAME)
|
||||
|
||||
ASPROF=bin/asprof
|
||||
JFRCONV=bin/jfrconv
|
||||
LIB_PROFILER=lib/libasyncProfiler.$(SOEXT)
|
||||
LIB_PROFILER_DEBUG=libasyncProfiler.$(SOEXT).debug
|
||||
ASPROF_HEADER=include/asprof.h
|
||||
API_JAR=jar/async-profiler.jar
|
||||
CONVERTER_JAR=jar/jfr-converter.jar
|
||||
TEST_JAR=test.jar
|
||||
LIB_PROFILER=libasyncProfiler.$(SOEXT)
|
||||
LIB_PROFILER_SO=libasyncProfiler.so
|
||||
JATTACH=jattach
|
||||
API_JAR=async-profiler.jar
|
||||
CONVERTER_JAR=converter.jar
|
||||
|
||||
CC ?= gcc
|
||||
CXX ?= g++
|
||||
STRIP ?= strip
|
||||
OBJCOPY ?= objcopy
|
||||
|
||||
ifneq ($(CROSS_COMPILE),)
|
||||
CC := $(CROSS_COMPILE)gcc
|
||||
CXX := $(CROSS_COMPILE)g++
|
||||
AS := $(CROSS_COMPILE)as
|
||||
LD := $(CROSS_COMPILE)ld
|
||||
STRIP := $(CROSS_COMPILE)strip
|
||||
OBJCOPY := $(CROSS_COMPILE)objcopy
|
||||
endif
|
||||
|
||||
CFLAGS_EXTRA ?=
|
||||
CXXFLAGS_EXTRA ?=
|
||||
CFLAGS=-O3 -fno-exceptions $(CFLAGS_EXTRA)
|
||||
CXXFLAGS=-O3 -fno-exceptions -fno-omit-frame-pointer -fvisibility=hidden -std=c++11 $(CXXFLAGS_EXTRA)
|
||||
CPPFLAGS=
|
||||
DEFS=-DPROFILER_VERSION=\"$(PROFILER_VERSION)\"
|
||||
INCLUDES=-I$(JAVA_HOME)/include -Isrc/helper
|
||||
CFLAGS=-O3
|
||||
CXXFLAGS=-O3 -fno-omit-frame-pointer -fvisibility=hidden
|
||||
INCLUDES=-I$(JAVA_HOME)/include -Isrc/res -Isrc/helper
|
||||
LIBS=-ldl -lpthread
|
||||
MERGE=true
|
||||
GCOV ?= gcov
|
||||
|
||||
JAVAC=$(JAVA_HOME)/bin/javac
|
||||
JAR=$(JAVA_HOME)/bin/jar
|
||||
JAVA=$(JAVA_HOME)/bin/java
|
||||
JAVA_TARGET=8
|
||||
JAVAC_OPTIONS=--release $(JAVA_TARGET) -Xlint:-options
|
||||
TEST_JAVA ?= $(JAVA_HOME)/bin/java
|
||||
JAVA_TARGET=7
|
||||
JAVAC_OPTIONS=-source $(JAVA_TARGET) -target $(JAVA_TARGET) -Xlint:-options
|
||||
|
||||
TEST_LIB_DIR=build/test/lib
|
||||
TEST_BIN_DIR=build/test/bin
|
||||
TEST_DEPS_DIR=test/deps
|
||||
TEST_GEN_DIR=test/gen
|
||||
LOG_DIR=build/test/logs
|
||||
LOG_LEVEL=
|
||||
SKIP=
|
||||
RETRY_COUNT=0
|
||||
TEST_THREADS ?= 8
|
||||
TEST_FLAGS=-DlogDir=$(LOG_DIR) -DlogLevel=$(LOG_LEVEL) -Dskip='$(subst $(COMMA), ,$(SKIP))' -DretryCount=$(RETRY_COUNT) -DthreadCount=$(TEST_THREADS)
|
||||
|
||||
# always sort SOURCES so zInit is last.
|
||||
SOURCES := $(sort $(wildcard src/*.cpp))
|
||||
HEADERS := $(wildcard src/*.h)
|
||||
SOURCES := $(wildcard src/*.cpp)
|
||||
HEADERS := $(wildcard src/*.h src/fdtransfer/*.h)
|
||||
RESOURCES := $(wildcard src/res/*)
|
||||
JAVA_HELPER_CLASSES := $(wildcard src/helper/one/profiler/*.class)
|
||||
API_SOURCES := $(wildcard src/api/one/profiler/*.java)
|
||||
JAR_MANIFEST := src/api/one/profiler/MANIFEST.MF
|
||||
CONVERTER_SOURCES := $(shell find src/converter -name '*.java')
|
||||
TEST_SOURCES := $(shell find test -name '*.java' ! -path 'test/stubs/*')
|
||||
TESTS ?=
|
||||
CPP_TEST_SOURCES := test/native/testRunner.cpp $(shell find test/native -name '*Test.cpp')
|
||||
CPP_TEST_HEADER := test/native/testRunner.hpp
|
||||
CPP_TEST_INCLUDES := -Isrc -Itest/native
|
||||
TEST_LIB_SOURCES := $(wildcard test/native/libs/*)
|
||||
TEST_BIN_SOURCES := $(shell find test/test -name "*.c*")
|
||||
|
||||
ifeq ($(JAVA_HOME),)
|
||||
JAVA_HOME:=$(shell java -cp . JavaHome)
|
||||
export JAVA_HOME:=$(shell java -cp . JavaHome)
|
||||
endif
|
||||
|
||||
OS:=$(shell uname -s)
|
||||
ifeq ($(OS),Darwin)
|
||||
CXXFLAGS += -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -Wl,-rpath,@executable_path/../lib -Wl,-rpath,@executable_path/../lib/server
|
||||
INCLUDES += -I$(JAVA_HOME)/include/darwin
|
||||
FDTRANSFER_BIN=
|
||||
SOEXT=dylib
|
||||
PACKAGE_EXT=zip
|
||||
OS_TAG=macos
|
||||
ifeq ($(FAT_BINARY),true)
|
||||
FAT_BINARY_FLAGS=-arch x86_64 -arch arm64 -mmacos-version-min=10.15
|
||||
FAT_BINARY_FLAGS=-arch x86_64 -arch arm64 -mmacos-version-min=10.12
|
||||
CFLAGS += $(FAT_BINARY_FLAGS)
|
||||
CXXFLAGS += $(FAT_BINARY_FLAGS)
|
||||
PACKAGE_NAME=async-profiler-$(PROFILER_VERSION)-$(OS_TAG)
|
||||
MERGE=false
|
||||
endif
|
||||
else
|
||||
CXXFLAGS += -U_FORTIFY_SOURCE -Wl,-z,defs -Wl,--exclude-libs,ALL -static-libstdc++ -static-libgcc
|
||||
CXXFLAGS += -fdata-sections -ffunction-sections -Wl,--gc-sections -ggdb -Wunused-variable -Wno-psabi
|
||||
CXXFLAGS += -Wl,-z,defs
|
||||
ifeq ($(MERGE),true)
|
||||
CXXFLAGS += -fwhole-program
|
||||
endif
|
||||
LIBS += -lrt
|
||||
INCLUDES += -I$(JAVA_HOME)/include/linux
|
||||
FDTRANSFER_BIN=build/fdtransfer
|
||||
SOEXT=so
|
||||
PACKAGE_EXT=tar.gz
|
||||
OS_TAG=linux
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH_TAG),)
|
||||
ARCH:=$(shell uname -m)
|
||||
ifeq ($(ARCH),x86_64)
|
||||
ARCH_TAG=x64
|
||||
else ifeq ($(ARCH),aarch64)
|
||||
ARCH_TAG=arm64
|
||||
else ifeq ($(ARCH),arm64)
|
||||
ARCH_TAG=arm64
|
||||
else ifeq ($(findstring arm,$(ARCH)),arm)
|
||||
ARCH_TAG=arm32
|
||||
else ifeq ($(ARCH),ppc64le)
|
||||
ARCH_TAG=ppc64le
|
||||
else ifeq ($(ARCH),riscv64)
|
||||
ARCH_TAG=riscv64
|
||||
else ifeq ($(ARCH),loongarch64)
|
||||
ARCH_TAG=loongarch64
|
||||
ifeq ($(findstring musl,$(shell ldd /bin/ls)),musl)
|
||||
OS_TAG=linux-musl
|
||||
CXXFLAGS += -D__musl__
|
||||
else
|
||||
ARCH_TAG=x86
|
||||
OS_TAG=linux
|
||||
endif
|
||||
endif
|
||||
|
||||
STATIC_BINARY=$(findstring musl-gcc,$(CC))
|
||||
ifneq (,$(STATIC_BINARY))
|
||||
CFLAGS += -static -fdata-sections -ffunction-sections -Wl,--gc-sections
|
||||
ARCH:=$(shell uname -m)
|
||||
ifeq ($(ARCH),x86_64)
|
||||
ARCH_TAG=x64
|
||||
else
|
||||
ifeq ($(findstring arm,$(ARCH)),arm)
|
||||
ifeq ($(findstring 64,$(ARCH)),64)
|
||||
ARCH_TAG=arm64
|
||||
else
|
||||
ARCH_TAG=arm32
|
||||
endif
|
||||
else
|
||||
ifeq ($(findstring aarch64,$(ARCH)),aarch64)
|
||||
ARCH_TAG=arm64
|
||||
else
|
||||
ifeq ($(ARCH),ppc64le)
|
||||
ARCH_TAG=ppc64le
|
||||
else
|
||||
ARCH_TAG=x86
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: all jar release build-test test clean coverage clean-coverage build-test-java build-test-cpp test-cpp test-java check-md format-md
|
||||
ifneq ($(ARCH),ppc64le)
|
||||
ifneq ($(ARCH_TAG),arm32)
|
||||
CXXFLAGS += -momit-leaf-frame-pointer
|
||||
endif
|
||||
endif
|
||||
|
||||
all: build/bin build/lib build/$(LIB_PROFILER) build/$(ASPROF) jar build/$(JFRCONV) build/$(ASPROF_HEADER)
|
||||
|
||||
jar: build/jar build/$(API_JAR) build/$(CONVERTER_JAR)
|
||||
.PHONY: all release test native clean
|
||||
|
||||
release: $(PACKAGE_NAME).$(PACKAGE_EXT)
|
||||
all: build build/$(LIB_PROFILER) build/$(JATTACH) $(FDTRANSFER_BIN) build/$(API_JAR) build/$(CONVERTER_JAR)
|
||||
|
||||
release: build $(PACKAGE_NAME).$(PACKAGE_EXT)
|
||||
|
||||
$(PACKAGE_NAME).tar.gz: $(PACKAGE_DIR)
|
||||
patchelf --remove-needed ld-linux-x86-64.so.2 --remove-needed ld-linux-aarch64.so.1 $(PACKAGE_DIR)/$(LIB_PROFILER)
|
||||
tar czf $@ -C $(PACKAGE_DIR)/.. $(PACKAGE_NAME)
|
||||
rm -r $(PACKAGE_DIR)
|
||||
|
||||
tar czf $(DEBUG_PACKAGE_NAME).tar.gz -C $(DEBUG_PACKAGE_DIR)/.. $(DEBUG_PACKAGE_NAME)
|
||||
rm -r $(DEBUG_PACKAGE_DIR)
|
||||
|
||||
$(PACKAGE_NAME).zip: $(PACKAGE_DIR)
|
||||
ifneq ($(GITHUB_ACTIONS), true)
|
||||
codesign -s "Developer ID" -o runtime --timestamp -v $(PACKAGE_DIR)/$(ASPROF) $(PACKAGE_DIR)/$(JFRCONV) $(PACKAGE_DIR)/$(LIB_PROFILER)
|
||||
endif
|
||||
codesign -s "Developer ID" -o runtime --timestamp -v $(PACKAGE_DIR)/build/$(JATTACH) $(PACKAGE_DIR)/build/$(LIB_PROFILER_SO)
|
||||
ditto -c -k --keepParent $(PACKAGE_DIR) $@
|
||||
rm -r $(PACKAGE_DIR)
|
||||
|
||||
$(PACKAGE_DIR): all LICENSE README.md
|
||||
rm -rf $@
|
||||
mkdir -p $(PACKAGE_DIR) $(DEBUG_PACKAGE_DIR)
|
||||
cp -RP build/bin build/lib build/include LICENSE README.md $(PACKAGE_DIR)/
|
||||
$(PACKAGE_DIR): build/$(LIB_PROFILER) build/$(JATTACH) $(FDTRANSFER_BIN) \
|
||||
build/$(API_JAR) build/$(CONVERTER_JAR) \
|
||||
profiler.sh LICENSE *.md
|
||||
mkdir -p $(PACKAGE_DIR)
|
||||
cp -RP build profiler.sh LICENSE *.md $(PACKAGE_DIR)
|
||||
chmod -R 755 $(PACKAGE_DIR)
|
||||
chmod 644 $(PACKAGE_DIR)/lib/* $(PACKAGE_DIR)/include/* $(PACKAGE_DIR)/LICENSE $(PACKAGE_DIR)/README.md
|
||||
chmod 644 $(PACKAGE_DIR)/LICENSE $(PACKAGE_DIR)/*.md $(PACKAGE_DIR)/build/*.jar
|
||||
|
||||
ifeq ($(OS_TAG),linux)
|
||||
$(STRIP) --only-keep-debug build/$(LIB_PROFILER) -o $(DEBUG_PACKAGE_DIR)/$(LIB_PROFILER_DEBUG)
|
||||
$(STRIP) -g $@/$(LIB_PROFILER)
|
||||
$(OBJCOPY) --add-gnu-debuglink=$(DEBUG_PACKAGE_DIR)/$(LIB_PROFILER_DEBUG) $@/$(LIB_PROFILER)
|
||||
chmod 644 $(DEBUG_PACKAGE_DIR)/*
|
||||
endif
|
||||
%.$(SOEXT): %.so
|
||||
rm -f $@
|
||||
-ln -s $(<F) $@
|
||||
|
||||
build/%:
|
||||
mkdir -p $@
|
||||
build:
|
||||
mkdir -p build
|
||||
|
||||
build/$(ASPROF): src/main/* src/jattach/* src/fdtransfer.h
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFS) -o $@ src/main/*.cpp src/jattach/*.c
|
||||
$(STRIP) $@
|
||||
|
||||
build/$(JFRCONV): src/launcher/launcher.sh build/$(CONVERTER_JAR)
|
||||
sed -e 's/PROFILER_VERSION/$(PROFILER_VERSION)/g' -e 's/BUILD_DATE/$(shell date "+%b %d %Y")/g' src/launcher/launcher.sh > $@
|
||||
chmod +x $@
|
||||
cat build/$(CONVERTER_JAR) >> $@
|
||||
|
||||
build/$(LIB_PROFILER): $(SOURCES) $(HEADERS) $(RESOURCES) $(JAVA_HELPER_CLASSES)
|
||||
build/$(LIB_PROFILER_SO): $(SOURCES) $(HEADERS) $(RESOURCES) $(JAVA_HELPER_CLASSES)
|
||||
ifeq ($(MERGE),true)
|
||||
for f in src/*.cpp; do echo '#include "'$$f'"'; done |\
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFS) $(INCLUDES) -fPIC -shared -o $@ -xc++ - $(LIBS)
|
||||
$(CXX) $(CXXFLAGS) -DPROFILER_VERSION=\"$(PROFILER_VERSION)\" $(INCLUDES) -fPIC -shared -o $@ -xc++ - $(LIBS)
|
||||
else
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFS) $(INCLUDES) -fPIC -shared -o $@ $(SOURCES) $(LIBS)
|
||||
$(CXX) $(CXXFLAGS) -DPROFILER_VERSION=\"$(PROFILER_VERSION)\" $(INCLUDES) -fPIC -shared -o $@ $(SOURCES) $(LIBS)
|
||||
endif
|
||||
|
||||
build/$(ASPROF_HEADER): src/asprof.h
|
||||
mkdir -p build/include
|
||||
cp -f $< build/include
|
||||
build/$(JATTACH): src/jattach/*.c src/jattach/*.h
|
||||
$(CC) $(CFLAGS) -DJATTACH_VERSION=\"$(PROFILER_VERSION)-ap\" -o $@ src/jattach/*.c
|
||||
|
||||
build/$(API_JAR): $(API_SOURCES) $(JAR_MANIFEST)
|
||||
build/fdtransfer: src/fdtransfer/*.cpp src/fdtransfer/*.h src/jattach/psutil.c src/jattach/psutil.h
|
||||
$(CXX) $(CFLAGS) -o $@ src/fdtransfer/*.cpp src/jattach/psutil.c
|
||||
|
||||
build/$(API_JAR): $(API_SOURCES)
|
||||
mkdir -p build/api
|
||||
$(JAVAC) $(JAVAC_OPTIONS) -d build/api $(API_SOURCES)
|
||||
$(JAR) cfm $@ $(JAR_MANIFEST) -C build/api .
|
||||
$(JAVAC) $(JAVAC_OPTIONS) -d build/api $^
|
||||
$(JAR) cf $@ -C build/api .
|
||||
$(RM) -r build/api
|
||||
|
||||
build/$(CONVERTER_JAR): $(CONVERTER_SOURCES) $(RESOURCES)
|
||||
mkdir -p build/converter
|
||||
$(JAVAC) $(JAVAC_OPTIONS) -d build/converter $(CONVERTER_SOURCES)
|
||||
$(JAR) cfe $@ one.convert.Main -C build/converter . -C src/res .
|
||||
$(JAR) cfe $@ Main -C build/converter . -C src/res .
|
||||
$(RM) -r build/converter
|
||||
|
||||
%.class: %.java
|
||||
$(JAVAC) -source $(JAVA_TARGET) -target $(JAVA_TARGET) -Xlint:-options -g:none $^
|
||||
$(JAVAC) $(JAVAC_OPTIONS) -g:none $^
|
||||
|
||||
build/test/cpptests: $(CPP_TEST_SOURCES) $(CPP_TEST_HEADER) $(SOURCES) $(HEADERS) $(RESOURCES) $(JAVA_HELPER_CLASSES)
|
||||
mkdir -p build/test
|
||||
ifeq ($(MERGE),true)
|
||||
for f in src/*.cpp test/native/*.cpp; do echo '#include "'$$f'"'; done |\
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFS) $(INCLUDES) $(CPP_TEST_INCLUDES) -fPIC -o $@ -xc++ - $(LIBS)
|
||||
else
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFS) $(INCLUDES) $(CPP_TEST_INCLUDES) -fPIC -o $@ $(SOURCES) $(CPP_TEST_SOURCES) $(LIBS)
|
||||
endif
|
||||
test: all
|
||||
test/smoke-test.sh
|
||||
test/thread-smoke-test.sh
|
||||
test/alloc-smoke-test.sh
|
||||
test/load-library-test.sh
|
||||
test/fdtransfer-smoke-test.sh
|
||||
echo "All tests passed"
|
||||
|
||||
build-test-java: all build/$(TEST_JAR) build/test/build-test-libs build/test/build-test-bins
|
||||
|
||||
build-test-cpp: build/test/cpptests build/test/build-test-libs
|
||||
|
||||
build-test: build-test-cpp build-test-java
|
||||
|
||||
build/test/build-test-libs: $(TEST_LIB_SOURCES)
|
||||
@mkdir -p $(TEST_LIB_DIR)
|
||||
$(CC) -shared -fPIC -o $(TEST_LIB_DIR)/libreladyn.$(SOEXT) test/native/libs/reladyn.c
|
||||
$(CC) -shared -fPIC -o $(TEST_LIB_DIR)/libcallsmalloc.$(SOEXT) test/native/libs/callsmalloc.c
|
||||
$(CC) -shared -fPIC $(INCLUDES) -Isrc -o $(TEST_LIB_DIR)/libjnimalloc.$(SOEXT) test/native/libs/jnimalloc.c
|
||||
$(CC) -shared -fPIC -o $(TEST_LIB_DIR)/libmalloc.$(SOEXT) test/native/libs/malloc.c
|
||||
$(CC) -fno-optimize-sibling-calls -shared -fPIC $(INCLUDES) -Isrc -o $(TEST_LIB_DIR)/libjninativestacks.$(SOEXT) test/native/libs/jninativestacks.c
|
||||
$(CC) -shared -fPIC $(INCLUDES) -Isrc -o $(TEST_LIB_DIR)/libjninativelocks.$(SOEXT) test/native/libs/jninativelocks.c -lpthread
|
||||
|
||||
ifeq ($(OS_TAG),linux)
|
||||
$(CC) -c -shared -fPIC -o $(TEST_LIB_DIR)/vaddrdif.o test/native/libs/vaddrdif.c
|
||||
$(LD) -N -shared -o $(TEST_LIB_DIR)/libvaddrdif.$(SOEXT) $(TEST_LIB_DIR)/vaddrdif.o -T test/native/libs/vaddrdif.ld
|
||||
|
||||
$(AS) -o $(TEST_LIB_DIR)/multiplematching.o test/native/libs/multiplematching.s
|
||||
$(LD) -shared -o $(TEST_LIB_DIR)/multiplematching.$(SOEXT) $(TEST_LIB_DIR)/multiplematching.o
|
||||
|
||||
$(AS) -o $(TEST_LIB_DIR)/twiceatzero.o test/native/libs/twiceatzero.s
|
||||
$(LD) -shared -o $(TEST_LIB_DIR)/libtwiceatzero.$(SOEXT) $(TEST_LIB_DIR)/twiceatzero.o --section-start=.seg1=0x4000 -z max-page-size=0x1000
|
||||
endif
|
||||
@touch $@
|
||||
|
||||
build/test/build-test-bins: $(TEST_BIN_SOURCES)
|
||||
@mkdir -p $(TEST_BIN_DIR)
|
||||
$(CC) -o $(TEST_BIN_DIR)/malloc_plt_dyn test/test/nativemem/malloc_plt_dyn.c
|
||||
$(CC) -o $(TEST_BIN_DIR)/native_api -Isrc test/test/c/native_api.c -ldl
|
||||
$(CC) -o $(TEST_BIN_DIR)/native_lock_contention test/test/nativelock/native_lock_contention.c -lpthread
|
||||
$(CC) -o $(TEST_BIN_DIR)/profile_with_dlopen -Isrc test/test/nativemem/profile_with_dlopen.c -ldl
|
||||
$(CC) -o $(TEST_BIN_DIR)/preload_malloc -Isrc test/test/nativemem/preload_malloc.c -ldl
|
||||
$(CC) -o $(TEST_BIN_DIR)/nativemem_known_lib_crash -Isrc test/test/nativemem/nativemem_known_lib_crash.c -ldl
|
||||
$(CXX) -o $(TEST_BIN_DIR)/non_java_app -std=c++11 $(INCLUDES) $(CPP_TEST_INCLUDES) test/test/nonjava/non_java_app.cpp $(LIBS)
|
||||
@touch $@
|
||||
|
||||
test-cpp: build-test-cpp
|
||||
echo "Running cpp tests..."
|
||||
LD_LIBRARY_PATH="$(TEST_LIB_DIR)" DYLD_LIBRARY_PATH="$(TEST_LIB_DIR)" build/test/cpptests
|
||||
|
||||
test-java: build-test-java
|
||||
echo "Running tests against $(LIB_PROFILER)"
|
||||
$(TEST_JAVA) $(TEST_FLAGS) -ea -cp "build/$(TEST_JAR):build/jar/*:$(TEST_DEPS_DIR)/*:$(TEST_GEN_DIR)/*" one.profiler.test.Runner $(subst $(COMMA), ,$(TESTS))
|
||||
|
||||
coverage: override FAT_BINARY=false
|
||||
coverage: clean-coverage
|
||||
$(MAKE) test-cpp CXXFLAGS_EXTRA="-fprofile-arcs -ftest-coverage -fPIC -O0 --coverage"
|
||||
mkdir -p build/test/coverage
|
||||
cd build/test/ && gcovr -r ../.. --html-details --gcov-executable "$(GCOV)" -o coverage/index.html
|
||||
rm -rf -- -.gc*
|
||||
|
||||
# unit tests shouldn't run if the user selects an integration test target
|
||||
ifeq ($(TESTS),)
|
||||
TEST_CPP := test-cpp
|
||||
endif
|
||||
|
||||
test: $(TEST_CPP) test-java
|
||||
|
||||
$(TEST_DEPS_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
build/$(TEST_JAR): build/$(API_JAR) $(TEST_SOURCES) build/$(CONVERTER_JAR) $(TEST_DEPS_DIR)
|
||||
rm -rf build/test/classes
|
||||
mkdir -p build/test/classes
|
||||
$(JAVAC) -source $(JAVA_TARGET) -target $(JAVA_TARGET) -Xlint:-options -XDignore.symbol.file \
|
||||
-implicit:none \
|
||||
-cp "build/jar/*:$(TEST_DEPS_DIR)/*:$(TEST_GEN_DIR)/*:test/stubs" \
|
||||
-d build/test/classes \
|
||||
$(TEST_SOURCES)
|
||||
$(JAR) cf $@ -C build/test/classes .
|
||||
|
||||
update-otlp-classes-jar:
|
||||
@if [ -z "$(OTEL_PROTO_PATH)" ]; then \
|
||||
echo "'OTEL_PROTO_PATH' is empty"; \
|
||||
exit 1; \
|
||||
fi
|
||||
rm -rf $(TMP_DIR)/gen/java $(TMP_DIR)/build
|
||||
mkdir -p $(TMP_DIR)/gen/java $(TMP_DIR)/build $(TEST_GEN_DIR)
|
||||
cd $(OTEL_PROTO_PATH) && protoc --java_out=$(TMP_DIR)/gen/java $$(find . \
|
||||
-type f \
|
||||
-name '*.proto' \
|
||||
-not \( -name 'logs*.proto' -o -name 'metrics*.proto' -o -name 'trace*.proto' -o -name '*service.proto' \))
|
||||
$(JAVAC) -source $(JAVA_TARGET) \
|
||||
-target $(JAVA_TARGET) \
|
||||
-cp $(TEST_DEPS_DIR)/* \
|
||||
-d $(TMP_DIR)/build \
|
||||
-Xlint:-options \
|
||||
$$(find $(TMP_DIR)/gen/java -name "*.java")
|
||||
$(JAR) cvf $(TEST_GEN_DIR)/opentelemetry-gen-classes.jar -C $(TMP_DIR)/build .
|
||||
|
||||
LINT_SOURCES=`ls -1 src/*.cpp src/*/*.cpp | grep -v rustDemangle.cpp`
|
||||
CLANG_TIDY_ARGS_EXTRA=
|
||||
cpp-lint:
|
||||
clang-tidy $(LINT_SOURCES) $(CLANG_TIDY_ARGS_EXTRA) -- -x c++ $(CXXFLAGS) $(INCLUDES) $(DEFS) $(LIBS)
|
||||
|
||||
DIFF_BASE=
|
||||
cpp-lint-diff:
|
||||
git diff -U0 $(DIFF_BASE) -- 'src/*.cpp' 'src/**/*.cpp' 'src/*.h' 'src/**/*.h' ':!**/rustDemangle.cpp' | \
|
||||
clang-tidy-diff.py -p1 $(CLANG_TIDY_ARGS_EXTRA) -- -x c++ $(CXXFLAGS) $(INCLUDES) $(DEFS) $(LIBS)
|
||||
|
||||
check-md:
|
||||
prettier -c README.md "docs/**/*.md"
|
||||
|
||||
format-md:
|
||||
prettier -w README.md "docs/**/*.md"
|
||||
|
||||
clean-coverage:
|
||||
$(RM) -rf build/test/cpptests build/test/coverage
|
||||
native:
|
||||
mkdir -p native/linux-x64 native/linux-arm64 native/macos
|
||||
tar xfO async-profiler-$(PROFILER_VERSION)-linux-x64.tar.gz */build/libasyncProfiler.so > native/linux-x64/libasyncProfiler.so
|
||||
tar xfO async-profiler-$(PROFILER_VERSION)-linux-arm64.tar.gz */build/libasyncProfiler.so > native/linux-arm64/libasyncProfiler.so
|
||||
unzip -p async-profiler-$(PROFILER_VERSION)-macos.zip */build/libasyncProfiler.so > native/macos/libasyncProfiler.so
|
||||
|
||||
clean:
|
||||
$(RM) -r build
|
||||
|
||||
669
README.md
@@ -1,117 +1,636 @@
|
||||
# Async-profiler
|
||||
# async-profiler
|
||||
|
||||
This project is a low overhead sampling profiler for Java
|
||||
that does not suffer from the [Safepoint bias problem](http://psy-lob-saw.blogspot.ru/2016/02/why-most-sampling-java-profilers-are.html).
|
||||
It features HotSpot-specific API to collect stack traces
|
||||
that does not suffer from [Safepoint bias problem](http://psy-lob-saw.blogspot.ru/2016/02/why-most-sampling-java-profilers-are.html).
|
||||
It features HotSpot-specific APIs to collect stack traces
|
||||
and to track memory allocations. The profiler works with
|
||||
OpenJDK and other Java runtimes based on the HotSpot JVM.
|
||||
OpenJDK, Oracle JDK and other Java runtimes based on the HotSpot JVM.
|
||||
|
||||
Unlike traditional Java profilers, async-profiler monitors non-Java threads
|
||||
(e.g., GC and JIT compiler threads) and shows native and kernel frames in stack traces.
|
||||
async-profiler can trace the following kinds of events:
|
||||
- CPU cycles
|
||||
- Hardware and Software performance counters like cache misses, branch misses, page faults, context switches etc.
|
||||
- Allocations in Java Heap
|
||||
- Contented lock attempts, including both Java object monitors and ReentrantLocks
|
||||
|
||||
What can be profiled:
|
||||
See our [Wiki](https://github.com/jvm-profiling-tools/async-profiler/wiki) or
|
||||
[3 hours playlist](https://www.youtube.com/playlist?list=PLNCLTEx3B8h4Yo_WvKWdLvI9mj1XpTKBr)
|
||||
to learn about all features.
|
||||
|
||||
- CPU time
|
||||
- Allocations in Java Heap
|
||||
- Native memory allocations and leaks
|
||||
- Contended locks
|
||||
- Hardware and software performance counters like cache misses, page faults, context switches
|
||||
- and [more](docs/ProfilingModes.md).
|
||||
## Download
|
||||
|
||||
See our [3 hours playlist](https://www.youtube.com/playlist?list=PLNCLTEx3B8h4Yo_WvKWdLvI9mj1XpTKBr)
|
||||
to learn about more features.
|
||||
Current release (2.9):
|
||||
|
||||
# Download
|
||||
- Linux x64 (glibc): [async-profiler-2.9-linux-x64.tar.gz](https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.9/async-profiler-2.9-linux-x64.tar.gz)
|
||||
- Linux x64 (musl): [async-profiler-2.9-linux-musl-x64.tar.gz](https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.9/async-profiler-2.9-linux-musl-x64.tar.gz)
|
||||
- Linux arm64: [async-profiler-2.9-linux-arm64.tar.gz](https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.9/async-profiler-2.9-linux-arm64.tar.gz)
|
||||
- macOS x64/arm64: [async-profiler-2.9-macos.zip](https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.9/async-profiler-2.9-macos.zip)
|
||||
- Converters between profile formats: [converter.jar](https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.9/converter.jar)
|
||||
(JFR to Flame Graph, JFR to FlameScope, collapsed stacks to Flame Graph)
|
||||
|
||||
### Stable release: [4.4](https://github.com/async-profiler/async-profiler/releases/tag/v4.4)
|
||||
[Previous releases](https://github.com/jvm-profiling-tools/async-profiler/releases)
|
||||
|
||||
- Linux x64: [async-profiler-4.4-linux-x64.tar.gz](https://github.com/async-profiler/async-profiler/releases/download/v4.4/async-profiler-4.4-linux-x64.tar.gz)
|
||||
- Linux arm64: [async-profiler-4.4-linux-arm64.tar.gz](https://github.com/async-profiler/async-profiler/releases/download/v4.4/async-profiler-4.4-linux-arm64.tar.gz)
|
||||
- macOS arm64/x64: [async-profiler-4.4-macos.zip](https://github.com/async-profiler/async-profiler/releases/download/v4.4/async-profiler-4.4-macos.zip)
|
||||
- Profile converters: [jfr-converter.jar](https://github.com/async-profiler/async-profiler/releases/download/v4.4/jfr-converter.jar)
|
||||
Note: async-profiler also comes bundled with IntelliJ IDEA Ultimate 2018.3 and later.
|
||||
For more information refer to [IntelliJ IDEA documentation](https://www.jetbrains.com/help/idea/cpu-and-allocation-profiling-basic-concepts.html).
|
||||
|
||||
### Nightly builds
|
||||
## Supported platforms
|
||||
|
||||
[The most recent binaries](https://github.com/async-profiler/async-profiler/releases/tag/nightly) corresponding
|
||||
to the latest successful commit in `master`.
|
||||
- **Linux** / x64 / x86 / arm64 / arm32 / ppc64le
|
||||
- **macOS** / x64 / arm64
|
||||
|
||||
For a build corresponding to one of the previous commits, go to
|
||||
[Nightly Builds](https://github.com/async-profiler/async-profiler/actions/workflows/test-and-publish-nightly.yml),
|
||||
click the desired build and scroll down to the artifacts section. These binaries are kept for 30 days.
|
||||
### Community supported builds
|
||||
|
||||
# Quick start
|
||||
- **Windows** / x64 - <img src="https://upload.wikimedia.org/wikipedia/commons/9/9c/IntelliJ_IDEA_Icon.svg" width="16" height="16"/> [IntelliJ IDEA](https://www.jetbrains.com/idea/) 2021.2 and later
|
||||
- [**ap-loader**](https://github.com/jvm-profiling-tools/ap-loader) -
|
||||
all-in-one JAR for using async-profiler in Java programs and as a CLI tool
|
||||
|
||||
In a typical use case, profiling a Java application is just a matter of a running `asprof` with a PID of a
|
||||
running Java process.
|
||||
## CPU profiling
|
||||
|
||||
In this mode profiler collects stack trace samples that include **Java** methods,
|
||||
**native** calls, **JVM** code and **kernel** functions.
|
||||
|
||||
The general approach is receiving call stacks generated by `perf_events`
|
||||
and matching them up with call stacks generated by `AsyncGetCallTrace`,
|
||||
in order to produce an accurate profile of both Java and native code.
|
||||
Additionally, async-profiler provides a workaround to recover stack traces
|
||||
in some [corner cases](https://bugs.openjdk.java.net/browse/JDK-8178287)
|
||||
where `AsyncGetCallTrace` fails.
|
||||
|
||||
This approach has the following advantages compared to using `perf_events`
|
||||
directly with a Java agent that translates addresses to Java method names:
|
||||
|
||||
* Works on older Java versions because it doesn't require
|
||||
`-XX:+PreserveFramePointer`, which is only available in JDK 8u60 and later.
|
||||
|
||||
* Does not introduce the performance overhead from `-XX:+PreserveFramePointer`,
|
||||
which can in rare cases be as high as 10%.
|
||||
|
||||
* Does not require generating a map file to map Java code addresses to method
|
||||
names.
|
||||
|
||||
* Works with interpreter frames.
|
||||
|
||||
* Does not require writing out a perf.data file for further processing in
|
||||
user space scripts.
|
||||
|
||||
If you wish to resolve frames within `libjvm`, the [debug symbols](#installing-debug-symbols) are required.
|
||||
|
||||
## ALLOCATION profiling
|
||||
|
||||
Instead of detecting CPU-consuming code, the profiler can be configured
|
||||
to collect call sites where the largest amount of heap memory is allocated.
|
||||
|
||||
async-profiler does not use intrusive techniques like bytecode instrumentation
|
||||
or expensive DTrace probes which have significant performance impact.
|
||||
It also does not affect Escape Analysis or prevent from JIT optimizations
|
||||
like allocation elimination. Only actual heap allocations are measured.
|
||||
|
||||
The profiler features TLAB-driven sampling. It relies on HotSpot-specific
|
||||
callbacks to receive two kinds of notifications:
|
||||
- when an object is allocated in a newly created TLAB (aqua frames in a Flame Graph);
|
||||
- when an object is allocated on a slow path outside TLAB (brown frames).
|
||||
|
||||
This means not each allocation is counted, but only allocations every _N_ kB,
|
||||
where _N_ is the average size of TLAB. This makes heap sampling very cheap
|
||||
and suitable for production. On the other hand, the collected data
|
||||
may be incomplete, though in practice it will often reflect the top allocation
|
||||
sources.
|
||||
|
||||
Sampling interval can be adjusted with `--alloc` option.
|
||||
For example, `--alloc 500k` will take one sample after 500 KB of allocated
|
||||
space on average. However, intervals less than TLAB size will not take effect.
|
||||
|
||||
The minimum supported JDK version is 7u40 where the TLAB callbacks appeared.
|
||||
|
||||
### Installing Debug Symbols
|
||||
|
||||
Prior to JDK 11, the allocation profiler required HotSpot debug symbols.
|
||||
Oracle JDK already has them embedded in `libjvm.so`, but in OpenJDK builds
|
||||
they are typically shipped in a separate package. For example, to install
|
||||
OpenJDK debug symbols on Debian / Ubuntu, run:
|
||||
```
|
||||
$ asprof -d 30 -f flamegraph.html <PID>
|
||||
# apt install openjdk-8-dbg
|
||||
```
|
||||
or for OpenJDK 11:
|
||||
```
|
||||
# apt install openjdk-11-dbg
|
||||
```
|
||||
|
||||
The above command translates to: run profiler for 30 seconds and save results to `flamegraph.html`
|
||||
as an interactive [Flame Graph](docs/FlamegraphInterpretation.md) that can be viewed in a browser.
|
||||
On CentOS, RHEL and some other RPM-based distributions, this could be done with
|
||||
[debuginfo-install](http://man7.org/linux/man-pages/man1/debuginfo-install.1.html) utility:
|
||||
```
|
||||
# debuginfo-install java-1.8.0-openjdk
|
||||
```
|
||||
|
||||
[](https://htmlpreview.github.io/?https://github.com/async-profiler/async-profiler/blob/master/.assets/html/flamegraph.html)
|
||||
On Gentoo the `icedtea` OpenJDK package can be built with the per-package setting
|
||||
`FEATURES="nostrip"` to retain symbols.
|
||||
|
||||
Find more details in the [Getting started guide](docs/GettingStarted.md).
|
||||
The `gdb` tool can be used to verify if the debug symbols are properly installed for the `libjvm` library.
|
||||
For example on Linux:
|
||||
```
|
||||
$ gdb $JAVA_HOME/lib/server/libjvm.so -ex 'info address UseG1GC'
|
||||
```
|
||||
This command's output will either contain `Symbol "UseG1GC" is at 0xxxxx`
|
||||
or `No symbol "UseG1GC" in current context`.
|
||||
|
||||
# Building
|
||||
## Wall-clock profiling
|
||||
|
||||
### Build status
|
||||
`-e wall` option tells async-profiler to sample all threads equally every given
|
||||
period of time regardless of thread status: Running, Sleeping or Blocked.
|
||||
For instance, this can be helpful when profiling application start-up time.
|
||||
|
||||
[](https://github.com/async-profiler/async-profiler/actions/workflows/test-and-publish-nightly.yml)
|
||||
Wall-clock profiler is most useful in per-thread mode: `-t`.
|
||||
|
||||
### Minimum requirements
|
||||
Example: `./profiler.sh -e wall -t -i 5ms -f result.html 8983`
|
||||
|
||||
- make
|
||||
- GCC 7.5.0+ or Clang 7.0.0+
|
||||
- Static version of libstdc++ (e.g. on Amazon Linux 2023: `yum install libstdc++-static`)
|
||||
- JDK 11+
|
||||
## Java method profiling
|
||||
|
||||
### How to build
|
||||
`-e ClassName.methodName` option instruments the given Java method
|
||||
in order to record all invocations of this method with the stack traces.
|
||||
|
||||
Make sure `gcc`, `g++` and `java` are available on the `PATH`.
|
||||
Navigate to the root directory with async-profiler sources and run `make`.
|
||||
async-profiler launcher will be available at `build/bin/asprof`.
|
||||
Example: `-e java.util.Properties.getProperty` will profile all places
|
||||
where `getProperty` method is called from.
|
||||
|
||||
Other Makefile targets:
|
||||
Only non-native Java methods are supported. To profile a native method,
|
||||
use hardware breakpoint event instead, e.g. `-e Java_java_lang_Throwable_fillInStackTrace`
|
||||
|
||||
- `make test` - run unit and integration tests;
|
||||
- `make release` - package async-profiler binaries as `.tar.gz` (Linux) or `.zip` (macOS).
|
||||
**Be aware** that if you attach async-profiler at runtime, the first instrumentation
|
||||
of a non-native Java method may cause the [deoptimization](https://github.com/openjdk/jdk/blob/bf2e9ee9d321ed289466b2410f12ad10504d01a2/src/hotspot/share/prims/jvmtiRedefineClasses.cpp#L4092-L4096)
|
||||
of all compiled methods. The subsequent instrumentation flushes only the _dependent code_.
|
||||
|
||||
### Supported platforms
|
||||
The massive CodeCache flush doesn't occur if attaching async-profiler as an agent.
|
||||
|
||||
| | Officially maintained builds | Other available ports |
|
||||
| --------- | ---------------------------- | ----------------------------------------- |
|
||||
| **Linux** | x64, arm64 | x86, arm32, ppc64le, riscv64, loongarch64 |
|
||||
| **macOS** | x64, arm64 | |
|
||||
Here are some useful native methods that you may want to profile:
|
||||
* ```G1CollectedHeap::humongous_obj_allocate``` - trace the _humongous allocation_ of the G1 GC,
|
||||
* ```JVM_StartThread``` - trace the new thread creation,
|
||||
* ```Java_java_lang_ClassLoader_defineClass1``` - trace class loading.
|
||||
|
||||
# Documentation
|
||||
## Building
|
||||
|
||||
## Basic usage
|
||||
Build status: [](https://github.com/jvm-profiling-tools/async-profiler/actions/workflows/cpp.yml)
|
||||
|
||||
- [Getting Started](docs/GettingStarted.md)
|
||||
- [Profiler Options](docs/ProfilerOptions.md)
|
||||
- [Profiling Modes](docs/ProfilingModes.md)
|
||||
- [Integrating async-profiler](docs/IntegratingAsyncProfiler.md)
|
||||
- [Profiling In Container](docs/ProfilingInContainer.md)
|
||||
Make sure the `JAVA_HOME` environment variable points to your JDK installation,
|
||||
and then run `make`. GCC is required. After building, the profiler agent binary
|
||||
will be in the `build` subdirectory. Additionally, a small application `jattach`
|
||||
that can load the agent into the target process will also be compiled to the
|
||||
`build` subdirectory. If the build fails due to
|
||||
`Source option 7 is no longer supported. Use 8 or later.`, use `make JAVA_TARGET=8`.
|
||||
|
||||
## Profiler output
|
||||
## Basic Usage
|
||||
|
||||
- [Output Formats](docs/OutputFormats.md)
|
||||
- [FlameGraph Interpretation](docs/FlamegraphInterpretation.md)
|
||||
- [JFR Visualization](docs/JfrVisualization.md)
|
||||
- [Converter Usage](docs/ConverterUsage.md)
|
||||
- [Heatmap](docs/Heatmap.md)
|
||||
As of Linux 4.6, capturing kernel call stacks using `perf_events` from a non-root
|
||||
process requires setting two runtime variables. You can set them using
|
||||
sysctl or as follows:
|
||||
|
||||
## Advanced usage
|
||||
```
|
||||
# sysctl kernel.perf_event_paranoid=1
|
||||
# sysctl kernel.kptr_restrict=0
|
||||
```
|
||||
|
||||
- [CPU Sampling Engines](docs/CpuSamplingEngines.md)
|
||||
- [Stack Walking Modes](docs/StackWalkingModes.md)
|
||||
- [Advanced Stacktrace Features](docs/AdvancedStacktraceFeatures.md)
|
||||
- [Profiling Non-Java Applications](docs/ProfilingNonJavaApplications.md)
|
||||
To run the agent and pass commands to it, the helper script `profiler.sh`
|
||||
is provided. A typical workflow would be to launch your Java application,
|
||||
attach the agent and start profiling, exercise your performance scenario, and
|
||||
then stop profiling. The agent's output, including the profiling results, will
|
||||
be displayed in the Java application's standard output.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
$ jps
|
||||
9234 Jps
|
||||
8983 Computey
|
||||
$ ./profiler.sh start 8983
|
||||
$ ./profiler.sh stop 8983
|
||||
```
|
||||
|
||||
The following may be used in lieu of the `pid` (8983):
|
||||
|
||||
- The keyword `jps`, which will use the most recently launched Java process.
|
||||
- The application name as it appears in the `jps` output: e.g. `Computey`
|
||||
|
||||
Alternatively, you may specify `-d` (duration) argument to profile
|
||||
the application for a fixed period of time with a single command.
|
||||
|
||||
```
|
||||
$ ./profiler.sh -d 30 8983
|
||||
```
|
||||
|
||||
By default, the profiling frequency is 100Hz (every 10ms of CPU time).
|
||||
Here is a sample of the output printed to the Java application's terminal:
|
||||
|
||||
```
|
||||
--- Execution profile ---
|
||||
Total samples: 687
|
||||
Unknown (native): 1 (0.15%)
|
||||
|
||||
--- 6790000000 (98.84%) ns, 679 samples
|
||||
[ 0] Primes.isPrime
|
||||
[ 1] Primes.primesThread
|
||||
[ 2] Primes.access$000
|
||||
[ 3] Primes$1.run
|
||||
[ 4] java.lang.Thread.run
|
||||
|
||||
... a lot of output omitted for brevity ...
|
||||
|
||||
ns percent samples top
|
||||
---------- ------- ------- ---
|
||||
6790000000 98.84% 679 Primes.isPrime
|
||||
40000000 0.58% 4 __do_softirq
|
||||
|
||||
... more output omitted ...
|
||||
```
|
||||
|
||||
This indicates that the hottest method was `Primes.isPrime`, and the hottest
|
||||
call stack leading to it comes from `Primes.primesThread`.
|
||||
|
||||
## Launching as an Agent
|
||||
|
||||
If you need to profile some code as soon as the JVM starts up, instead of using the `profiler.sh` script,
|
||||
it is possible to attach async-profiler as an agent on the command line. For example:
|
||||
|
||||
```
|
||||
$ java -agentpath:/path/to/libasyncProfiler.so=start,event=cpu,file=profile.html ...
|
||||
```
|
||||
|
||||
Agent library is configured through the JVMTI argument interface.
|
||||
The format of the arguments string is described
|
||||
[in the source code](https://github.com/jvm-profiling-tools/async-profiler/blob/v2.9/src/arguments.cpp#L52).
|
||||
The `profiler.sh` script actually converts command line arguments to that format.
|
||||
|
||||
For instance, `-e wall` is converted to `event=wall`, `-f profile.html`
|
||||
is converted to `file=profile.html`, and so on. However, some arguments are processed
|
||||
directly by `profiler.sh` script. E.g. `-d 5` results in 3 actions:
|
||||
attaching profiler agent with start command, sleeping for 5 seconds,
|
||||
and then attaching the agent again with stop command.
|
||||
|
||||
## Multiple events
|
||||
|
||||
It is possible to profile CPU, allocations, and locks at the same time.
|
||||
Or, instead of CPU, you may choose any other execution event: wall-clock,
|
||||
perf event, tracepoint, Java method, etc.
|
||||
|
||||
The only output format that supports multiple events together is JFR.
|
||||
The recording will contain the following event types:
|
||||
- `jdk.ExecutionSample`
|
||||
- `jdk.ObjectAllocationInNewTLAB` (alloc)
|
||||
- `jdk.ObjectAllocationOutsideTLAB` (alloc)
|
||||
- `jdk.JavaMonitorEnter` (lock)
|
||||
- `jdk.ThreadPark` (lock)
|
||||
|
||||
To start profiling cpu + allocations + locks together, specify
|
||||
```
|
||||
./profiler.sh -e cpu,alloc,lock -f profile.jfr ...
|
||||
```
|
||||
or use `--alloc` and `--lock` parameters with the desired threshold:
|
||||
```
|
||||
./profiler.sh -e cpu --alloc 2m --lock 10ms -f profile.jfr ...
|
||||
```
|
||||
The same, when starting profiler as an agent:
|
||||
```
|
||||
-agentpath:/path/to/libasyncProfiler.so=start,event=cpu,alloc=2m,lock=10ms,file=profile.jfr
|
||||
```
|
||||
|
||||
## Flame Graph visualization
|
||||
|
||||
async-profiler provides out-of-the-box [Flame Graph](https://github.com/BrendanGregg/FlameGraph) support.
|
||||
Specify `-o flamegraph` argument to dump profiling results as an interactive HTML Flame Graph.
|
||||
Also, Flame Graph output format will be chosen automatically if the target filename ends with `.html`.
|
||||
|
||||
```
|
||||
$ jps
|
||||
9234 Jps
|
||||
8983 Computey
|
||||
$ ./profiler.sh -d 30 -f /tmp/flamegraph.html 8983
|
||||
```
|
||||
|
||||
[](https://htmlpreview.github.io/?https://github.com/jvm-profiling-tools/async-profiler/blob/master/demo/flamegraph.html)
|
||||
|
||||
## Profiler Options
|
||||
|
||||
The following is a complete list of the command-line options accepted by
|
||||
`profiler.sh` script.
|
||||
|
||||
* `start` - starts profiling in semi-automatic mode, i.e. profiler will run
|
||||
until `stop` command is explicitly called.
|
||||
|
||||
* `resume` - starts or resumes earlier profiling session that has been stopped.
|
||||
All the collected data remains valid. The profiling options are not preserved
|
||||
between sessions, and should be specified again.
|
||||
|
||||
* `stop` - stops profiling and prints the report.
|
||||
|
||||
* `dump` - dump collected data without stopping profiling session.
|
||||
|
||||
* `check` - check if the specified profiling event is available.
|
||||
|
||||
* `status` - prints profiling status: whether profiler is active and
|
||||
for how long.
|
||||
|
||||
* `meminfo` - prints used memory statistics.
|
||||
|
||||
* `list` - show the list of profiling events available for the target process
|
||||
(if PID is specified) or for the default JVM.
|
||||
|
||||
* `-d N` - the profiling duration, in seconds. If no `start`, `resume`, `stop`
|
||||
or `status` option is given, the profiler will run for the specified period
|
||||
of time and then automatically stop.
|
||||
Example: `./profiler.sh -d 30 8983`
|
||||
|
||||
* `-e event` - the profiling event: `cpu`, `alloc`, `lock`, `cache-misses` etc.
|
||||
Use `list` to see the complete list of available events.
|
||||
|
||||
In allocation profiling mode the top frame of every call trace is the class
|
||||
of the allocated object, and the counter is the heap pressure (the total size
|
||||
of allocated TLABs or objects outside TLAB).
|
||||
|
||||
In lock profiling mode the top frame is the class of lock/monitor, and
|
||||
the counter is number of nanoseconds it took to enter this lock/monitor.
|
||||
|
||||
Two special event types are supported on Linux: hardware breakpoints
|
||||
and kernel tracepoints:
|
||||
- `-e mem:<func>[:rwx]` sets read/write/exec breakpoint at function
|
||||
`<func>`. The format of `mem` event is the same as in `perf-record`.
|
||||
Execution breakpoints can be also specified by the function name,
|
||||
e.g. `-e malloc` will trace all calls of native `malloc` function.
|
||||
- `-e trace:<id>` sets a kernel tracepoint. It is possible to specify
|
||||
tracepoint symbolic name, e.g. `-e syscalls:sys_enter_open` will trace
|
||||
all `open` syscalls.
|
||||
|
||||
* `-i N` - sets the profiling interval in nanoseconds or in other units,
|
||||
if N is followed by `ms` (for milliseconds), `us` (for microseconds),
|
||||
or `s` (for seconds). Only CPU active time is counted. No samples
|
||||
are collected while CPU is idle. The default is 10000000 (10ms).
|
||||
Example: `./profiler.sh -i 500us 8983`
|
||||
|
||||
* `--alloc N` - allocation profiling interval in bytes or in other units,
|
||||
if N is followed by `k` (kilobytes), `m` (megabytes), or `g` (gigabytes).
|
||||
|
||||
* `--live` - retain allocation samples with live objects only
|
||||
(object that have not been collected by the end of profiling session).
|
||||
Useful for finding Java heap memory leaks.
|
||||
|
||||
* `--lock N` - lock profiling threshold in nanoseconds (or other units).
|
||||
In lock profiling mode, record contended locks that the JVM has waited for
|
||||
longer than the specified duration.
|
||||
|
||||
* `-j N` - sets the Java stack profiling depth. This option will be ignored if N is greater
|
||||
than default 2048.
|
||||
Example: `./profiler.sh -j 30 8983`
|
||||
|
||||
* `-t` - profile threads separately. Each stack trace will end with a frame
|
||||
that denotes a single thread.
|
||||
Example: `./profiler.sh -t 8983`
|
||||
|
||||
* `-s` - print simple class names instead of FQN.
|
||||
|
||||
* `-g` - print method signatures.
|
||||
|
||||
* `-a` - annotate JIT compiled methods with `_[j]`, inlined methods with `_[i]`, interpreted methods with `_[0]` and C1 compiled methods with `_[1]`.
|
||||
|
||||
* `-l` - prepend library names to symbols, e.g. ``libjvm.so`JVM_DefineClassWithSource``.
|
||||
|
||||
* `-o fmt` - specifies what information to dump when profiling ends.
|
||||
`fmt` can be one of the following options:
|
||||
- `traces[=N]` - dump call traces (at most N samples);
|
||||
- `flat[=N]` - dump flat profile (top N hot methods);
|
||||
can be combined with `traces`, e.g. `traces=200,flat=200`
|
||||
- `jfr` - dump events in Java Flight Recorder format readable by Java Mission Control.
|
||||
This *does not* require JDK commercial features to be enabled.
|
||||
- `collapsed` - dump collapsed call traces in the format used by
|
||||
[FlameGraph](https://github.com/brendangregg/FlameGraph) script. This is
|
||||
a collection of call stacks, where each line is a semicolon separated list
|
||||
of frames followed by a counter.
|
||||
- `flamegraph` - produce Flame Graph in HTML format.
|
||||
- `tree` - produce Call Tree in HTML format.
|
||||
`--reverse` option will generate backtrace view.
|
||||
|
||||
* `--total` - count the total value of the collected metric instead of the number of samples,
|
||||
e.g. total allocation size.
|
||||
|
||||
* `--chunksize N`, `--chunktime N` - approximate size and time limits for a single JFR chunk.
|
||||
Example: `./profiler.sh -f profile.jfr --chunksize 100m --chunktime 1h 8983`
|
||||
|
||||
* `-I include`, `-X exclude` - filter stack traces by the given pattern(s).
|
||||
`-I` defines the name pattern that *must* be present in the stack traces,
|
||||
while `-X` is the pattern that *must not* occur in any of stack traces in the output.
|
||||
`-I` and `-X` options can be specified multiple times. A pattern may begin or end with
|
||||
a star `*` that denotes any (possibly empty) sequence of characters.
|
||||
Example: `./profiler.sh -I 'Primes.*' -I 'java/*' -X '*Unsafe.park*' 8983`
|
||||
|
||||
* `--title TITLE`, `--minwidth PERCENT`, `--reverse` - FlameGraph parameters.
|
||||
Example: `./profiler.sh -f profile.html --title "Sample CPU profile" --minwidth 0.5 8983`
|
||||
|
||||
* `-f FILENAME` - the file name to dump the profile information to.
|
||||
`%p` in the file name is expanded to the PID of the target JVM;
|
||||
`%t` - to the timestamp;
|
||||
`%n{MAX}` - to the sequence number;
|
||||
`%{ENV}` - to the value of the given environment variable.
|
||||
Example: `./profiler.sh -o collapsed -f /tmp/traces-%t.txt 8983`
|
||||
|
||||
* `--loop TIME` - run profiler in a loop (continuous profiling).
|
||||
The argument is either a clock time (`hh:mm:ss`) or
|
||||
a loop duration in `s`econds, `m`inutes, `h`ours, or `d`ays.
|
||||
Make sure the filename includes a timestamp pattern, or the output
|
||||
will be overwritten on each iteration.
|
||||
Example: `./profiler.sh --loop 1h -f /var/log/profile-%t.jfr 8983`
|
||||
|
||||
* `--all-user` - include only user-mode events. This option is helpful when kernel profiling
|
||||
is restricted by `perf_event_paranoid` settings.
|
||||
|
||||
* `--sched` - group threads by Linux-specific scheduling policy: BATCH/IDLE/OTHER.
|
||||
|
||||
* `--cstack MODE` - how to walk native frames (C stack). Possible modes are
|
||||
`fp` (Frame Pointer), `dwarf` (DWARF unwind info),
|
||||
`lbr` (Last Branch Record, available on Haswell since Linux 4.1),
|
||||
and `no` (do not collect C stack).
|
||||
|
||||
By default, C stack is shown in cpu, itimer, wall-clock and perf-events profiles.
|
||||
Java-level events like `alloc` and `lock` collect only Java stack.
|
||||
|
||||
* `--begin function`, `--end function` - automatically start/stop profiling
|
||||
when the specified native function is executed.
|
||||
|
||||
* `--ttsp` - time-to-safepoint profiling. An alias for
|
||||
`--begin SafepointSynchronize::begin --end RuntimeService::record_safepoint_synchronized`
|
||||
It is not a separate event type, but rather a constraint. Whatever event type
|
||||
you choose (e.g. `cpu` or `wall`), the profiler will work as usual, except that
|
||||
only events between the safepoint request and the start of the VM operation
|
||||
will be recorded.
|
||||
|
||||
* `--jfrsync CONFIG` - start Java Flight Recording with the given configuration
|
||||
synchronously with the profiler. The output .jfr file will include all regular
|
||||
JFR events, except that execution samples will be obtained from async-profiler.
|
||||
This option implies `-o jfr`.
|
||||
- `CONFIG` is a predefined JFR profile or a JFR configuration file (.jfc).
|
||||
|
||||
Example: `./profiler.sh -e cpu --jfrsync profile -f combined.jfr 8983`
|
||||
|
||||
* `--fdtransfer` - runs "fdtransfer" alongside, which is a small program providing an interface
|
||||
for the profiler to access `perf_event_open` even while this syscall is unavailable for the
|
||||
profiled process (due to low privileges).
|
||||
See [Profiling Java in a container](#profiling-java-in-a-container).
|
||||
|
||||
* `-v`, `--version` - prints the version of profiler library. If PID is specified,
|
||||
gets the version of the library loaded into the given process.
|
||||
|
||||
## Profiling Java in a container
|
||||
|
||||
It is possible to profile Java processes running in a Docker or LXC container
|
||||
both from within a container and from the host system.
|
||||
|
||||
When profiling from the host, `pid` should be the Java process ID in the host
|
||||
namespace. Use `ps aux | grep java` or `docker top <container>` to find
|
||||
the process ID.
|
||||
|
||||
async-profiler should be run from the host by a privileged user - it will
|
||||
automatically switch to the proper pid/mount namespace and change
|
||||
user credentials to match the target process. Also make sure that
|
||||
the target container can access `libasyncProfiler.so` by the same
|
||||
absolute path as on the host.
|
||||
|
||||
By default, Docker container restricts the access to `perf_event_open`
|
||||
syscall. There are 3 alternatives to allow profiling in a container:
|
||||
1. You can modify the [seccomp profile](https://docs.docker.com/engine/security/seccomp/)
|
||||
or disable it altogether with `--security-opt seccomp=unconfined` option. In
|
||||
addition, `--cap-add SYS_ADMIN` may be required.
|
||||
2. You can use "fdtransfer": see the help for `--fdtransfer`.
|
||||
3. Last, you may fall back to `-e itimer` profiling mode, see [Troubleshooting](#troubleshooting).
|
||||
|
||||
## Restrictions/Limitations
|
||||
|
||||
* macOS profiling is limited to user space code only.
|
||||
|
||||
* On most Linux systems, `perf_events` captures call stacks with a maximum depth
|
||||
of 127 frames. On recent Linux kernels, this can be configured using
|
||||
`sysctl kernel.perf_event_max_stack` or by writing to the
|
||||
`/proc/sys/kernel/perf_event_max_stack` file.
|
||||
|
||||
* Profiler allocates 8kB perf_event buffer for each thread of the target process.
|
||||
Make sure `/proc/sys/kernel/perf_event_mlock_kb` value is large enough
|
||||
(more than `8 * threads`) when running under unprivileged user.
|
||||
Otherwise the message _"perf_event mmap failed: Operation not permitted"_
|
||||
will be printed, and no native stack traces will be collected.
|
||||
|
||||
* There is no bullet-proof guarantee that the `perf_events` overflow signal
|
||||
is delivered to the Java thread in a way that guarantees no other code has run,
|
||||
which means that in some rare cases, the captured Java stack might not match
|
||||
the captured native (user+kernel) stack.
|
||||
|
||||
* You will not see the non-Java frames _preceding_ the Java frames on the
|
||||
stack. For example, if `start_thread` called `JavaMain` and then your Java
|
||||
code started running, you will not see the first two frames in the resulting
|
||||
stack. On the other hand, you _will_ see non-Java frames (user and kernel)
|
||||
invoked by your Java code.
|
||||
|
||||
* No Java stacks will be collected if `-XX:MaxJavaStackTraceDepth` is zero
|
||||
or negative.
|
||||
|
||||
* Too short profiling interval may cause continuous interruption of heavy
|
||||
system calls like `clone()`, so that it will never complete;
|
||||
see [#97](https://github.com/jvm-profiling-tools/async-profiler/issues/97).
|
||||
The workaround is simply to increase the interval.
|
||||
|
||||
* When agent is not loaded at JVM startup (by using -agentpath option) it is
|
||||
highly recommended to use `-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints` JVM flags.
|
||||
Without those flags the profiler will still work correctly but results might be
|
||||
less accurate. For example, without `-XX:+DebugNonSafepoints` there is a high chance
|
||||
that simple inlined methods will not appear in the profile. When the agent is attached at runtime,
|
||||
`CompiledMethodLoad` JVMTI event enables debug info, but only for methods compiled after attaching.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
For known issues faced while running async-profiler and their detailed troubleshooting,
|
||||
please refer [here](docs/Troubleshooting.md).
|
||||
```
|
||||
Failed to change credentials to match the target process: Operation not permitted
|
||||
```
|
||||
Due to limitation of HotSpot Dynamic Attach mechanism, the profiler must be run
|
||||
by exactly the same user (and group) as the owner of target JVM process.
|
||||
If profiler is run by a different user, it will try to automatically change
|
||||
current user and group. This will likely succeed for `root`, but not for
|
||||
other users, resulting in the above error.
|
||||
|
||||
```
|
||||
Could not start attach mechanism: No such file or directory
|
||||
```
|
||||
The profiler cannot establish communication with the target JVM through UNIX domain socket.
|
||||
|
||||
Usually this happens in one of the following cases:
|
||||
1. Attach socket `/tmp/.java_pidNNN` has been deleted. It is a common
|
||||
practice to clean `/tmp` automatically with some scheduled script.
|
||||
Configure the cleanup software to exclude `.java_pid*` files from deletion.
|
||||
How to check: run `lsof -p PID | grep java_pid`
|
||||
If it lists a socket file, but the file does not exist, then this is exactly
|
||||
the described problem.
|
||||
2. JVM is started with `-XX:+DisableAttachMechanism` option.
|
||||
3. `/tmp` directory of Java process is not physically the same directory
|
||||
as `/tmp` of your shell, because Java is running in a container or in
|
||||
`chroot` environment. `jattach` attempts to solve this automatically,
|
||||
but it might lack the required permissions to do so.
|
||||
Check `strace build/jattach PID properties`
|
||||
4. JVM is busy and cannot reach a safepoint. For instance,
|
||||
JVM is in the middle of long-running garbage collection.
|
||||
How to check: run `kill -3 PID`. Healthy JVM process should print
|
||||
a thread dump and heap info in its console.
|
||||
|
||||
```
|
||||
Failed to inject profiler into <pid>
|
||||
```
|
||||
The connection with the target JVM has been established, but JVM is unable to load profiler shared library.
|
||||
Make sure the user of JVM process has permissions to access `libasyncProfiler.so` by exactly the same absolute path.
|
||||
For more information see [#78](https://github.com/jvm-profiling-tools/async-profiler/issues/78).
|
||||
|
||||
```
|
||||
No access to perf events. Try --fdtransfer or --all-user option or 'sysctl kernel.perf_event_paranoid=1'
|
||||
```
|
||||
or
|
||||
```
|
||||
Perf events unavailable
|
||||
```
|
||||
`perf_event_open()` syscall has failed.
|
||||
|
||||
Typical reasons include:
|
||||
1. `/proc/sys/kernel/perf_event_paranoid` is set to restricted mode (>=2).
|
||||
2. seccomp disables `perf_event_open` API in a container.
|
||||
3. OS runs under a hypervisor that does not virtualize performance counters.
|
||||
4. perf_event_open API is not supported on this system, e.g. WSL.
|
||||
|
||||
For permissions-related reasons (such as 1 and 2), using `--fdtransfer` while running the profiler
|
||||
as a privileged user will allow using perf_events.
|
||||
|
||||
If changing the configuration is not possible, you may fall back to
|
||||
`-e itimer` profiling mode. It is similar to `cpu` mode, but does not
|
||||
require perf_events support. As a drawback, there will be no kernel
|
||||
stack traces.
|
||||
|
||||
```
|
||||
No AllocTracer symbols found. Are JDK debug symbols installed?
|
||||
```
|
||||
The OpenJDK debug symbols are required for allocation profiling.
|
||||
See [Installing Debug Symbols](#installing-debug-symbols) for more details.
|
||||
If the error message persists after a successful installation of the debug symbols,
|
||||
it is possible that the JDK was upgraded when installing the debug symbols.
|
||||
In this case, profiling any Java process which had started prior to the installation
|
||||
will continue to display this message, since the process had loaded
|
||||
the older version of the JDK which lacked debug symbols.
|
||||
Restarting the affected Java processes should resolve the issue.
|
||||
|
||||
```
|
||||
VMStructs unavailable. Unsupported JVM?
|
||||
```
|
||||
JVM shared library does not export `gHotSpotVMStructs*` symbols -
|
||||
apparently this is not a HotSpot JVM. Sometimes the same message
|
||||
can be also caused by an incorrectly built JDK
|
||||
(see [#218](https://github.com/jvm-profiling-tools/async-profiler/issues/218)).
|
||||
In these cases installing JDK debug symbols may solve the problem.
|
||||
|
||||
```
|
||||
Could not parse symbols from <libname.so>
|
||||
```
|
||||
Async-profiler was unable to parse non-Java function names because of
|
||||
the corrupted contents in `/proc/[pid]/maps`. The problem is known to
|
||||
occur in a container when running Ubuntu with Linux kernel 5.x.
|
||||
This is the OS bug, see https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1843018.
|
||||
|
||||
```
|
||||
Could not open output file
|
||||
```
|
||||
Output file is written by the target JVM process, not by the profiler script.
|
||||
Make sure the path specified in `-f` option is correct and is accessible by the JVM.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
## Reporting Security Issues
|
||||
|
||||
We take all security reports seriously.
|
||||
When we receive such reports,
|
||||
we will investigate and subsequently address
|
||||
any potential vulnerabilities as quickly as possible.
|
||||
If you discover a potential security issue in this project,
|
||||
please notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/).
|
||||
Please do *not* create a public GitHub issue in this project.
|
||||
882
demo/flamegraph.html
Normal file
@@ -0,0 +1,882 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<style>
|
||||
body {margin: 0; padding: 10px; background-color: #ffffff}
|
||||
h1 {margin: 5px 0 0 0; font-size: 18px; font-weight: normal; text-align: center}
|
||||
header {margin: -24px 0 5px 0; line-height: 24px}
|
||||
button {font: 12px sans-serif; cursor: pointer}
|
||||
p {margin: 5px 0 5px 0}
|
||||
a {color: #0366d6}
|
||||
#hl {position: absolute; display: none; overflow: hidden; white-space: nowrap; pointer-events: none; background-color: #ffffe0; outline: 1px solid #ffc000; height: 15px}
|
||||
#hl span {padding: 0 3px 0 3px}
|
||||
#status {overflow: hidden; white-space: nowrap}
|
||||
#match {overflow: hidden; white-space: nowrap; display: none; float: right; text-align: right}
|
||||
#reset {cursor: pointer}
|
||||
</style>
|
||||
</head>
|
||||
<body style='font: 12px Verdana, sans-serif'>
|
||||
<h1>Flame Graph</h1>
|
||||
<header style='text-align: left'><button id='reverse' title='Reverse'>🔻</button> <button id='search' title='Search'>🔍</button></header>
|
||||
<header style='text-align: right'>Produced by <a href='https://github.com/jvm-profiling-tools/async-profiler'>async-profiler</a></header>
|
||||
<canvas id='canvas' style='width: 100%; height: 752px'></canvas>
|
||||
<div id='hl'><span></span></div>
|
||||
<p id='match'>Matched: <span id='matchval'></span> <span id='reset' title='Clear'>❌</span></p>
|
||||
<p id='status'> </p>
|
||||
<script>
|
||||
// Copyright 2020 Andrei Pangin
|
||||
// Licensed under the Apache License, Version 2.0.
|
||||
'use strict';
|
||||
var root, rootLevel, px, pattern;
|
||||
var reverse = false;
|
||||
const levels = Array(47);
|
||||
for (let h = 0; h < levels.length; h++) {
|
||||
levels[h] = [];
|
||||
}
|
||||
|
||||
const canvas = document.getElementById('canvas');
|
||||
const c = canvas.getContext('2d');
|
||||
const hl = document.getElementById('hl');
|
||||
const status = document.getElementById('status');
|
||||
|
||||
const canvasWidth = canvas.offsetWidth;
|
||||
const canvasHeight = canvas.offsetHeight;
|
||||
canvas.style.width = canvasWidth + 'px';
|
||||
canvas.width = canvasWidth * (devicePixelRatio || 1);
|
||||
canvas.height = canvasHeight * (devicePixelRatio || 1);
|
||||
if (devicePixelRatio) c.scale(devicePixelRatio, devicePixelRatio);
|
||||
c.font = document.body.style.font;
|
||||
|
||||
const palette = [
|
||||
[0x50e150, 30, 30, 30],
|
||||
[0x50bebe, 30, 30, 30],
|
||||
[0xe17d00, 30, 30, 0],
|
||||
[0xc8c83c, 30, 30, 10],
|
||||
[0xe15a5a, 30, 40, 40],
|
||||
];
|
||||
|
||||
function getColor(p) {
|
||||
const v = Math.random();
|
||||
return '#' + (p[0] + ((p[1] * v) << 16 | (p[2] * v) << 8 | (p[3] * v))).toString(16);
|
||||
}
|
||||
|
||||
function f(level, left, width, type, title) {
|
||||
levels[level].push({left: left, width: width, color: getColor(palette[type]), title: title});
|
||||
}
|
||||
|
||||
function samples(n) {
|
||||
return n === 1 ? '1 sample' : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' samples';
|
||||
}
|
||||
|
||||
function pct(a, b) {
|
||||
return a >= b ? '100' : (100 * a / b).toFixed(2);
|
||||
}
|
||||
|
||||
function findFrame(frames, x) {
|
||||
let left = 0;
|
||||
let right = frames.length - 1;
|
||||
|
||||
while (left <= right) {
|
||||
const mid = (left + right) >>> 1;
|
||||
const f = frames[mid];
|
||||
|
||||
if (f.left > x) {
|
||||
right = mid - 1;
|
||||
} else if (f.left + f.width <= x) {
|
||||
left = mid + 1;
|
||||
} else {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
if (frames[left] && (frames[left].left - x) * px < 0.5) return frames[left];
|
||||
if (frames[right] && (x - (frames[right].left + frames[right].width)) * px < 0.5) return frames[right];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function search(r) {
|
||||
if (r && (r = prompt('Enter regexp to search:', '')) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
pattern = r ? RegExp(r) : undefined;
|
||||
const matched = render(root, rootLevel);
|
||||
document.getElementById('matchval').textContent = pct(matched, root.width) + '%';
|
||||
document.getElementById('match').style.display = r ? 'inherit' : 'none';
|
||||
}
|
||||
|
||||
function render(newRoot, newLevel) {
|
||||
if (root) {
|
||||
c.fillStyle = '#ffffff';
|
||||
c.fillRect(0, 0, canvasWidth, canvasHeight);
|
||||
}
|
||||
|
||||
root = newRoot || levels[0][0];
|
||||
rootLevel = newLevel || 0;
|
||||
px = canvasWidth / root.width;
|
||||
|
||||
const x0 = root.left;
|
||||
const x1 = x0 + root.width;
|
||||
const marked = [];
|
||||
|
||||
function mark(f) {
|
||||
return marked[f.left] >= f.width || (marked[f.left] = f.width);
|
||||
}
|
||||
|
||||
function totalMarked() {
|
||||
let total = 0;
|
||||
let left = 0;
|
||||
for (let x in marked) {
|
||||
if (+x >= left) {
|
||||
total += marked[x];
|
||||
left = +x + marked[x];
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
function drawFrame(f, y, alpha) {
|
||||
if (f.left < x1 && f.left + f.width > x0) {
|
||||
c.fillStyle = pattern && f.title.match(pattern) && mark(f) ? '#ee00ee' : f.color;
|
||||
c.fillRect((f.left - x0) * px, y, f.width * px, 15);
|
||||
|
||||
if (f.width * px >= 21) {
|
||||
const chars = Math.floor(f.width * px / 7);
|
||||
const title = f.title.length <= chars ? f.title : f.title.substring(0, chars - 2) + '..';
|
||||
c.fillStyle = '#000000';
|
||||
c.fillText(title, Math.max(f.left - x0, 0) * px + 3, y + 12, f.width * px - 6);
|
||||
}
|
||||
|
||||
if (alpha) {
|
||||
c.fillStyle = 'rgba(255, 255, 255, 0.5)';
|
||||
c.fillRect((f.left - x0) * px, y, f.width * px, 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let h = 0; h < levels.length; h++) {
|
||||
const y = reverse ? h * 16 : canvasHeight - (h + 1) * 16;
|
||||
const frames = levels[h];
|
||||
for (let i = 0; i < frames.length; i++) {
|
||||
drawFrame(frames[i], y, h < rootLevel);
|
||||
}
|
||||
}
|
||||
|
||||
return totalMarked();
|
||||
}
|
||||
|
||||
canvas.onmousemove = function() {
|
||||
const h = Math.floor((reverse ? event.offsetY : (canvasHeight - event.offsetY)) / 16);
|
||||
if (h >= 0 && h < levels.length) {
|
||||
const f = findFrame(levels[h], event.offsetX / px + root.left);
|
||||
if (f) {
|
||||
if (f != root) getSelection().removeAllRanges();
|
||||
hl.style.left = (Math.max(f.left - root.left, 0) * px + canvas.offsetLeft) + 'px';
|
||||
hl.style.width = (Math.min(f.width, root.width) * px) + 'px';
|
||||
hl.style.top = ((reverse ? h * 16 : canvasHeight - (h + 1) * 16) + canvas.offsetTop) + 'px';
|
||||
hl.firstChild.textContent = f.title;
|
||||
hl.style.display = 'block';
|
||||
canvas.title = f.title + '\n(' + samples(f.width) + ', ' + pct(f.width, levels[0][0].width) + '%)';
|
||||
canvas.style.cursor = 'pointer';
|
||||
canvas.onclick = function() {
|
||||
if (f != root) {
|
||||
render(f, h);
|
||||
canvas.onmousemove();
|
||||
}
|
||||
};
|
||||
status.textContent = 'Function: ' + canvas.title;
|
||||
return;
|
||||
}
|
||||
}
|
||||
canvas.onmouseout();
|
||||
}
|
||||
|
||||
canvas.onmouseout = function() {
|
||||
hl.style.display = 'none';
|
||||
status.textContent = '\xa0';
|
||||
canvas.title = '';
|
||||
canvas.style.cursor = '';
|
||||
canvas.onclick = '';
|
||||
}
|
||||
|
||||
canvas.ondblclick = function() {
|
||||
getSelection().selectAllChildren(hl);
|
||||
}
|
||||
|
||||
document.getElementById('reverse').onclick = function() {
|
||||
reverse = !reverse;
|
||||
render();
|
||||
}
|
||||
|
||||
document.getElementById('search').onclick = function() {
|
||||
search(true);
|
||||
}
|
||||
|
||||
document.getElementById('reset').onclick = function() {
|
||||
search(false);
|
||||
}
|
||||
|
||||
window.onkeydown = function() {
|
||||
if (event.ctrlKey && event.keyCode === 70) {
|
||||
event.preventDefault();
|
||||
search(true);
|
||||
} else if (event.keyCode === 27) {
|
||||
search(false);
|
||||
}
|
||||
}
|
||||
f(0,0,641,4,'all')
|
||||
f(1,0,5,0,'com/sun/glass/ui/InvokeLaterDispatcher.run')
|
||||
f(2,0,4,0,'com/sun/glass/ui/gtk/GtkApplication.submitForLaterInvocation')
|
||||
f(3,0,4,0,'com/sun/glass/ui/gtk/GtkApplication._submitForLaterInvocation')
|
||||
f(4,0,4,4,'Java_com_sun_glass_ui_gtk_GtkApplication__1submitForLaterInvocation')
|
||||
f(5,0,4,4,'__write')
|
||||
f(6,0,4,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(7,0,4,2,'do_syscall_64')
|
||||
f(8,0,4,2,'__x64_sys_write')
|
||||
f(9,0,4,2,'ksys_write')
|
||||
f(10,0,4,2,'vfs_write')
|
||||
f(11,0,4,2,'__vfs_write')
|
||||
f(12,0,4,2,'eventfd_write')
|
||||
f(1,5,408,0,'java/lang/Thread.run')
|
||||
f(2,5,179,0,'com/sun/glass/ui/gtk/GtkApplication$$Lambda$42/1642360923.run')
|
||||
f(3,5,179,0,'com/sun/glass/ui/gtk/GtkApplication.lambda$null$48')
|
||||
f(4,5,179,0,'com/sun/glass/ui/gtk/GtkApplication._runLoop')
|
||||
f(5,5,4,4,'Java_com_sun_glass_ui_gtk_GtkApplication__1runLoop')
|
||||
f(6,6,2,4,'__writev')
|
||||
f(7,6,2,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(8,6,2,2,'do_syscall_64')
|
||||
f(9,6,2,2,'__x64_sys_writev')
|
||||
f(10,6,2,2,'do_writev')
|
||||
f(11,6,2,2,'vfs_writev')
|
||||
f(12,6,2,2,'do_iter_write')
|
||||
f(13,6,2,2,'do_iter_readv_writev')
|
||||
f(14,6,2,2,'sock_write_iter')
|
||||
f(15,6,2,2,'sock_sendmsg')
|
||||
f(16,6,2,2,'inet_sendmsg')
|
||||
f(17,6,2,2,'tcp_sendmsg')
|
||||
f(18,6,2,2,'tcp_sendmsg_locked')
|
||||
f(19,6,2,2,'tcp_push')
|
||||
f(20,6,2,2,'__tcp_push_pending_frames')
|
||||
f(21,6,2,2,'tcp_write_xmit')
|
||||
f(22,6,2,2,'__tcp_transmit_skb')
|
||||
f(23,6,2,2,'ip_queue_xmit')
|
||||
f(24,6,2,2,'__ip_queue_xmit')
|
||||
f(25,6,2,2,'ip_local_out')
|
||||
f(26,6,2,2,'ip_output')
|
||||
f(27,6,2,2,'ip_finish_output')
|
||||
f(28,6,2,2,'__ip_finish_output')
|
||||
f(29,6,2,2,'ip_finish_output2')
|
||||
f(30,6,2,2,'dev_queue_xmit')
|
||||
f(31,6,2,2,'__dev_queue_xmit')
|
||||
f(32,6,2,2,'sch_direct_xmit')
|
||||
f(33,6,2,2,'dev_hard_start_xmit')
|
||||
f(34,6,2,2,'e1000_xmit_frame?[e1000]')
|
||||
f(5,10,161,0,'com/sun/glass/ui/InvokeLaterDispatcher$Future.run')
|
||||
f(6,10,6,3,'InterpreterRuntime::monitorexit(JavaThread*, BasicObjectLock*)')
|
||||
f(7,10,6,3,'ObjectMonitor::ExitEpilog(Thread*, ObjectWaiter*)')
|
||||
f(8,10,6,4,'pthread_cond_signal@@GLIBC_2.3.2')
|
||||
f(9,10,6,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(10,10,6,2,'do_syscall_64')
|
||||
f(11,10,6,2,'__x64_sys_futex')
|
||||
f(12,10,6,2,'do_futex')
|
||||
f(13,10,6,2,'wake_up_q')
|
||||
f(14,10,6,2,'try_to_wake_up')
|
||||
f(15,10,6,2,'_raw_spin_unlock_irqrestore')
|
||||
f(6,16,58,0,'com/sun/javafx/application/PlatformImpl$$Lambda$53/233530418.run')
|
||||
f(7,16,58,0,'com/sun/javafx/application/PlatformImpl.lambda$runLater$173')
|
||||
f(8,17,57,0,'java/security/AccessController.doPrivileged')
|
||||
f(9,17,57,0,'com/sun/javafx/application/PlatformImpl$$Lambda$54/1140247440.run')
|
||||
f(10,17,57,0,'com/sun/javafx/application/PlatformImpl.lambda$null$172')
|
||||
f(11,17,55,0,'com/sun/javafx/application/PlatformImpl$$Lambda$52/1364335809.run')
|
||||
f(12,17,55,0,'com/sun/javafx/application/PlatformImpl.lambda$runAndWait$174')
|
||||
f(13,17,4,0,'com/sun/javafx/application/LauncherImpl$$Lambda$57/1790390841.run')
|
||||
f(14,17,4,0,'com/sun/javafx/application/LauncherImpl.lambda$launchApplication1$160')
|
||||
f(15,17,4,0,'java/lang/reflect/Constructor.newInstance')
|
||||
f(16,17,4,0,'sun/reflect/DelegatingConstructorAccessorImpl.newInstance')
|
||||
f(17,17,4,0,'sun/reflect/NativeConstructorAccessorImpl.newInstance')
|
||||
f(18,17,4,0,'sun/reflect/NativeConstructorAccessorImpl.newInstance0')
|
||||
f(19,17,4,0,'demo/parallel/Main.<init>')
|
||||
f(20,17,2,0,'java/lang/ClassLoader.loadClass')
|
||||
f(21,17,2,0,'java/lang/ClassLoader.loadClass')
|
||||
f(22,17,2,0,'java/net/URLClassLoader.findClass')
|
||||
f(23,17,2,0,'java/security/AccessController.doPrivileged')
|
||||
f(24,17,2,0,'java/net/URLClassLoader$1.run')
|
||||
f(25,17,2,0,'java/net/URLClassLoader$1.run')
|
||||
f(26,17,2,0,'java/net/URLClassLoader.access$100')
|
||||
f(27,17,2,0,'java/net/URLClassLoader.defineClass')
|
||||
f(28,17,2,0,'java/security/SecureClassLoader.defineClass')
|
||||
f(13,21,50,0,'com/sun/javafx/application/LauncherImpl$$Lambda$63/508611611.run')
|
||||
f(14,21,50,0,'com/sun/javafx/application/LauncherImpl.lambda$launchApplication1$161')
|
||||
f(15,21,49,0,'demo/parallel/Main.start')
|
||||
f(16,22,17,0,'demo/parallel/Main.createContent')
|
||||
f(17,23,14,0,'demo/parallel/Main.createControlPane')
|
||||
f(18,26,8,0,'javafx/scene/control/Control.<clinit>')
|
||||
f(19,26,8,0,'com/sun/javafx/application/PlatformImpl.setDefaultPlatformUserAgentStylesheet')
|
||||
f(20,26,8,0,'com/sun/javafx/application/PlatformImpl.setPlatformUserAgentStylesheet')
|
||||
f(21,26,8,0,'com/sun/javafx/application/PlatformImpl._setPlatformUserAgentStylesheet')
|
||||
f(22,27,7,0,'java/security/AccessController.doPrivileged')
|
||||
f(23,27,7,0,'com/sun/javafx/application/PlatformImpl$$Lambda$68/360857571.run')
|
||||
f(24,27,7,0,'com/sun/javafx/application/PlatformImpl.lambda$_setPlatformUserAgentStylesheet$181')
|
||||
f(25,27,7,0,'com/sun/javafx/css/StyleManager.setUserAgentStylesheets')
|
||||
f(26,27,6,0,'com/sun/javafx/css/StyleManager._setDefaultUserAgentStylesheet')
|
||||
f(27,28,5,0,'com/sun/javafx/css/StyleManager.loadStylesheet')
|
||||
f(28,28,5,0,'com/sun/javafx/css/StyleManager.loadStylesheetUnPrivileged')
|
||||
f(29,28,2,0,'com/sun/javafx/css/StyleManager.getURL')
|
||||
f(30,28,2,0,'java/lang/Class.forName')
|
||||
f(31,28,2,0,'java/lang/Class.forName0')
|
||||
f(32,28,2,0,'com/sun/javafx/scene/control/skin/Utils.<clinit>')
|
||||
f(29,30,3,0,'com/sun/javafx/css/Stylesheet.loadBinary')
|
||||
f(30,30,3,0,'com/sun/javafx/css/Stylesheet.readBinary')
|
||||
f(31,30,3,0,'com/sun/javafx/css/Rule.readBinary')
|
||||
f(32,30,3,0,'com/sun/javafx/css/Selector.readBinary')
|
||||
f(33,30,2,0,'com/sun/javafx/css/CompoundSelector.readBinary')
|
||||
f(16,40,11,0,'javafx/scene/Scene.<init>')
|
||||
f(17,40,11,0,'javafx/scene/Scene.<init>')
|
||||
f(18,40,11,0,'javafx/scene/Scene.setRoot')
|
||||
f(19,40,11,0,'javafx/beans/property/ObjectPropertyBase.set')
|
||||
f(20,40,11,0,'javafx/beans/property/ObjectPropertyBase.markInvalid')
|
||||
f(21,40,11,0,'javafx/scene/Scene$9.invalidated')
|
||||
f(22,40,11,0,'javafx/scene/Node.setScenes')
|
||||
f(23,40,11,0,'javafx/scene/Node.invalidatedScenes')
|
||||
f(24,40,11,0,'javafx/scene/Node.impl_reapplyCSS')
|
||||
f(25,41,10,0,'javafx/scene/Node.reapplyCss')
|
||||
f(26,42,3,0,'javafx/scene/CssStyleHelper.<clinit>')
|
||||
f(27,42,3,0,'javafx/scene/text/Font.getDefault')
|
||||
f(28,42,3,0,'javafx/scene/text/Font.<init>')
|
||||
f(29,42,3,0,'com/sun/javafx/font/PrismFontLoader.loadFont')
|
||||
f(30,42,2,0,'com/sun/javafx/font/PrismFontFactory.createFont')
|
||||
f(31,42,2,0,'com/sun/javafx/font/LogicalFont.getLogicalFont')
|
||||
f(32,42,2,0,'com/sun/javafx/font/LogicalFont.getLogicalFont')
|
||||
f(33,42,2,0,'com/sun/javafx/font/LogicalFont.<init>')
|
||||
f(34,42,2,0,'com/sun/javafx/font/FontConfigManager.getFontConfigFont')
|
||||
f(35,42,2,0,'com/sun/javafx/font/FontConfigManager.initFontConfigLogFonts')
|
||||
f(36,42,2,0,'com/sun/javafx/font/FontConfigManager.getFontConfig')
|
||||
f(26,45,2,0,'javafx/scene/CssStyleHelper.createStyleHelper')
|
||||
f(26,47,4,0,'javafx/scene/Node.reapplyCss')
|
||||
f(27,47,3,0,'javafx/scene/CssStyleHelper.createStyleHelper')
|
||||
f(28,47,3,0,'com/sun/javafx/css/StyleManager.findMatchingStyles')
|
||||
f(29,47,3,0,'com/sun/javafx/css/StyleManager.gatherParentStylesheets')
|
||||
f(30,47,3,0,'com/sun/javafx/css/StyleManager.processStylesheets')
|
||||
f(31,47,3,0,'com/sun/javafx/css/StyleManager.loadStylesheet')
|
||||
f(32,47,3,0,'com/sun/javafx/css/StyleManager.loadStylesheetUnPrivileged')
|
||||
f(33,48,2,0,'com/sun/javafx/css/parser/CSSParser.parse')
|
||||
f(34,48,2,0,'com/sun/javafx/css/parser/CSSParser.parse')
|
||||
f(16,51,19,0,'javafx/stage/Stage.show')
|
||||
f(17,51,19,0,'javafx/stage/Window.show')
|
||||
f(18,51,19,0,'javafx/stage/Window.setShowing')
|
||||
f(19,51,19,0,'javafx/beans/property/BooleanPropertyBase.set')
|
||||
f(20,51,19,0,'javafx/beans/property/BooleanPropertyBase.markInvalid')
|
||||
f(21,51,19,0,'javafx/stage/Window$9.invalidated')
|
||||
f(22,52,3,0,'javafx/scene/Scene.impl_initPeer')
|
||||
f(22,55,14,0,'javafx/scene/Scene.impl_preferredSize')
|
||||
f(23,55,14,0,'javafx/scene/Scene.preferredSize')
|
||||
f(24,55,11,0,'javafx/scene/Scene.doCSSPass')
|
||||
f(25,55,11,0,'javafx/scene/Node.processCSS')
|
||||
f(26,55,11,0,'javafx/scene/Parent.impl_processCSS')
|
||||
f(27,56,10,0,'javafx/scene/Parent.impl_processCSS')
|
||||
f(28,56,10,0,'javafx/scene/control/Control.impl_processCSS')
|
||||
f(29,56,3,0,'javafx/scene/Parent.impl_processCSS')
|
||||
f(30,56,3,0,'javafx/scene/Node.impl_processCSS')
|
||||
f(31,56,3,0,'javafx/scene/CssStyleHelper.transitionToState')
|
||||
f(29,59,4,0,'javafx/scene/control/Button.createDefaultSkin')
|
||||
f(30,59,4,0,'com/sun/javafx/scene/control/skin/ButtonSkin.<init>')
|
||||
f(31,59,4,0,'com/sun/javafx/scene/control/skin/LabeledSkinBase.<init>')
|
||||
f(32,61,2,0,'com/sun/javafx/scene/control/skin/LabeledText.<init>')
|
||||
f(33,61,2,0,'javafx/css/StyleableObjectProperty.bind')
|
||||
f(34,61,2,0,'javafx/beans/property/ObjectPropertyBase.bind')
|
||||
f(35,61,2,0,'javafx/beans/property/ObjectPropertyBase.markInvalid')
|
||||
f(36,61,2,0,'javafx/scene/text/Text$5.invalidated')
|
||||
f(37,61,2,0,'javafx/scene/text/Text.access$200')
|
||||
f(38,61,2,0,'javafx/scene/text/Text.needsFullTextLayout')
|
||||
f(39,61,2,0,'javafx/scene/text/Text.getTextLayout')
|
||||
f(40,61,2,0,'com/sun/javafx/text/PrismTextLayout.setContent')
|
||||
f(41,61,2,0,'com/sun/javafx/font/PrismFont.getStrike')
|
||||
f(42,61,2,0,'com/sun/javafx/font/LogicalFont.getStrike')
|
||||
f(43,61,2,0,'com/sun/javafx/font/LogicalFont.getDefaultAAMode')
|
||||
f(44,61,2,0,'com/sun/javafx/font/LogicalFont.getSlot0Resource')
|
||||
f(45,61,2,0,'com/sun/javafx/font/PrismFontFactory.getFontResource')
|
||||
f(46,61,2,0,'com/sun/javafx/font/PrismFontFactory.getFullNameToFileMap')
|
||||
f(29,64,2,0,'javafx/scene/control/ProgressIndicator.createDefaultSkin')
|
||||
f(24,67,2,0,'javafx/scene/Scene.resizeRootToPreferredSize')
|
||||
f(25,67,2,0,'javafx/scene/Scene.getPreferredWidth')
|
||||
f(26,67,2,0,'javafx/scene/layout/Region.prefWidth')
|
||||
f(27,67,2,0,'javafx/scene/Parent.prefWidth')
|
||||
f(28,67,2,0,'javafx/scene/layout/Region.computePrefWidth')
|
||||
f(29,67,2,0,'javafx/scene/Parent.computePrefWidth')
|
||||
f(30,67,2,0,'javafx/scene/layout/Region.prefWidth')
|
||||
f(31,67,2,0,'javafx/scene/Parent.prefWidth')
|
||||
f(32,67,2,0,'javafx/scene/layout/GridPane.computePrefWidth')
|
||||
f(33,67,2,0,'javafx/scene/layout/GridPane.computePrefWidths')
|
||||
f(34,67,2,0,'javafx/scene/layout/Region.computeChildPrefAreaWidth')
|
||||
f(35,67,2,0,'javafx/scene/layout/Region.minWidth')
|
||||
f(36,67,2,0,'javafx/scene/Parent.minWidth')
|
||||
f(37,67,2,0,'javafx/scene/control/Control.computeMinWidth')
|
||||
f(38,67,2,0,'com/sun/javafx/scene/control/skin/LabeledSkinBase.computeMinWidth')
|
||||
f(39,67,2,0,'com/sun/javafx/scene/control/skin/LabeledSkinBase.computeMinLabeledPartWidth')
|
||||
f(40,67,2,0,'com/sun/javafx/scene/control/skin/Utils.computeTextWidth')
|
||||
f(41,67,2,0,'com/sun/javafx/text/PrismTextLayout.getBounds')
|
||||
f(42,67,2,0,'com/sun/javafx/text/PrismTextLayout.ensureLayout')
|
||||
f(43,67,2,0,'com/sun/javafx/text/PrismTextLayout.layout')
|
||||
f(44,67,2,0,'com/sun/javafx/text/PrismTextLayout.buildRuns')
|
||||
f(45,67,2,0,'com/sun/javafx/text/GlyphLayout.breakRuns')
|
||||
f(6,74,12,0,'com/sun/javafx/tk/quantum/QuantumToolkit$$Lambda$46/1696939523.run')
|
||||
f(7,74,12,0,'com/sun/javafx/tk/quantum/QuantumToolkit.lambda$runToolkit$403')
|
||||
f(8,74,12,0,'com/sun/javafx/tk/quantum/QuantumToolkit.pulseFromQueue')
|
||||
f(9,74,12,0,'com/sun/javafx/tk/quantum/QuantumToolkit.pulse')
|
||||
f(10,74,12,0,'com/sun/javafx/tk/quantum/QuantumToolkit.pulse')
|
||||
f(11,74,8,0,'com/sun/javafx/tk/Toolkit.firePulse')
|
||||
f(12,74,6,0,'com/sun/javafx/tk/Toolkit.runPulse')
|
||||
f(13,74,6,0,'java/security/AccessController.doPrivileged')
|
||||
f(14,74,6,0,'com/sun/javafx/tk/Toolkit$$Lambda$193/1813875389.run')
|
||||
f(15,74,6,0,'com/sun/javafx/tk/Toolkit.lambda$runPulse$29')
|
||||
f(16,74,6,0,'javafx/scene/Scene$ScenePulseListener.pulse')
|
||||
f(17,76,4,0,'javafx/scene/Scene.doLayoutPass')
|
||||
f(18,76,4,0,'javafx/scene/Parent.layout')
|
||||
f(19,76,4,0,'demo/parallel/Main$1.layoutChildren')
|
||||
f(20,76,4,0,'javafx/scene/Parent.layoutChildren')
|
||||
f(21,76,4,0,'javafx/scene/Node.autosize')
|
||||
f(22,76,2,0,'javafx/scene/layout/Region.prefHeight')
|
||||
f(23,76,2,0,'javafx/scene/Parent.prefHeight')
|
||||
f(24,76,2,0,'javafx/scene/layout/GridPane.computePrefHeight')
|
||||
f(25,76,2,0,'javafx/scene/layout/GridPane.computePrefHeights')
|
||||
f(22,78,2,0,'javafx/scene/layout/Region.prefWidth')
|
||||
f(23,78,2,0,'javafx/scene/Parent.prefWidth')
|
||||
f(24,78,2,0,'javafx/scene/layout/GridPane.computePrefWidth')
|
||||
f(25,78,2,0,'javafx/scene/layout/GridPane.computePrefWidths')
|
||||
f(11,82,3,0,'com/sun/javafx/tk/quantum/PaintCollector.renderAll')
|
||||
f(12,82,3,0,'com/sun/javafx/tk/quantum/ViewScene.repaint')
|
||||
f(13,82,3,0,'com/sun/javafx/tk/quantum/QuantumToolkit.addRenderJob')
|
||||
f(14,82,3,0,'com/sun/javafx/tk/quantum/QuantumRenderer.submitRenderJob')
|
||||
f(15,82,3,0,'java/util/concurrent/AbstractExecutorService.submit')
|
||||
f(16,82,3,0,'java/util/concurrent/ThreadPoolExecutor.execute')
|
||||
f(17,82,3,0,'java/util/concurrent/LinkedBlockingQueue.offer')
|
||||
f(18,82,3,0,'java/util/concurrent/LinkedBlockingQueue.signalNotEmpty')
|
||||
f(19,82,3,0,'java/util/concurrent/locks/ReentrantLock.unlock')
|
||||
f(20,82,3,0,'java/util/concurrent/locks/AbstractQueuedSynchronizer.release')
|
||||
f(21,82,3,0,'java/util/concurrent/locks/AbstractQueuedSynchronizer.unparkSuccessor')
|
||||
f(22,82,3,0,'java/util/concurrent/locks/LockSupport.unpark')
|
||||
f(23,82,3,0,'sun/misc/Unsafe.unpark')
|
||||
f(24,82,3,4,'Unsafe_Unpark')
|
||||
f(25,82,3,4,'pthread_cond_signal@@GLIBC_2.3.2')
|
||||
f(26,82,3,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(27,82,3,2,'do_syscall_64')
|
||||
f(28,82,3,2,'__x64_sys_futex')
|
||||
f(29,82,3,2,'do_futex')
|
||||
f(30,82,3,2,'wake_up_q')
|
||||
f(31,82,3,2,'try_to_wake_up')
|
||||
f(32,82,3,2,'_raw_spin_unlock_irqrestore')
|
||||
f(6,86,85,0,'com/sun/javafx/tk/quantum/SceneState$$Lambda$205/1725489206.run')
|
||||
f(7,86,85,0,'com/sun/javafx/tk/quantum/SceneState.lambda$uploadPixels$305')
|
||||
f(8,86,85,0,'com/sun/javafx/tk/quantum/SceneState.access$001')
|
||||
f(9,86,85,0,'com/sun/prism/PresentableState.uploadPixels')
|
||||
f(10,86,85,0,'com/sun/glass/ui/View.uploadPixels')
|
||||
f(11,86,85,0,'com/sun/glass/ui/gtk/GtkView._uploadPixels')
|
||||
f(12,86,85,0,'com/sun/glass/ui/gtk/GtkView._uploadPixelsDirect')
|
||||
f(13,86,85,4,'Java_com_sun_glass_ui_gtk_GtkView__1uploadPixelsDirect')
|
||||
f(14,86,85,4,'__writev')
|
||||
f(15,86,85,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(16,86,85,2,'do_syscall_64')
|
||||
f(17,86,85,2,'__x64_sys_writev')
|
||||
f(18,86,85,2,'do_writev')
|
||||
f(19,86,85,2,'vfs_writev')
|
||||
f(20,86,85,2,'do_iter_write')
|
||||
f(21,86,85,2,'do_iter_readv_writev')
|
||||
f(22,86,85,2,'sock_write_iter')
|
||||
f(23,86,85,2,'sock_sendmsg')
|
||||
f(24,86,85,2,'inet_sendmsg')
|
||||
f(25,86,85,2,'tcp_sendmsg')
|
||||
f(26,86,3,2,'lock_sock_nested')
|
||||
f(27,86,3,2,'_raw_spin_lock_bh')
|
||||
f(28,86,3,2,'queued_spin_lock_slowpath')
|
||||
f(29,86,3,2,'native_queued_spin_lock_slowpath')
|
||||
f(26,90,81,2,'tcp_sendmsg_locked')
|
||||
f(27,90,3,2,'__sk_flush_backlog')
|
||||
f(28,90,3,2,'__release_sock')
|
||||
f(29,90,3,2,'tcp_v4_do_rcv')
|
||||
f(30,90,3,2,'tcp_rcv_established')
|
||||
f(31,90,3,2,'__tcp_push_pending_frames')
|
||||
f(32,90,3,2,'tcp_write_xmit')
|
||||
f(33,90,3,2,'__tcp_transmit_skb')
|
||||
f(34,90,3,2,'ip_queue_xmit')
|
||||
f(35,90,3,2,'__ip_queue_xmit')
|
||||
f(36,90,3,2,'ip_local_out')
|
||||
f(37,90,3,2,'ip_output')
|
||||
f(38,90,3,2,'ip_finish_output')
|
||||
f(39,90,3,2,'__ip_finish_output')
|
||||
f(40,90,3,2,'ip_finish_output2')
|
||||
f(41,90,3,2,'dev_queue_xmit')
|
||||
f(42,90,3,2,'__dev_queue_xmit')
|
||||
f(43,90,3,2,'sch_direct_xmit')
|
||||
f(44,90,3,2,'dev_hard_start_xmit')
|
||||
f(45,90,3,2,'e1000_xmit_frame?[e1000]')
|
||||
f(27,93,78,2,'tcp_push_one')
|
||||
f(28,93,78,2,'tcp_write_xmit')
|
||||
f(29,93,78,2,'__tcp_transmit_skb')
|
||||
f(30,93,78,2,'ip_queue_xmit')
|
||||
f(31,93,78,2,'__ip_queue_xmit')
|
||||
f(32,93,78,2,'ip_local_out')
|
||||
f(33,93,78,2,'ip_output')
|
||||
f(34,93,78,2,'ip_finish_output')
|
||||
f(35,93,78,2,'__ip_finish_output')
|
||||
f(36,93,78,2,'ip_finish_output2')
|
||||
f(37,93,9,2,'__local_bh_enable_ip')
|
||||
f(38,93,9,2,'do_softirq')
|
||||
f(39,93,9,2,'do_softirq_own_stack')
|
||||
f(40,93,9,2,'__softirqentry_text_start')
|
||||
f(41,93,9,2,'net_rx_action')
|
||||
f(42,93,9,2,'e1000_clean?[e1000]')
|
||||
f(37,102,69,2,'dev_queue_xmit')
|
||||
f(38,102,69,2,'__dev_queue_xmit')
|
||||
f(39,102,69,2,'sch_direct_xmit')
|
||||
f(40,102,69,2,'dev_hard_start_xmit')
|
||||
f(41,102,69,2,'e1000_xmit_frame?[e1000]')
|
||||
f(5,171,3,0,'com/sun/glass/ui/View.notifyMouse')
|
||||
f(6,171,3,0,'com/sun/glass/ui/View.handleMouseEvent')
|
||||
f(7,171,3,0,'com/sun/javafx/tk/quantum/GlassViewEventHandler.handleMouseEvent')
|
||||
f(8,171,3,0,'com/sun/javafx/tk/quantum/QuantumToolkit.runWithoutRenderLock')
|
||||
f(9,171,3,0,'com/sun/javafx/tk/quantum/GlassViewEventHandler$$Lambda$181/241733715.get')
|
||||
f(10,171,3,0,'com/sun/javafx/tk/quantum/GlassViewEventHandler.lambda$handleMouseEvent$353')
|
||||
f(11,171,3,0,'java/security/AccessController.doPrivileged')
|
||||
f(12,171,3,0,'com/sun/javafx/tk/quantum/GlassViewEventHandler$MouseEventNotification.run')
|
||||
f(13,171,3,0,'com/sun/javafx/tk/quantum/GlassViewEventHandler$MouseEventNotification.run')
|
||||
f(14,171,3,0,'javafx/scene/Scene$ScenePeerListener.mouseEvent')
|
||||
f(15,171,3,0,'javafx/scene/Scene.impl_processMouseEvent')
|
||||
f(16,171,3,0,'javafx/scene/Scene$MouseHandler.access$1500')
|
||||
f(17,171,3,0,'javafx/scene/Scene$MouseHandler.process')
|
||||
f(18,172,2,0,'javafx/scene/Scene.access$6700')
|
||||
f(19,172,2,0,'javafx/scene/Scene.pick')
|
||||
f(20,172,2,0,'javafx/scene/Scene$MouseHandler.access$1600')
|
||||
f(21,172,2,0,'javafx/scene/Scene$MouseHandler.pickNode')
|
||||
f(22,172,2,0,'javafx/scene/Node.impl_pickNode')
|
||||
f(23,172,2,0,'javafx/scene/layout/Region.impl_pickNodeLocal')
|
||||
f(5,174,2,0,'com/sun/javafx/tk/quantum/QuantumToolkit$$Lambda$47/605813029.run')
|
||||
f(6,174,2,0,'com/sun/javafx/tk/quantum/QuantumToolkit.lambda$runToolkit$404')
|
||||
f(7,174,2,0,'com/sun/javafx/tk/quantum/QuantumToolkit.postPulse')
|
||||
f(8,174,2,0,'com/sun/glass/ui/Application.invokeLater')
|
||||
f(9,174,2,0,'com/sun/glass/ui/gtk/GtkApplication._invokeLater')
|
||||
f(10,174,2,0,'com/sun/glass/ui/InvokeLaterDispatcher.invokeLater')
|
||||
f(11,174,2,0,'java/util/concurrent/LinkedBlockingDeque.addLast')
|
||||
f(12,174,2,0,'java/util/concurrent/LinkedBlockingDeque.offerLast')
|
||||
f(13,174,2,0,'java/util/concurrent/locks/ReentrantLock.unlock')
|
||||
f(14,174,2,0,'java/util/concurrent/locks/AbstractQueuedSynchronizer.release')
|
||||
f(15,174,2,0,'java/util/concurrent/locks/AbstractQueuedSynchronizer.unparkSuccessor')
|
||||
f(16,174,2,0,'java/util/concurrent/locks/LockSupport.unpark')
|
||||
f(17,174,2,0,'sun/misc/Unsafe.unpark')
|
||||
f(18,174,2,4,'Unsafe_Unpark')
|
||||
f(19,174,2,4,'pthread_cond_signal@@GLIBC_2.3.2')
|
||||
f(20,174,2,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(21,174,2,2,'do_syscall_64')
|
||||
f(22,174,2,2,'__x64_sys_futex')
|
||||
f(23,174,2,2,'do_futex')
|
||||
f(24,174,2,2,'wake_up_q')
|
||||
f(25,174,2,2,'try_to_wake_up')
|
||||
f(26,174,2,2,'_raw_spin_unlock_irqrestore')
|
||||
f(5,176,8,4,'recvmsg')
|
||||
f(6,176,8,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(7,176,8,2,'do_syscall_64')
|
||||
f(8,176,8,2,'__x64_sys_recvmsg')
|
||||
f(9,176,8,2,'__sys_recvmsg')
|
||||
f(10,176,8,2,'___sys_recvmsg')
|
||||
f(11,176,8,2,'sock_recvmsg')
|
||||
f(12,176,8,2,'inet_recvmsg')
|
||||
f(13,176,8,2,'tcp_recvmsg')
|
||||
f(14,176,3,2,'lock_sock_nested')
|
||||
f(15,176,3,2,'_raw_spin_lock_bh')
|
||||
f(16,176,3,2,'queued_spin_lock_slowpath')
|
||||
f(17,176,3,2,'native_queued_spin_lock_slowpath')
|
||||
f(14,180,4,2,'tcp_cleanup_rbuf')
|
||||
f(15,180,4,2,'tcp_send_ack')
|
||||
f(16,180,4,2,'__tcp_send_ack.part.45')
|
||||
f(17,180,4,2,'__tcp_transmit_skb')
|
||||
f(18,180,4,2,'ip_queue_xmit')
|
||||
f(19,180,4,2,'__ip_queue_xmit')
|
||||
f(20,180,4,2,'ip_local_out')
|
||||
f(21,180,4,2,'ip_output')
|
||||
f(22,180,4,2,'ip_finish_output')
|
||||
f(23,180,4,2,'__ip_finish_output')
|
||||
f(24,180,4,2,'ip_finish_output2')
|
||||
f(25,180,4,2,'dev_queue_xmit')
|
||||
f(26,180,4,2,'__dev_queue_xmit')
|
||||
f(27,180,4,2,'sch_direct_xmit')
|
||||
f(28,180,4,2,'dev_hard_start_xmit')
|
||||
f(29,180,4,2,'e1000_xmit_frame?[e1000]')
|
||||
f(2,184,45,0,'com/sun/javafx/tk/quantum/QuantumRenderer$PipelineRunnable.run')
|
||||
f(3,184,45,0,'java/util/concurrent/ThreadPoolExecutor$Worker.run')
|
||||
f(4,184,45,0,'java/util/concurrent/ThreadPoolExecutor.runWorker')
|
||||
f(5,184,45,0,'com/sun/javafx/tk/RenderJob.run')
|
||||
f(6,184,45,0,'java/util/concurrent/FutureTask.runAndReset')
|
||||
f(7,184,45,0,'java/util/concurrent/Executors$RunnableAdapter.call')
|
||||
f(8,184,45,0,'com/sun/javafx/tk/quantum/UploadingPainter.run')
|
||||
f(9,184,2,0,'com/sun/javafx/tk/quantum/SceneState.uploadPixels')
|
||||
f(10,184,2,0,'com/sun/glass/ui/Application.invokeLater')
|
||||
f(11,184,2,0,'com/sun/glass/ui/gtk/GtkApplication._invokeLater')
|
||||
f(12,184,2,0,'com/sun/glass/ui/InvokeLaterDispatcher.invokeLater')
|
||||
f(13,184,2,0,'java/util/concurrent/LinkedBlockingDeque.addLast')
|
||||
f(14,184,2,0,'java/util/concurrent/LinkedBlockingDeque.offerLast')
|
||||
f(15,184,2,0,'java/util/concurrent/locks/ReentrantLock.unlock')
|
||||
f(16,184,2,0,'java/util/concurrent/locks/AbstractQueuedSynchronizer.release')
|
||||
f(17,184,2,0,'java/util/concurrent/locks/AbstractQueuedSynchronizer.unparkSuccessor')
|
||||
f(18,184,2,0,'java/util/concurrent/locks/LockSupport.unpark')
|
||||
f(19,184,2,0,'sun/misc/Unsafe.unpark')
|
||||
f(20,184,2,4,'Unsafe_Unpark')
|
||||
f(21,184,2,4,'pthread_cond_signal@@GLIBC_2.3.2')
|
||||
f(22,184,2,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(23,184,2,2,'do_syscall_64')
|
||||
f(24,184,2,2,'__x64_sys_futex')
|
||||
f(25,184,2,2,'do_futex')
|
||||
f(26,184,2,2,'wake_up_q')
|
||||
f(27,184,2,2,'try_to_wake_up')
|
||||
f(28,184,2,2,'_raw_spin_unlock_irqrestore')
|
||||
f(9,186,40,0,'com/sun/javafx/tk/quantum/ViewPainter.paintImpl')
|
||||
f(10,188,38,0,'com/sun/javafx/tk/quantum/ViewPainter.doPaint')
|
||||
f(11,188,38,0,'com/sun/javafx/sg/prism/NGNode.render')
|
||||
f(12,188,38,0,'com/sun/javafx/sg/prism/NGNode.doRender')
|
||||
f(13,188,38,0,'com/sun/javafx/sg/prism/NGRegion.renderContent')
|
||||
f(14,188,38,0,'com/sun/javafx/sg/prism/NGGroup.renderContent')
|
||||
f(15,188,38,0,'com/sun/javafx/sg/prism/NGNode.render')
|
||||
f(16,188,38,0,'com/sun/javafx/sg/prism/NGNode.doRender')
|
||||
f(17,188,21,0,'com/sun/javafx/sg/prism/NGCanvas.renderContent')
|
||||
f(18,188,15,0,'com/sun/javafx/sg/prism/NGCanvas.renderStream')
|
||||
f(19,188,15,0,'com/sun/javafx/sg/prism/NGCanvas.handleRenderOp')
|
||||
f(20,188,11,0,'com/sun/prism/impl/BaseResourceFactory.getCachedTexture')
|
||||
f(21,188,11,0,'com/sun/prism/impl/BaseResourceFactory.getCachedTexture')
|
||||
f(22,189,10,0,'com/sun/prism/sw/SWTexture.update')
|
||||
f(23,189,10,0,'com/sun/prism/sw/SWArgbPreTexture.update')
|
||||
f(24,189,10,0,'com/sun/javafx/image/impl/BaseByteToIntConverter.convert')
|
||||
f(25,189,10,0,'com/sun/javafx/image/impl/BaseByteToIntConverter.convert')
|
||||
f(26,189,10,0,'com/sun/javafx/image/impl/ByteBgra$ToIntArgbSameConv.doConvert')
|
||||
f(20,199,3,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(21,199,3,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(22,199,3,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(23,199,3,0,'com/sun/pisces/PiscesRenderer.drawImage')
|
||||
f(24,199,3,0,'com/sun/pisces/PiscesRenderer.drawImageImpl')
|
||||
f(25,199,3,4,'Java_com_sun_pisces_PiscesRenderer_drawImageImpl')
|
||||
f(26,199,3,4,'fillRect')
|
||||
f(27,200,2,4,'emitLinePTSourceOver8888_pre')
|
||||
f(18,203,6,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(19,203,6,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(20,203,6,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(21,203,6,0,'com/sun/pisces/PiscesRenderer.drawImage')
|
||||
f(22,203,6,0,'com/sun/pisces/PiscesRenderer.drawImageImpl')
|
||||
f(23,203,6,4,'Java_com_sun_pisces_PiscesRenderer_drawImageImpl')
|
||||
f(24,203,6,4,'fillRect')
|
||||
f(25,204,5,4,'emitLinePTSourceOver8888_pre')
|
||||
f(17,209,17,0,'com/sun/javafx/sg/prism/NGNode.renderOpacity')
|
||||
f(18,210,10,0,'com/sun/javafx/sg/prism/NGRegion.renderContent')
|
||||
f(19,210,10,0,'com/sun/javafx/sg/prism/NGGroup.renderContent')
|
||||
f(20,210,10,0,'com/sun/javafx/sg/prism/NGNode.render')
|
||||
f(21,210,10,0,'com/sun/javafx/sg/prism/NGNode.doRender')
|
||||
f(22,210,10,0,'com/sun/javafx/sg/prism/NGRegion.renderContent')
|
||||
f(23,210,8,0,'com/sun/javafx/sg/prism/NGGroup.renderContent')
|
||||
f(24,210,8,0,'com/sun/javafx/sg/prism/NGNode.render')
|
||||
f(25,210,8,0,'com/sun/javafx/sg/prism/NGNode.doRender')
|
||||
f(26,210,3,0,'com/sun/javafx/sg/prism/NGRegion.renderContent')
|
||||
f(27,211,2,0,'com/sun/javafx/sg/prism/NGRegion.renderAsRectangle')
|
||||
f(28,211,2,0,'com/sun/javafx/sg/prism/NGRegion.renderBackgroundRectangle')
|
||||
f(29,211,2,0,'com/sun/javafx/sg/prism/NGRegion.renderBackgroundRectanglesDirectly')
|
||||
f(30,211,2,0,'com/sun/prism/sw/SWGraphics.fill')
|
||||
f(31,211,2,0,'com/sun/prism/sw/SWGraphics.paintShape')
|
||||
f(32,211,2,0,'com/sun/prism/sw/SWGraphics.paintShapePaintAlreadySet')
|
||||
f(33,211,2,0,'com/sun/prism/sw/SWContext.renderShape')
|
||||
f(34,211,2,0,'com/sun/prism/sw/SWContext$JavaShapeRenderer.renderShape')
|
||||
f(35,211,2,0,'com/sun/prism/impl/shape/OpenPiscesPrismUtils.setupRenderer')
|
||||
f(26,213,5,0,'com/sun/javafx/sg/prism/NGShape.renderContent')
|
||||
f(27,213,5,0,'com/sun/javafx/sg/prism/NGText.renderContent2D')
|
||||
f(28,213,4,0,'com/sun/javafx/sg/prism/NGText.renderText')
|
||||
f(29,213,4,0,'com/sun/prism/sw/SWGraphics.drawString')
|
||||
f(30,214,3,0,'com/sun/prism/sw/SWGraphics.drawGlyph')
|
||||
f(23,218,2,0,'com/sun/javafx/sg/prism/NGRegion.renderAsRectangle')
|
||||
f(24,218,2,0,'com/sun/javafx/sg/prism/NGRegion.renderBackgroundRectangle')
|
||||
f(18,220,5,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(19,220,5,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(20,220,5,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(21,220,5,0,'com/sun/prism/sw/SWGraphics.drawTexture')
|
||||
f(22,220,5,0,'com/sun/pisces/PiscesRenderer.drawImage')
|
||||
f(23,220,5,0,'com/sun/pisces/PiscesRenderer.drawImageImpl')
|
||||
f(24,220,5,4,'Java_com_sun_pisces_PiscesRenderer_drawImageImpl')
|
||||
f(25,220,5,4,'fillRect')
|
||||
f(26,220,3,4,'emitLinePTSourceOver8888_pre')
|
||||
f(26,223,2,4,'genTexturePaintMultiply')
|
||||
f(9,227,2,0,'java/nio/DirectIntBufferU.put')
|
||||
f(10,227,2,0,'java/nio/Bits.copyFromArray')
|
||||
f(11,227,2,0,'sun/misc/Unsafe.copyMemory')
|
||||
f(12,227,2,4,'acl_CopyRight')
|
||||
f(2,229,184,0,'java/util/concurrent/FutureTask.run')
|
||||
f(3,229,184,0,'javafx/concurrent/Task$TaskCallable.call')
|
||||
f(4,229,184,0,'demo/parallel/MandelbrotSetTask.call')
|
||||
f(5,229,184,0,'demo/parallel/MandelbrotSetTask.call')
|
||||
f(6,233,175,0,'java/util/stream/IntPipeline$Head.forEach')
|
||||
f(7,233,68,0,'java/util/stream/IntPipeline.forEach')
|
||||
f(8,233,68,0,'java/util/stream/AbstractPipeline.evaluate')
|
||||
f(9,233,68,0,'java/util/stream/ForEachOps$ForEachOp$OfInt.evaluateParallel')
|
||||
f(10,233,68,0,'java/util/stream/ForEachOps$ForEachOp.evaluateParallel')
|
||||
f(11,233,68,0,'java/util/concurrent/ForkJoinTask.invoke')
|
||||
f(12,233,68,0,'java/util/concurrent/ForkJoinTask.doInvoke')
|
||||
f(13,233,25,0,'java/util/concurrent/ForkJoinTask.doExec')
|
||||
f(14,233,25,0,'java/util/concurrent/CountedCompleter.exec')
|
||||
f(15,233,25,0,'java/util/stream/ForEachOps$ForEachTask.compute')
|
||||
f(16,233,24,0,'java/util/stream/AbstractPipeline.copyInto')
|
||||
f(17,233,24,0,'java/util/Spliterator$OfInt.forEachRemaining')
|
||||
f(18,233,24,0,'java/util/stream/Streams$RangeIntSpliterator.forEachRemaining')
|
||||
f(19,233,24,0,'java/util/stream/ForEachOps$ForEachOp$OfInt.accept')
|
||||
f(20,233,24,0,'demo/parallel/MandelbrotSetTask$$Lambda$99/105194951.accept')
|
||||
f(21,233,24,0,'demo/parallel/MandelbrotSetTask.lambda$call$19')
|
||||
f(22,234,2,3,'SharedRuntime::complete_monitor_locking_C(oopDesc*, BasicLock*, JavaThread*)')
|
||||
f(23,234,2,3,'ObjectMonitor::enter(Thread*)')
|
||||
f(24,234,2,3,'ObjectMonitor::TrySpin_VaryDuration(Thread*)')
|
||||
f(22,236,21,0,'demo/parallel/MandelbrotSetTask.calcAntialiasedPixel')
|
||||
f(23,237,19,0,'demo/parallel/MandelbrotSetTask.calcPixel')
|
||||
f(24,237,19,0,'demo/parallel/MandelbrotSetTask.calc')
|
||||
f(25,248,5,0,'demo/parallel/Complex.lengthSQ')
|
||||
f(25,253,3,0,'demo/parallel/Complex.plus')
|
||||
f(13,258,43,0,'java/util/concurrent/ForkJoinTask.externalAwaitDone')
|
||||
f(14,258,43,0,'java/util/concurrent/ForkJoinPool.externalHelpComplete')
|
||||
f(15,258,43,0,'java/util/concurrent/ForkJoinPool.helpComplete')
|
||||
f(16,258,14,0,'java/util/concurrent/ForkJoinPool$WorkQueue.pollAndExecCC')
|
||||
f(17,258,14,0,'java/util/concurrent/ForkJoinTask.doExec')
|
||||
f(18,258,14,0,'java/util/concurrent/CountedCompleter.exec')
|
||||
f(19,258,14,0,'java/util/stream/ForEachOps$ForEachTask.compute')
|
||||
f(20,258,14,0,'java/util/stream/AbstractPipeline.copyInto')
|
||||
f(21,258,14,0,'java/util/Spliterator$OfInt.forEachRemaining')
|
||||
f(22,258,14,0,'java/util/stream/Streams$RangeIntSpliterator.forEachRemaining')
|
||||
f(23,258,14,0,'java/util/stream/ForEachOps$ForEachOp$OfInt.accept')
|
||||
f(24,258,14,0,'demo/parallel/MandelbrotSetTask$$Lambda$99/105194951.accept')
|
||||
f(25,258,14,0,'demo/parallel/MandelbrotSetTask.lambda$call$19')
|
||||
f(26,258,14,0,'demo/parallel/MandelbrotSetTask.calcAntialiasedPixel')
|
||||
f(27,259,13,0,'demo/parallel/MandelbrotSetTask.calcPixel')
|
||||
f(28,259,13,0,'demo/parallel/MandelbrotSetTask.calc')
|
||||
f(29,267,4,0,'demo/parallel/Complex.plus')
|
||||
f(16,272,29,0,'java/util/concurrent/ForkJoinTask.doExec')
|
||||
f(17,272,29,0,'java/util/concurrent/CountedCompleter.exec')
|
||||
f(18,272,29,0,'java/util/stream/ForEachOps$ForEachTask.compute')
|
||||
f(19,272,29,0,'java/util/stream/AbstractPipeline.copyInto')
|
||||
f(20,272,29,0,'java/util/Spliterator$OfInt.forEachRemaining')
|
||||
f(21,272,29,0,'java/util/stream/Streams$RangeIntSpliterator.forEachRemaining')
|
||||
f(22,272,29,0,'java/util/stream/ForEachOps$ForEachOp$OfInt.accept')
|
||||
f(23,272,29,0,'demo/parallel/MandelbrotSetTask$$Lambda$99/105194951.accept')
|
||||
f(24,272,29,0,'demo/parallel/MandelbrotSetTask.lambda$call$19')
|
||||
f(25,273,28,0,'demo/parallel/MandelbrotSetTask.calcAntialiasedPixel')
|
||||
f(26,274,27,0,'demo/parallel/MandelbrotSetTask.calcPixel')
|
||||
f(27,274,27,0,'demo/parallel/MandelbrotSetTask.calc')
|
||||
f(28,287,3,0,'demo/parallel/Complex.lengthSQ')
|
||||
f(28,290,8,0,'demo/parallel/Complex.plus')
|
||||
f(28,298,3,0,'demo/parallel/Complex.times')
|
||||
f(7,301,107,0,'java/util/stream/Streams$RangeIntSpliterator.forEachRemaining')
|
||||
f(8,301,107,0,'demo/parallel/MandelbrotSetTask$$Lambda$99/105194951.accept')
|
||||
f(9,301,107,0,'demo/parallel/MandelbrotSetTask.lambda$call$19')
|
||||
f(10,301,105,0,'demo/parallel/MandelbrotSetTask.calcAntialiasedPixel')
|
||||
f(11,309,97,0,'demo/parallel/MandelbrotSetTask.calcPixel')
|
||||
f(12,312,94,0,'demo/parallel/MandelbrotSetTask.calc')
|
||||
f(13,357,23,0,'demo/parallel/Complex.lengthSQ')
|
||||
f(13,380,16,0,'demo/parallel/Complex.plus')
|
||||
f(13,396,10,0,'demo/parallel/Complex.times')
|
||||
f(6,408,5,0,'javafx/scene/image/WritableImage$2.setColor')
|
||||
f(7,408,3,0,'java/lang/Math.round')
|
||||
f(7,411,2,0,'javafx/scene/image/WritableImage$2.setArgb')
|
||||
f(8,411,2,0,'com/sun/prism/Image.setArgb')
|
||||
f(1,413,163,0,'java/util/concurrent/ForkJoinWorkerThread.run')
|
||||
f(2,413,163,0,'java/util/concurrent/ForkJoinPool.runWorker')
|
||||
f(3,413,163,0,'java/util/concurrent/ForkJoinPool$WorkQueue.runTask')
|
||||
f(4,413,38,0,'java/util/concurrent/ForkJoinPool$WorkQueue.execLocalTasks')
|
||||
f(5,413,38,0,'java/util/concurrent/ForkJoinTask.doExec')
|
||||
f(6,413,38,0,'java/util/concurrent/CountedCompleter.exec')
|
||||
f(7,413,38,0,'java/util/stream/ForEachOps$ForEachTask.compute')
|
||||
f(8,413,38,0,'java/util/stream/AbstractPipeline.copyInto')
|
||||
f(9,413,38,0,'java/util/Spliterator$OfInt.forEachRemaining')
|
||||
f(10,413,38,0,'java/util/stream/Streams$RangeIntSpliterator.forEachRemaining')
|
||||
f(11,413,38,0,'java/util/stream/ForEachOps$ForEachOp$OfInt.accept')
|
||||
f(12,413,38,0,'demo/parallel/MandelbrotSetTask$$Lambda$99/105194951.accept')
|
||||
f(13,413,38,0,'demo/parallel/MandelbrotSetTask.lambda$call$19')
|
||||
f(14,415,32,0,'demo/parallel/MandelbrotSetTask.calcAntialiasedPixel')
|
||||
f(15,421,26,0,'demo/parallel/MandelbrotSetTask.calcPixel')
|
||||
f(16,424,22,0,'demo/parallel/MandelbrotSetTask.calc')
|
||||
f(17,432,7,0,'demo/parallel/Complex.lengthSQ')
|
||||
f(17,439,7,0,'demo/parallel/Complex.plus')
|
||||
f(14,447,4,0,'javafx/scene/image/WritableImage$2.setColor')
|
||||
f(15,448,3,0,'javafx/scene/image/WritableImage$2.setArgb')
|
||||
f(16,449,2,0,'javafx/scene/image/Image.getWritablePlatformImage')
|
||||
f(4,451,125,0,'java/util/concurrent/ForkJoinTask.doExec')
|
||||
f(5,451,125,0,'java/util/concurrent/CountedCompleter.exec')
|
||||
f(6,451,125,0,'java/util/stream/ForEachOps$ForEachTask.compute')
|
||||
f(7,452,124,0,'java/util/stream/AbstractPipeline.copyInto')
|
||||
f(8,452,124,0,'java/util/Spliterator$OfInt.forEachRemaining')
|
||||
f(9,452,124,0,'java/util/stream/Streams$RangeIntSpliterator.forEachRemaining')
|
||||
f(10,452,124,0,'java/util/stream/ForEachOps$ForEachOp$OfInt.accept')
|
||||
f(11,452,124,0,'demo/parallel/MandelbrotSetTask$$Lambda$99/105194951.accept')
|
||||
f(12,452,124,0,'demo/parallel/MandelbrotSetTask.lambda$call$19')
|
||||
f(13,454,119,0,'demo/parallel/MandelbrotSetTask.calcAntialiasedPixel')
|
||||
f(14,462,111,0,'demo/parallel/MandelbrotSetTask.calcPixel')
|
||||
f(15,464,109,0,'demo/parallel/MandelbrotSetTask.calc')
|
||||
f(16,504,39,0,'demo/parallel/Complex.lengthSQ')
|
||||
f(16,543,22,0,'demo/parallel/Complex.plus')
|
||||
f(16,565,8,0,'demo/parallel/Complex.times')
|
||||
f(13,573,3,0,'javafx/scene/image/WritableImage$2.setColor')
|
||||
f(1,576,65,4,'start_thread')
|
||||
f(2,576,65,4,'java_start(Thread*)')
|
||||
f(3,576,4,3,'GCTaskThread::run()')
|
||||
f(4,577,3,3,'OldToYoungRootsTask::do_it(GCTaskManager*, unsigned int)')
|
||||
f(5,577,3,3,'CardTableExtension::scavenge_contents_parallel(ObjectStartArray*, MutableSpace*, HeapWord*, PSPromotionManager*, unsigned int, unsigned int)')
|
||||
f(6,577,3,3,'PSPromotionManager::drain_stacks_depth(bool)')
|
||||
f(7,578,2,3,'oopDesc* PSPromotionManager::copy_to_survivor_space<false>(oopDesc*)')
|
||||
f(3,580,61,3,'JavaThread::run()')
|
||||
f(4,580,61,3,'JavaThread::thread_main_inner()')
|
||||
f(5,580,61,3,'CompileBroker::compiler_thread_loop()')
|
||||
f(6,580,58,3,'CompileBroker::invoke_compiler_on_method(CompileTask*)')
|
||||
f(7,580,58,3,'C2Compiler::compile_method(ciEnv*, ciMethod*, int)')
|
||||
f(8,580,58,3,'Compile::Compile(ciEnv*, C2Compiler*, ciMethod*, int, bool, bool, bool)')
|
||||
f(9,580,32,3,'Compile::Code_Gen()')
|
||||
f(10,582,3,3,'PhaseCFG::do_global_code_motion()')
|
||||
f(11,582,3,3,'PhaseCFG::global_code_motion()')
|
||||
f(10,585,27,3,'PhaseChaitin::Register_Allocate()')
|
||||
f(11,585,2,3,'PhaseChaitin::Select()')
|
||||
f(12,585,2,3,'PhaseIFG::re_insert(unsigned int)')
|
||||
f(11,589,9,3,'PhaseChaitin::build_ifg_physical(ResourceArea*)')
|
||||
f(12,592,3,3,'PhaseChaitin::interfere_with_live(unsigned int, IndexSet*)')
|
||||
f(12,596,2,3,'RegMask::smear_to_sets(int)')
|
||||
f(11,599,3,3,'PhaseChaitin::gather_lrg_masks(bool)')
|
||||
f(11,602,5,3,'PhaseChaitin::post_allocate_copy_removal()')
|
||||
f(12,604,2,3,'PhaseChaitin::elide_copy(Node*, int, Block*, Node_List&, Node_List&, bool)')
|
||||
f(11,609,2,3,'PhaseIFG::init(unsigned int)')
|
||||
f(12,609,2,3,'IndexSet::initialize(unsigned int)')
|
||||
f(9,613,15,3,'Compile::Optimize()')
|
||||
f(10,614,13,3,'PhaseIdealLoop::build_and_optimize(bool, bool)')
|
||||
f(11,617,2,3,'PhaseIdealLoop::build_loop_early(VectorSet&, Node_List&, Node_Stack&)')
|
||||
f(11,619,4,3,'PhaseIdealLoop::build_loop_late(VectorSet&, Node_List&, Node_Stack&)')
|
||||
f(11,625,2,3,'PhaseIterGVN::optimize()')
|
||||
f(12,625,2,3,'PhaseIterGVN::transform_old(Node*)')
|
||||
f(9,629,3,3,'ParseGenerator::generate(JVMState*)')
|
||||
f(10,629,3,3,'Parse::Parse(JVMState*, ciMethod*, float)')
|
||||
f(11,629,3,3,'Parse::do_all_blocks()')
|
||||
f(12,629,3,3,'Parse::do_one_block()')
|
||||
f(13,629,3,3,'Parse::do_one_bytecode()')
|
||||
f(14,629,3,3,'Parse::do_call()')
|
||||
f(15,630,2,3,'PredictedCallGenerator::generate(JVMState*)')
|
||||
f(16,630,2,3,'ParseGenerator::generate(JVMState*)')
|
||||
f(17,630,2,3,'Parse::Parse(JVMState*, ciMethod*, float)')
|
||||
f(18,630,2,3,'Parse::do_all_blocks()')
|
||||
f(19,630,2,3,'Parse::do_one_block()')
|
||||
f(20,630,2,3,'Parse::do_one_bytecode()')
|
||||
f(21,630,2,3,'Parse::do_call()')
|
||||
f(9,632,6,3,'ciEnv::register_method(ciMethod*, int, CodeOffsets*, int, CodeBuffer*, int, OopMapSet*, ExceptionHandlerTable*, ImplicitExceptionTable*, AbstractCompiler*, int, bool, bool, RTMState)')
|
||||
f(10,632,6,3,'nmethod::post_compiled_method_load_event()')
|
||||
f(11,632,6,4,'pthread_cond_signal@@GLIBC_2.3.2')
|
||||
f(12,632,6,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(13,632,6,2,'do_syscall_64')
|
||||
f(14,632,6,2,'__x64_sys_futex')
|
||||
f(15,632,6,2,'do_futex')
|
||||
f(16,632,6,2,'wake_up_q')
|
||||
f(17,632,6,2,'try_to_wake_up')
|
||||
f(18,632,6,2,'_raw_spin_unlock_irqrestore')
|
||||
f(6,638,3,3,'CompileQueue::get()')
|
||||
f(7,638,3,4,'pthread_cond_signal@@GLIBC_2.3.2')
|
||||
f(8,638,3,2,'entry_SYSCALL_64_after_hwframe')
|
||||
f(9,638,3,2,'do_syscall_64')
|
||||
f(10,638,3,2,'__x64_sys_futex')
|
||||
f(11,638,3,2,'do_futex')
|
||||
f(12,638,3,2,'wake_up_q')
|
||||
f(13,638,3,2,'try_to_wake_up')
|
||||
f(14,638,3,2,'_raw_spin_unlock_irqrestore')
|
||||
render();
|
||||
</script></body></html>
|
||||
BIN
demo/flamegraph.png
Normal file
|
After Width: | Height: | Size: 170 KiB |
@@ -1,3 +0,0 @@
|
||||
FROM public.ecr.aws/bellsoft/alpaquita-linux-gcc:15.2-musl
|
||||
|
||||
RUN apk add --no-cache liberica21-jdk util-linux-misc curl
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM public.ecr.aws/docker/library/amazoncorretto:11-alpine-jdk
|
||||
|
||||
RUN apk add --no-cache make gcc g++ linux-headers musl-dev util-linux patchelf gcovr bash tar curl
|
||||
@@ -1,37 +0,0 @@
|
||||
FROM public.ecr.aws/amazonlinux/amazonlinux:2
|
||||
|
||||
RUN amazon-linux-extras enable python3.8
|
||||
|
||||
RUN yum update -y && yum install -y git make python38 gcc10 gcc10-c++ binutils tar
|
||||
|
||||
ARG node_version=20.19.1
|
||||
ARG node_sha256=babcd5b9e3216510b89305e6774bcdb2905ca98ff60028b67f163eb8296b6665
|
||||
RUN curl -L --output node.tar.gz https://github.com/nodejs/node/archive/refs/tags/v${node_version}.tar.gz
|
||||
RUN echo ${node_sha256} node.tar.gz | sha256sum -c
|
||||
RUN mkdir /node
|
||||
RUN tar xf node.tar.gz -C /node --strip-components=1
|
||||
WORKDIR /node
|
||||
|
||||
ENV CC=gcc10-cc
|
||||
ENV CXX=gcc10-c++
|
||||
RUN ./configure
|
||||
RUN make -j4 -s > /dev/null
|
||||
RUN make install
|
||||
|
||||
FROM public.ecr.aws/amazonlinux/amazonlinux:2
|
||||
|
||||
COPY --from=0 /usr/local/bin/node /usr/local/bin/node
|
||||
RUN amazon-linux-extras enable python3.8 && \
|
||||
yum update -y && \
|
||||
yum install -y gcc-c++ binutils make java-11-amazon-corretto patchelf tar python38 && \
|
||||
yum clean all && \
|
||||
rm -rf /var/cache/yum && \
|
||||
python -m ensurepip && \
|
||||
python -m pip install gcovr
|
||||
|
||||
ENV NODE_JS_LOCATION=/__e/node20
|
||||
RUN cat <<EOF > /root/setup.sh
|
||||
#!/bin/sh
|
||||
mkdir -p "$NODE_JS_LOCATION/bin"
|
||||
ln --force --symbolic "/usr/local/bin/node" "$NODE_JS_LOCATION/bin/node"
|
||||
EOF
|
||||
@@ -1,8 +0,0 @@
|
||||
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
|
||||
|
||||
RUN yum update -y && \
|
||||
yum install -y binutils findutils make tar gcc-c++ util-linux && \
|
||||
yum clean all && \
|
||||
rm -rf /var/cache/yum && \
|
||||
python3 -m ensurepip && \
|
||||
python3 -m pip install gcovr
|
||||
@@ -1,10 +0,0 @@
|
||||
# Image for all tasks related to static code analysis in async-profiler
|
||||
FROM public.ecr.aws/docker/library/amazoncorretto:11-alpine-jdk
|
||||
|
||||
ADD --chmod=555 https://raw.githubusercontent.com/llvm/llvm-project/67be4fe3d5fd986a3149de3806bcf2c92320015e/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py /usr/bin/
|
||||
RUN apk add --no-cache clang-extra-tools linux-headers make python3 git py3-pip bash
|
||||
# Needed by clang-tidy-diff.py to merge multiple results in one file.
|
||||
# '--break-system-packages' is needed because Alpine does not like other package managers than 'apk' ('pip' in this case) to install
|
||||
# software globally, but it's safe to do in this case.
|
||||
RUN pip install --break-system-packages pyyaml
|
||||
ENV CPLUS_INCLUDE_PATH="/usr/lib/jvm/java-11-amazon-corretto/include:/usr/lib/jvm/java-11-amazon-corretto/include/linux"
|
||||
@@ -1,32 +0,0 @@
|
||||
# Image for building async-profiler release packages
|
||||
|
||||
# Stage 0: download and build musl
|
||||
FROM public.ecr.aws/debian/debian:10-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
sudo libicu-dev patchelf curl make g++ openjdk-11-jdk-headless gcovr && \
|
||||
rm -rf /var/cache/apt /var/lib/apt/lists/*
|
||||
|
||||
ARG musl_src=musl-1.2.5
|
||||
ARG musl_sha256=a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4
|
||||
|
||||
ADD https://musl.libc.org/releases/${musl_src}.tar.gz /
|
||||
RUN echo ${musl_sha256} ${musl_src}.tar.gz | sha256sum -c
|
||||
|
||||
RUN ["/bin/bash", "-c", "\
|
||||
tar xfz ${musl_src}.tar.gz && \
|
||||
cd /${musl_src} && \
|
||||
./configure --disable-shared --prefix=/usr/local/musl && \
|
||||
make -j`nproc` && make install && make clean && \
|
||||
ln -s /usr/include/$(arch)-linux-gnu/asm /usr/include/{asm-generic,linux} /usr/local/musl/include/"]
|
||||
|
||||
# Stage 1: install build tools + copy musl toolchain from the previous step
|
||||
FROM public.ecr.aws/debian/debian:10-slim
|
||||
|
||||
# The following command should be exactly the same as at stage 0 to benefit from caching.
|
||||
# libicu-dev is needed for the github actions runner
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
sudo libicu-dev patchelf curl make g++ openjdk-11-jdk-headless gcovr && \
|
||||
rm -rf /var/cache/apt /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=0 /usr/local/musl /usr/local/musl
|
||||
@@ -1,35 +0,0 @@
|
||||
# Advanced Stacktrace Features
|
||||
|
||||
## Display JIT compilation task
|
||||
|
||||
Async-profiler samples JIT compiler threads just the same way as Java threads, and hence can show
|
||||
CPU percentage spent on JIT compilation. At the same time, Java methods are different:
|
||||
some take more resources to compile, other take less. Furthermore, there are cases when
|
||||
a bug in C2 compiler causes a JIT thread to stuck in an infinite loop consuming 100% CPU.
|
||||
Async-profiler can highlight which particular Java methods take most CPU time to compile.
|
||||
|
||||

|
||||
|
||||
The feature can be enabled with the option `-F comptask` (or its agent equivalent `features=comptask`).
|
||||
|
||||
## Display actual implementation in vtable
|
||||
|
||||
In some applications, a significant amount of CPU time is spent on dispatching megamorphic virtual/interface calls.
|
||||
async-profiler shows a pseudo-frame on top of v/itable stub with the actual type of object the virtual method is
|
||||
called on. This should make clear the proportion of different receivers for the particular call site.
|
||||
|
||||

|
||||
|
||||
The feature can be enabled with the option `-F vtable` (or its agent equivalent `features=vtable`).
|
||||
|
||||
## Display instruction addresses
|
||||
|
||||
Sometimes, for low-level performance analysis, it is important to know where exactly
|
||||
CPU time is spent inside a method. As an intermediate step to the instruction-level
|
||||
profiling, async-profiler provides an option to record PC address of the currently
|
||||
running method for each execution sample. In this case, each stack trace will include
|
||||
a synthetic frame with the address at the top of every stack trace.
|
||||
|
||||

|
||||
|
||||
The feature can be enabled with the option `-F pcaddr` (or its agent equivalent `features=pcaddr`).
|
||||
@@ -1,177 +0,0 @@
|
||||
# Converter Usage
|
||||
|
||||
async-profiler provides `jfrconv` utility to convert between different profile output formats.
|
||||
`jfrconv` can be found at the same location as the `asprof` binary. Converter is also available
|
||||
as a standalone Java application: [`jfr-converter.jar`](https://github.com/async-profiler/async-profiler/releases/latest/download/jfr-converter.jar).
|
||||
|
||||
## Supported conversions
|
||||
|
||||
The tool can convert several source formats into various outputs. The conversion capabilities are summarized below:
|
||||
|
||||
| Source format | to html | to collapsed | to pprof | to pb.gz | to heatmap | to otlp |
|
||||
| ------------- | ------- | ------------ | -------- | -------- | ---------- | ------- |
|
||||
| jfr | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| html | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
||||
| collapsed | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
jfrconv [options] <input> [<input>...] <output>
|
||||
```
|
||||
|
||||
The output format specified can be only one at a time for conversion from one format to another.
|
||||
|
||||
```
|
||||
Conversion options:
|
||||
-o --output FORMAT, -o can be omitted if the output file extension unambiguously determines the format, e.g. profile.collapsed
|
||||
|
||||
FORMAT can be any of the following:
|
||||
# collapsed: This is a collection of call stacks, where each line is a semicolon separated
|
||||
list of frames followed by a counter. This is used by the FlameGraph script to
|
||||
generate the FlameGraph visualization of the profile data.
|
||||
|
||||
# html: FlameGraph is a hierarchical representation of call traces of the profiled
|
||||
software in a color coded format that helps to identify a particular resource
|
||||
usage like CPU and memory for the application.
|
||||
|
||||
# pprof: pprof is a profiling visualization and analysis tool from Google. More details on
|
||||
pprof on the official github page https://github.com/google/pprof.
|
||||
|
||||
# pb.gz: This is a compressed version of pprof output.
|
||||
|
||||
# heatmap: A single page interactive heatmap that allows to explore profiling events
|
||||
on a timeline.
|
||||
|
||||
# otlp: OpenTelemetry profile format.
|
||||
|
||||
Differential Flame Graph:
|
||||
--diff <base-profile> <new-profile>
|
||||
|
||||
JFR options:
|
||||
--cpu Generate only CPU profile during conversion
|
||||
--cpu-time Generate only CPU profile, using CPUTimeSample events
|
||||
--wall Generate only Wall clock profile during conversion
|
||||
--alloc Generate only Allocation profile during conversion
|
||||
--live Build allocation profile from live objects only during conversion
|
||||
--nativemem Generate native memory allocation profile
|
||||
--leak Only include memory leaks in nativemem
|
||||
--tail RATIO Ignore tail allocations for leak profiling (10% by default)
|
||||
--lock Generate only lock contention profile during conversion
|
||||
--nativelock Generate only native (pthread) lock contention profile
|
||||
--trace Convert only MethodTrace events
|
||||
-t --threads Split stack traces by threads
|
||||
-s --state LIST Filter thread states: runnable, sleeping, default. State name is case insensitive
|
||||
and can be abbreviated, e.g. -s r
|
||||
--classify Classify samples into predefined categories
|
||||
--total Accumulate total value (time, bytes, etc.) instead of samples
|
||||
--lines Show line numbers
|
||||
--bci Show bytecode indices
|
||||
--simple Simple class names instead of fully qualified names
|
||||
--norm Normalize names of hidden classes/lambdas, e.g. Original JFR transforms
|
||||
lambda names to something like pkg.ClassName$$Lambda+0x00007f8177090218/543846639
|
||||
which gets normalized to pkg.ClassName$$Lambda
|
||||
--dot Dotted class names, e.g. java.lang.String instead of java/lang/String
|
||||
--from TIME Start time in ms (absolute or relative)
|
||||
--to TIME End time in ms (absolute or relative)
|
||||
TIME can be:
|
||||
# an absolute timestamp specified in millis since epoch;
|
||||
# an absolute time in hh:mm:ss or yyyy-MM-dd'T'hh:mm:ss format;
|
||||
# a relative time from the beginning of recording;
|
||||
# a relative time from the end of recording (a negative number).
|
||||
--latency MS Retain only samples within MethodTraces of at least MS milliseconds
|
||||
|
||||
Flame Graph options:
|
||||
--title STRING Convert to Flame Graph with provided title
|
||||
--minwidth X Skip frames smaller than X%
|
||||
--grain X Coarsen Flame Graph to the given grain size
|
||||
--skip N Skip N bottom frames
|
||||
-r --reverse Reverse stack traces (defaults to icicle graph)
|
||||
-i --inverted Toggles the layout for reversed stacktraces from icicle to flamegraph
|
||||
and for default stacktraces from flamegraph to icicle
|
||||
-I --include REGEX Include only stacks with the specified frames, e.g. -I 'MyApplication\.main' -I 'VMThread.*'
|
||||
-X --exclude REGEX Exclude stacks with the specified frames, e.g. -X '.*pthread_cond_(wait|timedwait).*'
|
||||
--highlight REGEX Highlight frames matching the given pattern
|
||||
```
|
||||
|
||||
See the [profiler options documentation](ProfilerOptions.md#options-applicable-to-flamegraph-and-tree-view-outputs-only) for details on the `--reverse` and `--inverted` options.
|
||||
|
||||
## jfrconv examples
|
||||
|
||||
`jfrconv` utility is provided in `bin` directory of the async-profiler package.
|
||||
It requires JRE to be installed on the system.
|
||||
|
||||
### Generate Flame Graph from JFR
|
||||
|
||||
If no output file is specified, it defaults to a Flame Graph output.
|
||||
|
||||
```
|
||||
jfrconv foo.jfr
|
||||
```
|
||||
|
||||
Profiling in JFR mode allows multi-mode profiling. So the command above will generate a Flame Graph
|
||||
output, however, for a multi-mode profile output with both `cpu` and `wall-clock` events, the
|
||||
Flame Graph will have an aggregation of both in the view. Such a view wouldn't make much sense and
|
||||
hence it is advisable to use JFR conversion filter options like `--cpu` to filter out events
|
||||
during a conversion.
|
||||
|
||||
```
|
||||
jfrconv --cpu foo.jfr
|
||||
|
||||
# which is equivalent to:
|
||||
# jfrconv --cpu -o html foo.jfr foo.html
|
||||
```
|
||||
|
||||
for HTML output as HTML is the default format for conversion from JFR.
|
||||
|
||||
### Flame Graph options
|
||||
|
||||
To add a custom title to the generated Flame Graph, use `--title`, which has the default value `Flame Graph`:
|
||||
|
||||
```
|
||||
jfrconv --cpu foo.jfr foo.html -r --title "Custom Title"
|
||||
```
|
||||
|
||||
### Differential Flame Graph
|
||||
|
||||
To find performance regressions, it may be useful to compare current profile
|
||||
to a previous one that serves as a baseline. Differential Flame Graph
|
||||
visualizes such a comparsion with a special color scheme:
|
||||
|
||||
- Red color denotes frames with more samples comparing to the baseline (i.e. regression);
|
||||
- Blue is for frames with less samples;
|
||||
- Yellow are new frames that were absent in the baseline.
|
||||
|
||||
The more intense the color, the larger the delta.
|
||||
For each different frame, the delta value is displayed in a tooltip.
|
||||
|
||||

|
||||
|
||||
Differential Flame Graph takes the shape of the current profile:
|
||||
all frames have exactly the same size as in the normal Flame Graph.
|
||||
This means, frames that exist only in the base profile will not be visible.
|
||||
To see such frames, create another differential Flame Graph,
|
||||
swapping the base and the current input file.
|
||||
|
||||
To create differential Flame Graph, run `jfrconv --diff` with two input files:
|
||||
basline profile and new profile. Both files can be in JFR, HTML, or collapsed format.
|
||||
Other converter options work as usual.
|
||||
|
||||
```
|
||||
jfrconv --cpu --diff baseline.jfr new.jfr diff.html
|
||||
```
|
||||
|
||||
Output file name is optional. If omitted, `jfrconv` takes the name
|
||||
of the second input file, replacing its extension with `.diff.html`.
|
||||
|
||||
## Standalone converter examples
|
||||
|
||||
Standalone converter jar is provided in
|
||||
[Download](https://github.com/async-profiler/async-profiler/?tab=readme-ov-file#Download).
|
||||
It accepts the same parameters as `jfrconv`.
|
||||
|
||||
Below is an example usage:
|
||||
|
||||
```
|
||||
java -jar jfr-converter.jar --cpu foo.jfr --reverse --title "Application CPU profile"
|
||||
```
|
||||
@@ -1,76 +0,0 @@
|
||||
# CPU Sampling Engines
|
||||
|
||||
Async-profiler has three options for CPU profiling: `-e cpu`, `-e itimer` and `-e ctimer`.
|
||||
|
||||
## cpu
|
||||
|
||||
`cpu` mode measures CPU time spent by the running threads. For example,
|
||||
if an application uses 2 cpu cores, each with 30% utilization, and the sampling interval is
|
||||
10ms, then the profiler will collect about `2 * 0.3 * 100 = 60` samples per second.
|
||||
In other words, 1 profiling sample means that one CPU core was actively running for N nanoseconds,
|
||||
where N is the profiling interval.
|
||||
|
||||
On Linux, `cpu` mode relies on [perf_events](https://man7.org/linux/man-pages/man2/perf_event_open.2.html).
|
||||
One `perf_event` descriptor is created for each running thread and configured to generate a signal
|
||||
every `N` nanoseconds of CPU time. This is the most accurate CPU sampler available in async-profiler
|
||||
and the only one that can obtain kernel stack traces. It, however, comes with certain restrictions.
|
||||
|
||||
Most importantly, OS configuration may limit access to `perf_events` API, e.g.,
|
||||
by `kernel.perf_event_paranoid` sysctl or by seccomp (which is often the case in a Docker container).
|
||||
If `perf_events` are available, but kernel symbols are hidden (e.g., by `kernel.kptr_resitrct` setting),
|
||||
async-profiler continues to use `perf_events`, emits a warning and does not show kernel stack traces.
|
||||
|
||||
Another important thing to consider is that `cpu` sampling engine allocates a descriptor per thread.
|
||||
This means, if an application has too many threads and OS limit for the maximum number of open descriptors
|
||||
(`ulimit -n`) is too low, an application may run out of file descriptors. The workaround
|
||||
is to simply increase file descriptor limit.
|
||||
|
||||
## itimer
|
||||
|
||||
`itimer` mode is based on [setitimer(ITIMER_PROF)](https://man7.org/linux/man-pages/man2/setitimer.2.html)
|
||||
syscall, which ideally generates a signal every given interval of CPU time consumed by the process.
|
||||
Ideally, both `itimer` and `cpu` should collect the same number of samples. Typically,
|
||||
profiles indeed look very similar. However, in [some cases](https://github.com/golang/go/issues/14434),
|
||||
`cpu` profile appears more accurate, since a signal is delivered exactly to the thread
|
||||
that overflowed a hardware counter. In contrast, `itimer` has the following limitations:
|
||||
|
||||
- Only one `itimer` signal can be delivered to a process at a time.
|
||||
- Signals are not distributed evenly between running threads.
|
||||
- Sampling resolution is limited by the size of [jiffies](https://man7.org/linux/man-pages/man7/time.7.html).
|
||||
|
||||
`itimer` profiles may be even less accurate on macOS, where `itimer` signals are often biased
|
||||
towards system calls.
|
||||
|
||||
The main advantage of `itimer` is that it works in containers and does not consume file descriptors.
|
||||
|
||||
## ctimer
|
||||
|
||||
`ctimer` is a Linux-specific alternative for `cpu` profiling mode to overcome limitations
|
||||
of `perf_events`, such as `perf_event_paraniod` setting, seccomp restriction or a low limit
|
||||
for the number of open file descriptors. `ctimer` mode relies on
|
||||
[timer_create](https://man7.org/linux/man-pages/man2/timer_create.2.html) API.
|
||||
It combines benefits of `-e cpu` and `-e itimer`, except that it does not allow collecting kernel stacks.
|
||||
|
||||
Like with `itimer`, `ctimer` resolution is limited by the size of the jiffy -
|
||||
kernel `HZ` constant, which is typically equal to 100 or 250, meaning that the minimum supported
|
||||
profiling interval is 10ms or 4ms respectively.
|
||||
|
||||
## Summary
|
||||
|
||||
Here is a summary of advantages and drawbacks of all CPU profiling engines:
|
||||
|
||||
| Attribute | cpu (perf_events) | itimer | ctimer |
|
||||
| --------------------------------- | :---------------: | :----: | :----: |
|
||||
| Can collect kernel stack traces | ✅ | ❌ | ❌ |
|
||||
| High resolution | ✅ | ❌ | ❌ |
|
||||
| Accuracy / fairness | ✅ | ❌ | 🆗 |
|
||||
| Works in containers by default | ❌ | ✅ | ✅ |
|
||||
| Does not consume file descriptors | ❌ | ✅ | ✅ |
|
||||
| macOS support | ❌ | ✅ | ❌ |
|
||||
|
||||
When using `-e cpu` on Linux, async-profiler automatically checks for `perf_events` availability
|
||||
by trying to create a dummy perf_event. If kernel-space profiling is not available,
|
||||
async-profiler transparently falls back to `ctimer` mode. To force using `perf_events`
|
||||
for user-space only profiling, specify `-e cpu-clock --all-user` instead of `-e cpu`.
|
||||
|
||||
The actual profiling engine (`perf_events`, `ctimer`, etc.) is now recorded in `jfr` output.
|
||||
@@ -1,85 +0,0 @@
|
||||
# FlameGraph interpretation
|
||||
|
||||
To interpret a flame graph, the best way forward is to understand how it is created.
|
||||
|
||||
## Example application to profile
|
||||
|
||||
Let's take the below example:
|
||||
|
||||
```
|
||||
main() {
|
||||
// some business logic
|
||||
func3() {
|
||||
// some business logic
|
||||
func7();
|
||||
}
|
||||
|
||||
// some business logic
|
||||
func4();
|
||||
|
||||
// some business logic
|
||||
func1() {
|
||||
// some business logic
|
||||
func5();
|
||||
}
|
||||
|
||||
// some business logic
|
||||
func2() {
|
||||
// some business logic
|
||||
func6() {
|
||||
// some business logic
|
||||
func8(); // cpu intensive work here
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Profiler sampling
|
||||
|
||||
Profiling starts by taking samples `X` times per second. Whenever a sample is taken,
|
||||
the current call stack for it is saved. The diagram below shows the unsorted sampling view
|
||||
before the sorting and aggregation takes place.
|
||||
|
||||

|
||||
|
||||
Below are the sampling numbers:
|
||||
|
||||
- `func3()->func7()`: 3 samples
|
||||
- `func4()`: 1 sample
|
||||
- `func1()->func5()`: 2 samples
|
||||
- `func2()->func8()`: 4 samples
|
||||
- `func2()->func6()`: 1 sample
|
||||
|
||||
## Sorting samples
|
||||
|
||||
Samples are then alphabetically sorted at the base level just after root (or main method) of the application.
|
||||
|
||||

|
||||
|
||||
Note that X-axis is no longer a timeline. Flame graph does not preserve information
|
||||
on _when_ a particular stack trace was taken, it only indicates _how often_
|
||||
a stack trace was observed during profiling.
|
||||
|
||||
## Aggregated view
|
||||
|
||||
The blocks for the same functions at each level of stack depth are then stitched together
|
||||
to get an aggregated view of the flame graph.
|
||||

|
||||
|
||||
In this example, except `func4()`, no other function actually consumes
|
||||
any resource at the base level of stack depth. `func5()`, `func6()`,
|
||||
`func7()` and `func8()` are the ones consuming resources, with `func8()`
|
||||
being a likely candidate for performance optimization.
|
||||
|
||||
CPU utilization is the most common use case for flame graphs, however,
|
||||
there are other modes of profiling like allocation profiling to view
|
||||
heap utilization and wall-clock profiling to view latency.
|
||||
|
||||
[More on various modes of profiling](ProfilingModes.md)
|
||||
|
||||
## Understanding FlameGraph colors
|
||||
|
||||
Color is another flame graph dimension that may be used to encode additional information
|
||||
about each frame. Colors may have different meaning in various flame graph implementations.
|
||||
async-profiler uses the following palette to differentiate frame types:
|
||||
|
||||

|
||||
@@ -1,110 +0,0 @@
|
||||
# Getting started guide
|
||||
|
||||
## Before profiling
|
||||
|
||||
As of Linux 4.6, capturing kernel call stacks using `perf_events` from a non-root
|
||||
process requires setting two kernel parameters. You can set them using sysctl as follows:
|
||||
|
||||
```
|
||||
# sysctl kernel.perf_event_paranoid=1
|
||||
# sysctl kernel.kptr_restrict=0
|
||||
```
|
||||
|
||||
For better profiling accuracy, it is [recommended](Troubleshooting.md#known-limitations)
|
||||
to start the JVM with `-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints` flags,
|
||||
unless async-profiler is loaded at JVM startup.
|
||||
|
||||
## Find a process to profile
|
||||
|
||||
Common ways to find the target process include using
|
||||
[`jps`](https://docs.oracle.com/en/java/javase/21/docs/specs/man/jps.html) and
|
||||
[`pgrep`](https://man7.org/linux/man-pages/man1/pgrep.1.html).
|
||||
For example, to list all Java process IDs with their full command lines, run
|
||||
`pgrep -a java`. The next section includes an example using `jps`.
|
||||
|
||||
## Start profiling
|
||||
|
||||
async-profiler works in the context of the target Java application,
|
||||
i.e. it runs as an agent in the process being profiled.
|
||||
`asprof` is a tool to attach and control the agent.
|
||||
|
||||
A typical workflow would be to launch your Java application, attach
|
||||
the agent and start profiling, exercise your performance scenario, and
|
||||
then stop profiling. The agent's output, including the profiling results, will
|
||||
be displayed on the console where you've started `asprof`.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
$ jps
|
||||
9234 Jps
|
||||
8983 Computey
|
||||
$ asprof start 8983
|
||||
$ asprof stop 8983
|
||||
```
|
||||
|
||||
The following may be used in lieu of the `pid` (8983):
|
||||
|
||||
- The keyword `jps`, which will find `pid` automatically, if there is a single Java process running in the system.
|
||||
- The application name as it appears in the `jps` output: e.g. `Computey`
|
||||
|
||||
Alternatively, you may specify `-d` (duration) argument to profile
|
||||
the application for a fixed period of time with a single command.
|
||||
|
||||
```
|
||||
$ asprof -d 30 8983
|
||||
```
|
||||
|
||||
By default, the profiling frequency is 100Hz (every 10ms of CPU time).
|
||||
Here is a sample output of `asprof`:
|
||||
|
||||
```
|
||||
--- Execution profile ---
|
||||
Total samples: 687
|
||||
Unknown (native): 1 (0.15%)
|
||||
|
||||
--- 6790000000 (98.84%) ns, 679 samples
|
||||
[ 0] Primes.isPrime
|
||||
[ 1] Primes.primesThread
|
||||
[ 2] Primes.access$000
|
||||
[ 3] Primes$1.run
|
||||
[ 4] java.lang.Thread.run
|
||||
|
||||
... a lot of output omitted for brevity ...
|
||||
|
||||
ns percent samples top
|
||||
---------- ------- ------- ---
|
||||
6790000000 98.84% 679 Primes.isPrime
|
||||
40000000 0.58% 4 __do_softirq
|
||||
|
||||
... more output omitted ...
|
||||
```
|
||||
|
||||
This indicates that the hottest method was `Primes.isPrime`, and the hottest
|
||||
call stack leading to it comes from `Primes.primesThread`.
|
||||
|
||||
## Other use cases
|
||||
|
||||
- [Launching as an agent](IntegratingAsyncProfiler.md#launching-as-an-agent)
|
||||
- [Java API](IntegratingAsyncProfiler.md#using-java-api)
|
||||
- [IntelliJ IDEA](IntegratingAsyncProfiler.md#intellij-idea)
|
||||
|
||||
## FlameGraph visualization
|
||||
|
||||
async-profiler provides out-of-the-box [Flame Graph](https://www.brendangregg.com/flamegraphs.html) support.
|
||||
Specify `-o flamegraph` argument to dump profiling results as an interactive HTML Flame Graph.
|
||||
Also, Flame Graph output format will be chosen automatically if the target filename ends with `.html`.
|
||||
|
||||
```
|
||||
$ jps
|
||||
9234 Jps
|
||||
8983 Computey
|
||||
$ asprof -d 30 -f /tmp/flamegraph.html 8983
|
||||
```
|
||||
|
||||
[](https://htmlpreview.github.io/?https://github.com/async-profiler/async-profiler/blob/master/.assets/html/flamegraph.html)
|
||||
|
||||
The flame graph html can be opened in any browser of your choice for further interpretation.
|
||||
|
||||
Please refer to [Interpreting a Flame Graph](FlamegraphInterpretation.md)
|
||||
to understand more on how to interpret a Flame Graph.
|
||||
@@ -1,94 +0,0 @@
|
||||
# Heatmap
|
||||
|
||||
Problems to be solved with a profiler can be divided into two large categories:
|
||||
|
||||
1. Optimization of overall resource usage.
|
||||
2. Troubleshooting of intermittent performance issues.
|
||||
|
||||
While flame graphs are handy for the first type of problems, they are not very helpful
|
||||
for analyzing transient anomalies because they provide an aggregated view that lacks
|
||||
any timeline information. To address the second type of problems, async-profiler offers
|
||||
a converter from JFR format to an interactive heatmap in the form of a single-page HTML file.
|
||||
|
||||
Heatmap is an alternative representation of profile data that preserves timestamps
|
||||
of particular samples. Essentially, it's a two-dimensional timeline composed of
|
||||
colored blocks. Each block represents a short period of time (usually in the range of
|
||||
milliseconds to seconds) with its color being the third dimension: the more intense
|
||||
the color, the more events happened in a given period of time.
|
||||
|
||||

|
||||
|
||||
The idea of heatmaps was borrowed from [FlameScope](https://github.com/Netflix/flamescope),
|
||||
however, FlameScope targets short profiling intervals up to a few minutes, whereas
|
||||
async-profiler implementation is capable of visualizing 24-hour recordings
|
||||
with the granularity of 20 milliseconds. Moreover, heatmaps produced by async-profiler
|
||||
are serverless: they are standalone self-contained HTML files that can be easily shared
|
||||
and viewed without additional software besides a browser.
|
||||
|
||||
## Heatmap features
|
||||
|
||||
### Whole day profile
|
||||
|
||||
Heatmaps are optimized for information density. Full day of continuous profiling
|
||||
can be presented on a single image, where an engineer can spot regular activity
|
||||
patterns as well as anomalies at a glance.
|
||||
|
||||
Heatmaps are also optimized for footprint. Specialized compression algorithms
|
||||
can pack 1 GB original JFR recording to an HTML page of 10-15 MB in size.
|
||||
|
||||

|
||||
|
||||
### Scale / zoom
|
||||
|
||||
Depending on the recording duration and level of detail you are interested in,
|
||||
you can switch between 3 available scales. On the largest scale, each vertical line
|
||||
represents 5 minutes of wall clock time, with each square corresponding to
|
||||
5 second interval. On the finest scale, each square corresponds to 20 milliseconds,
|
||||
allowing you to analyze profiling samples with a high resolution.
|
||||
|
||||

|
||||
|
||||
### Instant flame graphs
|
||||
|
||||
A click on any heatmap square displays a flame graph for this specific time interval.
|
||||
|
||||

|
||||
|
||||
Hold mouse button to select an arbitrary time range on a heatmap.
|
||||
A flame graph for the given time range will be built automatically.
|
||||
|
||||

|
||||
|
||||
### Compare time ranges
|
||||
|
||||
Select target time range as described above. Holding `Ctrl` key,
|
||||
move mouse pointer to choose another time range that will serve as a baseline.
|
||||
You will then get a differential flame graph highlighting stacks
|
||||
that were seen more often in the target time range comparing to the baseline.
|
||||
|
||||

|
||||
|
||||
### Search
|
||||
|
||||
Press `Ctrl+F` and enter a regex to search on the entire heatmap.
|
||||
Time intervals containing matched stacks will be highlighted on a heatmap in blue.
|
||||
Matching frames, if any, will be also highlighted on a flame graph.
|
||||
|
||||
`Ctrl+Shift+F` does the same, except that a flame graph will
|
||||
retain stacks with matching frames only. All other stacks will be filtered out.
|
||||
|
||||

|
||||
|
||||
## Producing heatmaps
|
||||
|
||||
Heatmaps can only be generated from recordings in JFR format.
|
||||
Run [`jfrconv`](ConverterUsage.md) tool with `-o heatmap` option.
|
||||
|
||||
Standard `jfrconv` options (`--cpu`, `--alloc`, `--from`/`--to`, `--simple`, etc.)
|
||||
are also applicable to heatmaps.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
jfrconv --cpu -o heatmap profiler.jfr heatmap-cpu.html
|
||||
```
|
||||
@@ -1,65 +0,0 @@
|
||||
# Integrating async-profiler
|
||||
|
||||
## Launching as an agent
|
||||
|
||||
If you need to profile some code as soon as the JVM starts up, instead of using `asprof`,
|
||||
it is possible to attach async-profiler as an agent on the command line. For example:
|
||||
|
||||
```
|
||||
$ java -agentpath:/path/to/libasyncProfiler.so=start,event=cpu,file=profile.html ...
|
||||
```
|
||||
|
||||
On macOS, the library name is `libasyncProfiler.dylib` instead of `libasyncProfiler.so`.
|
||||
|
||||
Agent library is configured through the JVMTI argument interface.
|
||||
The argument string is a comma-separated list of [profiler options](ProfilerOptions.md):
|
||||
|
||||
```
|
||||
option[=value],option[=value]...
|
||||
```
|
||||
|
||||
`asprof` internally converts command line arguments to the above format and attaches
|
||||
`libasyncProfiler.so` agent to a running process.
|
||||
|
||||
Another important use of attaching async-profiler as an agent is for continuous profiling.
|
||||
|
||||
## Using Java API
|
||||
|
||||
async-profiler can be controlled programmatically using Java API. The corresponding Java library
|
||||
is published to Maven Central. You can [include it](https://mvnrepository.com/artifact/tools.profiler/async-profiler/latest)
|
||||
just like any other Maven dependency:
|
||||
|
||||
```
|
||||
<dependency>
|
||||
<groupId>tools.profiler</groupId>
|
||||
<artifactId>async-profiler</artifactId>
|
||||
<version>X.Y</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Example usage with the API
|
||||
|
||||
```
|
||||
AsyncProfiler profiler = AsyncProfiler.getInstance();
|
||||
```
|
||||
|
||||
The above gives us an instance of `AsyncProfiler` object which can be further used to start
|
||||
actual profiling.
|
||||
|
||||
```
|
||||
profiler.execute("start,jfr,event=cpu,file=/path/to/%p.jfr");
|
||||
// do some meaningful work
|
||||
profiler.execute("stop");
|
||||
```
|
||||
|
||||
`%p` equates to the PID of the process. Filename may include other placeholders which
|
||||
can be found in [Profiler Options](ProfilerOptions.md).
|
||||
`file` should be specified only once, either in
|
||||
`start` command with `jfr` output or in `stop` command with any other format.
|
||||
|
||||
## Intellij IDEA
|
||||
|
||||
Intellij IDEA comes bundled with async-profiler, which can be further configured to our needs
|
||||
by selecting the `Java Profiler` menu option at `Settings/Preferences > Build, Execution, Deployment`.
|
||||
Agent options can be modified for the specific use cases and also `Collect native calls` can be checked
|
||||
to monitor non-java threads and native frames in Java stack traces.
|
||||
@@ -1,41 +0,0 @@
|
||||
# JFR Visualization
|
||||
|
||||
JFR recordings produced by async-profiler can be viewed using multiple options explained below.
|
||||
|
||||
## Built-in converter
|
||||
|
||||
async-profiler provides a built-in converter `jfrconv` which can be used to convert `jfr` output
|
||||
to a flame graph or one of the other supported formats. More details on the built-in converter usage
|
||||
can be found [here](ConverterUsage.md).
|
||||
|
||||
## JMC
|
||||
|
||||
[JDK Mission Control](https://www.oracle.com/java/technologies/jdk-mission-control.html) (JMC)
|
||||
is a popular GUI tool to analyze JFR recordings.
|
||||
It has been originally developed to work in conjunction with the JDK Flight Recorder,
|
||||
however, async-profiler recordings are also fully compatible with JMC.
|
||||
|
||||
When viewing async-profiler recordings in JMC, information on some tabs may be missing.
|
||||
Developers are typically interested in the following sections:
|
||||
|
||||
- Java Application
|
||||
- Method Profiling
|
||||
- Memory
|
||||
- Lock Instances
|
||||
- JVM Internals
|
||||
- TLAB Allocations
|
||||
|
||||
## IntelliJ IDEA
|
||||
|
||||
IntelliJ IDEA Ultimate has built-in JFR viewer that works perfectly with async-profiler recordings.
|
||||
For the Community Edition, there is an open-source profiler [plugin](https://plugins.jetbrains.com/plugin/20937-java-jfr-profiler)
|
||||
that allows you to profile Java applications with JFR and async-profiler as well as
|
||||
open JFR files obtained outside IDE.
|
||||
|
||||
## JFR command line tool
|
||||
|
||||
JDK distributions include the `jfr` command line utility to filter, summarize and output
|
||||
flight recording files into human-readable format. The
|
||||
[official documentation](https://docs.oracle.com/en/java/javase/21/docs/specs/man/jfr.html)
|
||||
provides complete information on how to manipulate the contents and translate it as per
|
||||
developers' needs to debug performance issues with their Java applications.
|
||||
@@ -1,63 +0,0 @@
|
||||
# Output Formats
|
||||
|
||||
async-profiler currently supports the following output formats:
|
||||
|
||||
- `collapsed` - This is a collection of call stacks, where each line is a semicolon separated list of frames followed
|
||||
by a counter. This is used by the FlameGraph script to generate the FlameGraph visualization of the profile data.
|
||||
|
||||
```
|
||||
FileConverter.main;FileConverter.convertFile;FileConverter.saveResult 21
|
||||
FileConverter.main;FileConverter.convertFile;FileConverter.saveResult;java/io/DataOutputStream.writeInt 1
|
||||
FileConverter.main;FileConverter.convertFile;FileConverter.saveResult;java/io/DataOutputStream.writeInt;java/io/ByteArrayOutputStream.write 5
|
||||
FileConverter.main;FileConverter.convertFile;FileConverter.saveResult;java/io/DataOutputStream.writeUTF;java/io/DataOutputStream.writeUTF 12
|
||||
FileConverter.main;FileConverter.convertFile;FileConverter.saveResult;java/io/DataOutputStream.writeUTF;java/io/DataOutputStream.writeUTF;java/lang/String.length 3
|
||||
FileConverter.main;FileConverter.convertFile;FileConverter.saveResult;java/io/DataOutputStream.writeUTF;java/io/DataOutputStream.writeUTF;java/io/DataOutputStream.write 6
|
||||
start_thread;thread_native_entry;Thread::call_run;VMThread::run;VMThread::inner_execute;VMThread::evaluate_operation;VM_Operation::evaluate;VM_GenCollectForAllocation::doit;GenCollectedHeap::satisfy_failed_allocation;GenCollectedHeap::do_collection;GenCollectedHeap::collect_generation;DefNewGeneration::collect;DefNewGeneration::FastEvacuateFollowersClosure::do_void 12
|
||||
start_thread;thread_native_entry;Thread::call_run;VMThread::run;VMThread::inner_execute;VMThread::evaluate_operation;VM_Operation::evaluate;VM_GenCollectForAllocation::doit;GenCollectedHeap::satisfy_failed_allocation;GenCollectedHeap::do_collection;GenCollectedHeap::collect_generation;DefNewGeneration::collect;DefNewGeneration::FastEvacuateFollowersClosure::do_void;void ContiguousSpace::oop_since_save_marks_iterate<DefNewScanClosure> 1
|
||||
```
|
||||
|
||||
- `flamegraph` - FlameGraph is a hierarchical representation of call traces of the profiled software in a color coded
|
||||
format. Read more on the [interpretation](FlamegraphInterpretation.md) of FlameGraphs.
|
||||
[](https://htmlpreview.github.io/?https://github.com/async-profiler/async-profiler/blob/master/.assets/html/flamegraph.html)
|
||||
|
||||
- `tree` - Profile output generated in HTML format showing a tree view of resource usage beginning with the call stack
|
||||
with the highest resource usage and then showing other call stacks in descending order of resource usage. Expanding a
|
||||
parent frame follows the same hierarchical representation within that frame.
|
||||

|
||||
|
||||
- `text` - If no output format is specified with `-o` and filename has no extension provided, profiled output is
|
||||
generated in text format.
|
||||
|
||||
```
|
||||
--- Execution profile ---
|
||||
Total samples : 733
|
||||
|
||||
--- 8208 bytes (19.58%), 1 sample
|
||||
[ 0] byte[]
|
||||
[ 1] java.util.jar.Manifest$FastInputStream.<init>
|
||||
[ 2] java.util.jar.Manifest$FastInputStream.<init>
|
||||
[ 3] java.util.jar.Manifest.read
|
||||
[ 4] java.util.jar.Manifest.<init>
|
||||
[ 5] java.util.jar.Manifest.<init>
|
||||
[ 6] java.util.jar.JarFile.getManifestFromReference
|
||||
[ 7] java.util.jar.JarFile.getManifest
|
||||
[ 8] jdk.internal.loader.URLClassPath$JarLoader$2.getManifest
|
||||
[ 9] jdk.internal.loader.BuiltinClassLoader.defineClass
|
||||
[10] jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull
|
||||
[11] jdk.internal.loader.BuiltinClassLoader.loadClassOrNull
|
||||
[12] jdk.internal.loader.BuiltinClassLoader.loadClass
|
||||
[13] jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass
|
||||
[14] java.lang.ClassLoader.loadClass
|
||||
[15] java.lang.Class.forName0
|
||||
[16] java.lang.Class.forName
|
||||
[17] sun.launcher.LauncherHelper.loadMainClass
|
||||
[18] sun.launcher.LauncherHelper.checkAndLoadMain
|
||||
```
|
||||
|
||||
- `jfr` - profile format used by the JDK Flight Recorder. The `jfr` format collects data
|
||||
about the JVM as well as the Java application running on it. async-profiler can generate output in `jfr` format
|
||||
compatible with tools capable of viewing and analyzing `jfr` files. JDK Mission Control (JMC) and Intellij IDEA are
|
||||
some of many options to visualize `jfr` files. More details [here](JfrVisualization.md).
|
||||
|
||||
- `otlp` - OpenTelemetry protocol format for [profiling data](https://opentelemetry.io/blog/2024/profiling).
|
||||
Experimental feature: backward-incompatible changes may happen in future releases of async-profiler.
|
||||
@@ -1,130 +0,0 @@
|
||||
# Profiler options
|
||||
|
||||
The below tables list the profiler options available with `asprof` and also when
|
||||
[launching as an agent](IntegratingAsyncProfiler.md#launching-as-an-agent).
|
||||
Some tables are output specific, which means some options are applicable to only one or more output formats but not all.
|
||||
|
||||
```
|
||||
Usage: asprof [action] [options] [PID]
|
||||
```
|
||||
|
||||
## Actions
|
||||
|
||||
The below options are `action`s for async-profiler and common for both `asprof` binary and when launching as an agent.
|
||||
|
||||
| Option | Description |
|
||||
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `start` | Start profiling in semi-automatic mode, i.e. profiler will run until `stop` command is explicitly called. |
|
||||
| `resume` | Start or resume earlier profiling session that has been stopped. All the collected data remains valid. The profiling options are not preserved between sessions, and should be specified again. |
|
||||
| `stop` | Stop profiling and print the report. |
|
||||
| `dump` | Dump collected data without stopping profiling session. |
|
||||
| `status` | Print profiling status: whether profiler is active and for how long. |
|
||||
| `metrics` | Print profiler metrics in Prometheus format. |
|
||||
| `list` | Show the list of profiling events available for the target process specified with PID. |
|
||||
|
||||
## General options
|
||||
|
||||
| asprof | Launch as agent | Description |
|
||||
| -------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `-o fmt` | `fmt` | Specifies what information to dump when profiling ends. For various dump option details, please refer to [Dump Option Appendix](#dump-option). |
|
||||
| `-f FILENAME` | `file=FILENAME` | The file name to dump the profile information to.<br>`%p` in the file name is expanded to the PID of the target JVM;<br>`%t` - to the timestamp;<br>`%n{MAX}` - to the sequence number;<br>`%{ENV}` - to the value of the given environment variable.<br>Example: `asprof -o collapsed -f /tmp/traces-%t.txt 8983` |
|
||||
| `-d N` | N/A | asprof-only option designed for interactive use. It is a shortcut for running 3 actions: start, sleep for N seconds, stop. If no `start`, `resume`, `stop` or `status` option is given, the profiler will run for the specified period of time and then automatically stop.<br>Example: `asprof -d 30 <pid>` |
|
||||
| `--timeout N` | `timeout=N` | The profiling duration, in seconds. The profiler will run for the specified period of time and then automatically stop.<br>Example: `java -agentpath:/path/to/libasyncProfiler.so=start,event=cpu,timeout=30,file=profile.html <application>` |
|
||||
| `--loop TIME` | `loop=TIME` | Run profiler in a loop (continuous profiling). The argument is either a clock time (`hh:mm:ss`) or a loop duration in `s`econds, `m`inutes, `h`ours, or `d`ays. Make sure the filename includes a timestamp pattern, or the output will be overwritten on each iteration.<br>Example: `asprof --loop 1h -f /var/log/profile-%t.jfr 8983` |
|
||||
| `-e --event EVENT` | `event=EVENT` | The profiling event: `cpu`, `alloc`, `nativemem`, `lock`, `cache-misses` etc. Use `list` to see the complete list of available events.<br>Please refer to [Profiling Modes](ProfilingModes.md) for additional information. |
|
||||
| `-i --interval N` | `interval=N` | Interval has different meaning depending on the event. For CPU profiling, it's CPU time in nanoseconds. In wall clock mode, it's wall clock time. For Java method profiling or native function profiling, it's number of calls. For PMU profiling, it's number of events. Time intervals may be followed by `s` for seconds, `ms` for milliseconds, `us` for microseconds or `ns` for nanoseconds.<br>Example: `asprof -e cpu -i 5ms 8983` |
|
||||
| `--alloc N` | `alloc=N` | Allocation profiling interval in bytes or in other units, if N is followed by `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). |
|
||||
| `--tlab` | `tlab` | Use TLAB events for allocation profiling |
|
||||
| `--live` | `live` | Retain allocation samples with live objects only (object that have not been collected by the end of profiling session). Useful for finding Java heap memory leaks. |
|
||||
| `--nativemem N` | `nativemem=N` | Native memory allocation profiling. N, if specified is the interval in bytes or in other units, if N is followed by `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). Default N is 0. |
|
||||
| `--nofree` | `nofree` | Will not record free calls in native memory allocation profiling. This is relevant when tracking memory leaks is not important and there are lots of free calls. |
|
||||
| `--trace METHOD[:T]` | `trace=METHOD[:T]` | Java method to be traced, optionally followed by a latency threshold.<br>Example: `--trace my.pkg.Class.Method:50ms`.<br>Latency threshold defaults to 0 (all calls are profiled). Can be used multiple times. |
|
||||
| `--lock TIME` | `lock=TIME` | In lock profiling mode, sample contended locks whenever total lock wait time overflows the specified threshold. |
|
||||
| `--nativelock TIME` | `nativelock=TIME ` | In native lock profiling mode, sample contended pthread locks (mutex/rwlock) whenever total lock wait time overflows the specified threshold. |
|
||||
| `--wall INTERVAL` | `wall=INTERVAL` | Wall clock profiling interval. Use this option instead of `-e wall` to enable wall clock profiling with another event, typically `cpu`.<br>Example: `asprof -e cpu --wall 100ms -f combined.jfr 8983`. |
|
||||
| `--nobatch` | `nobatch` | Disable wall clock profiling optimization. Async-profiler will emit one `jdk.ExecutionSample` event for each wall clock sample instead of batching them in a custom `profiler.WallClockSample` event. |
|
||||
| `-j N` | `jstackdepth=N` | Sets the maximum stack depth. The default is 2048.<br>Example: `asprof -j 30 8983`<br>The argument may include two numbers separated by `/` (e.g. `200/40`). In this case, stack traces deeper than 200 frames will be truncated to the top 40 frames. This can be useful to prevent a deep recursion from bloating the profile. |
|
||||
| `-F features` | `features=LIST` | Comma separated (or `+` separated when launching as an agent) list of stack walking features. Supported features are:<ul><li>`stats` - log stack walking performance stats.</li><li>`vtable` - display targets of megamorphic virtual calls as an extra frame on top of `vtable stub` or `itable stub`.</li><li>`comptask` - display current compilation task (a Java method being compiled) in a JIT compiler stack trace.</li><li>`pcaddr` - display instruction addresses .</li></ul>More details [here](AdvancedStacktraceFeatures.md). |
|
||||
| `-L level` | `loglevel=level` | Log level: `debug`, `info`, `warn`, `error` or `none`. |
|
||||
| N/A | `log=FILENAME` | Dedicated file for log messages. Used internally by asprof. |
|
||||
| N/A | `quiet` | Do not log "Profiling started/stopped" message. Used internally by asprof. |
|
||||
| N/A | `server=ADDRESS` | Start insecure HTTP server with the given IP address/port to control the profiler. This option can be specified as `-agentpath` argument only. Be careful not to expose async-profiler server in a public network. |
|
||||
| `--all-user` | `alluser` | Include only user-mode events. This option is helpful when kernel profiling is restricted by `perf_event_paranoid` settings. |
|
||||
| `--sched` | `sched` | Group threads by Linux-specific scheduling policy: BATCH/IDLE/OTHER. |
|
||||
| `--cstack MODE` | `cstack=MODE` | How to walk native frames (C stack). Possible modes are `fp` (Frame Pointer), `dwarf` (DWARF unwind info), `vm`, `vmx` (HotSpot VM Structs) and `no` (do not collect C stack).<br><br>By default, C stack is shown in cpu, ctimer, wall-clock and perf-events profiles. Java-level events like `alloc` and `lock` collect only Java stack. |
|
||||
| `--signal NUM` | `signal=NUM` | Use alternative signal for cpu or wall clock profiling. To change both signals, specify two numbers separated by a slash: `--signal SIGCPU/SIGWALL`. |
|
||||
| `--clock SOURCE` | `clock=SOURCE` | Clock source for JFR timestamps: `tsc` (default) or `monotonic` (equivalent for `CLOCK_MONOTONIC`). |
|
||||
| `--begin function` | `begin=FUNCTION` | Automatically start profiling when the specified native function is executed. |
|
||||
| `--end function` | `end=FUNCTION` | Automatically stop profiling when the specified native function is executed. |
|
||||
| `--ttsp` | `ttsp` | Time-to-safepoint profiling. An alias for `--begin SafepointSynchronize::begin --end RuntimeService::record_safepoint_synchronized`.<br>It is not a separate event type, but rather a constraint. Whatever event type you choose (e.g. `cpu` or `wall`), the profiler will work as usual, except that only events between the safepoint request and the start of the VM operation will be recorded. |
|
||||
| `--nostop` | `nostop` | Record profiling window between `--begin` and `--end`, but do not stop profiling outside window. |
|
||||
| `--memlimit SIZE` | `memlimit=SIZE` | Limit memory used by the call trace storage. Once the limit is exceeded, no new stack traces will be recorded. The lowest possible limit is 10 MB; the default is unlimited.<br>Example: `asprof -e cpu --memlimit 128m` |
|
||||
| `--libpath PATH` | N/A | Full path to `libasyncProfiler.so` (useful when profiling a container from the host). |
|
||||
| `--filter FILTER` | `filter=FILTER` | In the wall-clock profiling mode, profile only threads with the specified ids.<br>Example: `asprof -e wall -d 30 --filter 120-127,132,134 Computey` |
|
||||
| `--fdtransfer` | `fdtransfer` | Run a background process that provides access to perf_events to an unprivileged process. `--fdtransfer` is useful for profiling a process in a container (which lacks access to perf_events) from the host.<br>See [Profiling Java in a container](ProfilingInContainer.md). |
|
||||
| `--target-cpu` | `target-cpu` | In perf_events profiling mode, instruct the profiler to only sample threads running on the specified CPU, defaults to -1.<br>Example: `asprof --target-cpu 3`. |
|
||||
| `--record-cpu` | `record-cpu` | In perf_events profiling mode, instruct the profiler to capture which CPU a sample was taken on. |
|
||||
| `-v --version` | `version` | Prints the version of profiler library. If PID is specified, gets the version of the library loaded into the given process. |
|
||||
|
||||
## Options applicable to JFR output only
|
||||
|
||||
| asprof | Launch as agent | Description |
|
||||
| ------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `--chunksize N` | `chunksize=N` | Approximate size for a single JFR chunk. A new chunk will be started whenever specified size is reached. The default `chunksize` is 100MB.<br>Example: `asprof -f profile.jfr --chunksize 100m 8983` |
|
||||
| `--chunktime N` | `chunktime=N` | Approximate time limit for a single JFR chunk. A new chunk will be started whenever specified time limit is reached. The default `chunktime` is 1 hour.<br>Example: `asprof -f profile.jfr --chunktime 1h 8983` |
|
||||
| `--jfropts OPTIONS` | `jfropts=OPTIONS` | Comma separated list of JFR recording options. Currently, the only available option is `mem` supported on Linux 3.17+. `mem` enables accumulating events in memory instead of flushing synchronously to a file. |
|
||||
| `--jfrsync CONFIG` | `jfrsync[=CONFIG]` | Start Java Flight Recording with the given configuration synchronously with the profiler. The output .jfr file will include all regular JFR events, except that execution samples will be obtained from async-profiler. This option implies `-o jfr`.<br>`CONFIG` is a predefined JFR profile or a JFR configuration file (.jfc) or a list of JFR events started with `+`.<br>Example: `asprof -e cpu --jfrsync profile -f combined.jfr 8983` |
|
||||
| `--proc INTERVAL` | `proc=INTERVAL` | Collect statistics about other processes in the system. Default sampling interval is 30s. |
|
||||
| `--all` | `all` | Shorthand for enabling `cpu`, `wall`, `alloc`, `live`, `lock`, `nativelock`, `nativemem`, and `proc` profiling simultaneously. This can be combined with `--alloc 2m --lock 10ms` etc. to pass custom interval/threshold. It is also possible to combine it with `-e` argument to change the type of event being collected (default is `cpu`). This is not recommended for production, especially for continuous profiling. |
|
||||
|
||||
## Options applicable to FlameGraph and Tree view outputs only
|
||||
|
||||
| asprof | Launch as agent | Description |
|
||||
| -------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `--title TITLE` | `title=TITLE` | Custom title of a FlameGraph.<br>Example: `asprof -f profile.html --title "Sample CPU profile" 8983` |
|
||||
| `--minwidth PERCENT` | `minwidth=PERCENT` | Minimum frame width as a percentage. Smaller frames will not be visible.<br>Example: `asprof -f profile.html --minwidth 0.5 8983` |
|
||||
| `--reverse` | `reverse` | Reverse stack traces (defaults to icicle graph).<br>Example: `asprof -f profile.html --reverse 8983` |
|
||||
| `--inverted` | `inverted` | Toggles the layout for reversed stacktraces from icicle to flamegraph and for default stacktraces from flamegraph to icicle.<br>Example: `asprof -f profile.html --inverted 8983` |
|
||||
|
||||
Notice that `--reverse` and `--inverted` are orthogonal settings. By default, flamegraphs grow from bottom to top (because flames grow from bottom to top). The outermost frames (e.g. the `main()` function) are shown at the bottom while the innermost, leaf frames are shown at the top. If such a flame graph is mirrored on the y-axis, it becomes an icicle graph (icicles grow top-down). The default setting for this layout can be toggled with the `--inverted` option when the graph is created or changed later with the `Invert` button which is located in the upper-left corner of the generated HTML page, when the graph is displayed.
|
||||
|
||||
By default, async-profiler merges stack traces starting from the outermost (e.g. `main()`) frames and displays them from bottom to top in a flamegraph. The `--reverse` option can be used to create reverse stack traces, i.e. merge them starting with the innermost, leaf frames. By default, reversed stack traces are displayed from top to bottom as icicle graphs. The default layout setting for both, normal and reversed stack traces can be changed with the `--inverted` option.
|
||||
|
||||
## Options applicable to any output format except JFR
|
||||
|
||||
| asprof | Launch as agent | Description |
|
||||
| -------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `-t --threads` | `threads` | Profile threads separately. Each stack trace will end with a frame that denotes a single thread.<br>Example: `asprof -t 8983` |
|
||||
| `-s --simple` | `simple` | Print simple class names instead of fully qualified names. |
|
||||
| `-n --norm` | `norm` | Normalize names of hidden classes / lambdas. |
|
||||
| `-g --sig` | `sig` | Print method signatures. |
|
||||
| `-a --ann` | `ann` | Annotate JIT compiled methods with `_[j]`, inlined methods with `_[i]`, interpreted methods with `_[0]` and C1 compiled methods with `_[1]`. FlameGraph and Tree view will color frames depending on their type regardless of this option. |
|
||||
| `-l --lib` | `lib` | Prepend library names to symbols, e.g. ``libjvm.so`JVM_DefineClassWithSource``. |
|
||||
| `--dot` | `dot` | Dotted class names, e.g. `java.lang.String` instead of `java/lang/String`. |
|
||||
| `--samples` | `samples` | Count the number of samples. This is the default aggregation option. |
|
||||
| `--total` | `total` | Count the total value of the collected metric instead of the number of samples, e.g. total allocation size. |
|
||||
| `-I PATTERN` | `include=PATTERN` | Filter stack traces by the given pattern(s). `-I` defines the name pattern that _must_ be present in the stack traces. `-I` can be specified multiple times. A pattern may begin or end with a star `*` that denotes any (possibly empty) sequence of characters.<br>Example: `asprof -I 'Primes.*' -I 'java/*' 8983` |
|
||||
| `-X PATTERN` | `exclude=PATTERN` | Filter stack traces by the given pattern(s). `-X` defines the name pattern that _must not_ occur in any of stack traces in the output. `-X` can be specified multiple times. A pattern may begin or end with a star `*` that denotes any (possibly empty) sequence of characters.<br>Example: `asprof -X '*Unsafe.park*' 8983` |
|
||||
| N/A | `mcache[=AGE]` | Maximum age of the method name cache. Default is `0` (do not cache method names between profiling sessions). |
|
||||
|
||||
## Appendix
|
||||
|
||||
### Dump Option
|
||||
|
||||
`-o fmt` - specifies what information to dump when profiling ends.
|
||||
`fmt` can be one of the following options:
|
||||
|
||||
- `traces[=N]` - dump call traces (at most N samples);
|
||||
- `flat[=N]` - dump flat profile (top N hot methods);
|
||||
- can be combined with `traces`, e.g. `traces=200,flat=200`
|
||||
- `jfr` - dump events in JDK Flight Recorder format readable by JDK Mission Control.
|
||||
- `collapsed` - dump collapsed call traces in the format used by
|
||||
[FlameGraph](https://github.com/brendangregg/FlameGraph) script. This is
|
||||
a collection of call stacks, where each line is a semicolon separated list
|
||||
of frames followed by a counter.
|
||||
- `flamegraph` - produce Flame Graph in HTML format.
|
||||
- `tree` - produce Call Tree in HTML format.
|
||||
- `--reverse` option will generate backtrace view.
|
||||
- `otlp` - dump events in OpenTelemetry format.
|
||||
|
||||
It is possible to specify multiple dump options at the same time.
|
||||
@@ -1,24 +0,0 @@
|
||||
# Profiling Java in a container
|
||||
|
||||
async-profiler provides the ability to profile Java processes running in a Docker or LXC
|
||||
container both from within a container and from the host system.
|
||||
|
||||
When profiling from the host, `pid` should be the Java process ID in the host
|
||||
namespace. Use `ps aux | grep java` or `docker top <container>` to find
|
||||
the process ID.
|
||||
|
||||
async-profiler should be run from the host by a privileged user - it will
|
||||
automatically switch to the proper pid/mount namespace and change
|
||||
user credentials to match the target process. Also make sure that
|
||||
the target container can access `libasyncProfiler.so` by the same
|
||||
absolute path as on the host. Alternatively, specify `--libpath` option
|
||||
to override path to `libasyncProfiler.so` in a container.
|
||||
|
||||
By default, Docker container restricts the access to `perf_event_open`
|
||||
syscall. There are 3 alternatives to allow profiling in a container:
|
||||
|
||||
1. You can modify the [seccomp profile](https://docs.docker.com/engine/security/seccomp/)
|
||||
or disable it altogether with `--security-opt seccomp=unconfined` option. In
|
||||
addition, `--cap-add SYS_ADMIN` may be required.
|
||||
2. You can use "fdtransfer": see the help for `--fdtransfer`.
|
||||
3. Last, you may fall back to `-e ctimer` profiling mode, see [Troubleshooting](Troubleshooting.md).
|
||||
@@ -1,347 +0,0 @@
|
||||
# Profiling modes
|
||||
|
||||
Besides CPU time, async-profiler provides various other profiling modes such as `Allocation`, `Wall Clock`, `Java Method`
|
||||
and even a `Multiple Events` profiling mode.
|
||||
|
||||
## CPU profiling
|
||||
|
||||
In this mode, profiler collects stack trace samples that include **Java** methods,
|
||||
**native** calls, **JVM** code and **kernel** functions.
|
||||
|
||||
The general approach is receiving call stacks generated by `perf_events`
|
||||
and matching them up with call stacks generated by `AsyncGetCallTrace`,
|
||||
in order to produce an accurate profile of both Java and native code.
|
||||
Additionally, async-profiler provides a workaround to recover stack traces
|
||||
in some [corner cases](https://bugs.openjdk.java.net/browse/JDK-8178287)
|
||||
where `AsyncGetCallTrace` fails.
|
||||
|
||||
This approach has the following advantages compared to using `perf_events`
|
||||
directly with a Java agent that translates addresses to Java method names:
|
||||
|
||||
- Does not require `-XX:+PreserveFramePointer`, which introduces
|
||||
performance overhead that can be sometimes as high as 10%.
|
||||
|
||||
- Does not require starting JVM with an agent for translating Java code addresses
|
||||
to method names.
|
||||
|
||||
- Displays interpreter frames.
|
||||
|
||||
- Does not produce large intermediate files (perf.data) for further processing in
|
||||
user space scripts.
|
||||
|
||||
If you wish to resolve frames within `libjvm`, the [debug symbols](#installing-debug-symbols) are required.
|
||||
|
||||
## ALLOCATION profiling
|
||||
|
||||
The profiler can be configured to collect call sites where the largest amount
|
||||
of heap memory is allocated.
|
||||
|
||||
async-profiler does not use intrusive techniques like bytecode instrumentation
|
||||
or expensive DTrace probes which have significant performance impact.
|
||||
It also does not affect Escape Analysis or prevent from JIT optimizations
|
||||
like allocation elimination. Only actual heap allocations are measured.
|
||||
|
||||
The profiler features TLAB-driven sampling. It relies on HotSpot-specific
|
||||
callbacks to receive two kinds of notifications:
|
||||
|
||||
- when an object is allocated in a newly created TLAB;
|
||||
- when an object is allocated on a slow path outside TLAB.
|
||||
|
||||
Sampling interval can be adjusted with `--alloc` option.
|
||||
For example, `--alloc 500k` will take one sample after 500 KB of allocated
|
||||
space on average. Prior to JDK 11, intervals less than TLAB size will not take effect.
|
||||
|
||||
In allocation profiling mode, the top frame of every call trace is the class
|
||||
of the allocated object, and the counter is the heap pressure (the total size
|
||||
of allocated TLABs or objects outside TLAB).
|
||||
|
||||
### Installing Debug Symbols
|
||||
|
||||
Prior to JDK 11, the allocation profiler required HotSpot debug symbols.
|
||||
Some OpenJDK distributions (Amazon Corretto, Liberica JDK, Azul Zulu)
|
||||
already have them embedded in `libjvm.so`, other OpenJDK builds typically
|
||||
provide debug symbols in a separate package. For example, to install
|
||||
OpenJDK debug symbols on Debian / Ubuntu, run:
|
||||
|
||||
```
|
||||
# apt install openjdk-17-dbg
|
||||
```
|
||||
|
||||
(replace `17` with the desired version of JDK).
|
||||
|
||||
On CentOS, RHEL and some other RPM-based distributions, this could be done with
|
||||
[debuginfo-install](http://man7.org/linux/man-pages/man1/debuginfo-install.1.html) utility:
|
||||
|
||||
```
|
||||
# debuginfo-install java-1.8.0-openjdk
|
||||
```
|
||||
|
||||
On Gentoo, the `icedtea` OpenJDK package can be built with the per-package setting
|
||||
`FEATURES="nostrip"` to retain symbols.
|
||||
|
||||
The `gdb` tool can be used to verify if debug symbols are properly installed for the `libjvm` library.
|
||||
For example, on Linux:
|
||||
|
||||
```
|
||||
$ gdb $JAVA_HOME/lib/server/libjvm.so -ex 'info address UseG1GC'
|
||||
```
|
||||
|
||||
This command's output will either contain `Symbol "UseG1GC" is at 0xxxxx`
|
||||
or `No symbol "UseG1GC" in current context`.
|
||||
|
||||
## Native memory leaks
|
||||
|
||||
The profiling mode `nativemem` records `malloc`, `realloc`, `calloc` and `free` calls
|
||||
with the addresses, so that allocations can be matched with frees. This helps to focus
|
||||
the profile report only on unfreed allocations, which are the likely to be a source of a memory leak.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
asprof start -e nativemem -f app.jfr <YourApp>
|
||||
# or
|
||||
asprof start --nativemem N -f app.jfr <YourApp>
|
||||
# or if only allocation calls are interesting, do not collect free calls:
|
||||
asprof start --nativemem N --nofree -f app.jfr <YourApp>
|
||||
|
||||
asprof stop <YourApp>
|
||||
```
|
||||
|
||||
Now we need to process the jfr file, to find native memory leaks:
|
||||
|
||||
```
|
||||
# --total for bytes, default counts invocations.
|
||||
jfrconv --total --nativemem --leak app.jfr app-leak.html
|
||||
|
||||
# No leak analysis, include all native allocations:
|
||||
jfrconv --total --nativemem app.jfr app-malloc.html
|
||||
```
|
||||
|
||||
When `--leak` option is used, the generated flame graph will show allocations without matching `free` calls.
|
||||
|
||||

|
||||
|
||||
To avoid bias towards youngest allocations not freed by the end of the profiling session,
|
||||
leak profiler ignores tail allocations made in the last 10% of the profiling period.
|
||||
Tail length can be altered with `--tail` option that accepts `ratio` or `percent%` as an argument.
|
||||
For example, to ignore allocations in the last 2 minutes of a 10 minutes profile, use
|
||||
|
||||
```
|
||||
jfrconv --nativemem --leak --tail 20% app.jfr app-leak.html
|
||||
```
|
||||
|
||||
The overhead of `nativemem` profiling depends on the number of native allocations,
|
||||
but is usually small enough even for production use. If required, the overhead can be reduced
|
||||
by configuring the profiling interval. E.g. if you add `nativemem=1m` profiler option,
|
||||
allocation samples will be limited to at most one sample per allocated megabyte.
|
||||
|
||||
### Using LD_PRELOAD for finding native memory leaks
|
||||
|
||||
Similar to Java applications, `nativemem` mode can be also used with [non-Java processes](ProfilingNonJavaApplications.md).
|
||||
|
||||
Run an application with `nativemem` profiler that dumps recordings in JFR format every 10 minutes:
|
||||
|
||||
```
|
||||
LD_PRELOAD=/path/to/libasyncProfiler.so ASPROF_COMMAND=start,nativemem,total,loop=10m,cstack=dwarf,file=profile-%t.jfr NativeApp [args]
|
||||
```
|
||||
|
||||
Then run `jfrconv` to generate memory leak report as a flame graph:
|
||||
|
||||
```
|
||||
jfrconv --total --nativemem --leak <profile>.jfr <profile>-leak.html
|
||||
```
|
||||
|
||||
## Wall-clock profiling
|
||||
|
||||
`-e wall` option tells async-profiler to sample all threads equally every given
|
||||
period of time regardless of thread status: Running, Sleeping or Blocked.
|
||||
For instance, this can be helpful when profiling application start-up time.
|
||||
|
||||
Wall-clock profiler is most useful in per-thread mode: `-t`.
|
||||
|
||||
Example: `asprof -e wall -t -i 50ms -f result.html 8983`
|
||||
|
||||
## Lock profiling
|
||||
|
||||
`-e lock` option tells async-profiler to measure lock contention in the profiled application. Lock profiling can help
|
||||
developers understand lock acquisition patterns, lock contention (when threads have to wait to acquire locks), time
|
||||
spent waiting for locks and which code paths are blocked due to locks.
|
||||
|
||||
In lock profiling mode, the top frame is the class of lock/monitor, and the counter is number of nanoseconds it took to
|
||||
enter this lock/monitor.
|
||||
|
||||
Example: `asprof -e lock -t -i 5ms -f result.html 8983`
|
||||
|
||||
## Native lock profiling
|
||||
|
||||
`--nativelock` option tells async-profiler to measure pthread lock contention in the profiled application.
|
||||
Native lock profiling can help developers understand pthread lock acquisition patterns, lock contention (when threads
|
||||
have to wait to acquire native locks), time spent waiting for pthread mutexes and read-write locks, and which code paths
|
||||
are blocked due to native synchronization primitives.
|
||||
|
||||
Native lock profiling works by intercepting calls to:
|
||||
|
||||
- [`pthread_mutex_lock`](https://man7.org/linux/man-pages/man3/pthread_mutex_lock.3p.html)
|
||||
- [`pthread_rwlock_rdlock`](https://man7.org/linux/man-pages/man3/pthread_rwlock_rdlock.3p.html)
|
||||
- [`pthread_rwlock_wrlock`](https://man7.org/linux/man-pages/man3/pthread_rwlock_wrlock.3p.html)
|
||||
|
||||
In this mode, the top frame shows the native function that experienced contention (e.g., pthread_mutex_lock_hook),
|
||||
and the counter represents the number of nanoseconds threads spent waiting to acquire the lock.
|
||||
|
||||
Key differences from Java lock profiling:
|
||||
|
||||
- Profiles native pthread locks instead of Java monitors.
|
||||
- Works with C/C++ applications and native libraries used by Java applications.
|
||||
- Captures contention in native code paths that Java lock profiling cannot see.
|
||||
|
||||
Example: `asprof --nativelock 5ms -t -f result.html 8983`
|
||||
|
||||
## Java method profiling
|
||||
|
||||
`-e ClassName.methodName` option instruments the given Java method
|
||||
in order to record all invocations of this method with the stack traces.
|
||||
|
||||
Example: `-e java.util.Properties.getProperty` will profile all places
|
||||
where `getProperty` method is called from.
|
||||
|
||||
Only non-native Java methods are supported. To profile a native method,
|
||||
use hardware breakpoint event instead, e.g. `-e Java_java_lang_Throwable_fillInStackTrace`
|
||||
|
||||
**Be aware** that if you attach async-profiler at runtime, the first instrumentation
|
||||
of a non-native Java method may cause the [deoptimization](https://github.com/openjdk/jdk/blob/bf2e9ee9d321ed289466b2410f12ad10504d01a2/src/hotspot/share/prims/jvmtiRedefineClasses.cpp#L4092-L4096)
|
||||
of all compiled methods. The subsequent instrumentation flushes only the _dependent code_.
|
||||
|
||||
The massive CodeCache flush doesn't occur if attaching async-profiler as an agent.
|
||||
|
||||
### Latency profiling
|
||||
|
||||
Please refer to our blog post on [latency profiling](https://github.com/async-profiler/async-profiler/discussions/1497)
|
||||
to know more about this profiling mode.
|
||||
|
||||
## Native function profiling
|
||||
|
||||
Here are some useful native functions to profile:
|
||||
|
||||
- `G1CollectedHeap::humongous_obj_allocate` - trace _humongous allocations_ of the G1 GC,
|
||||
- `JVM_StartThread` - trace creation of new Java threads,
|
||||
- `Java_java_lang_ClassLoader_defineClass1` - trace class loading.
|
||||
|
||||
## Multiple events
|
||||
|
||||
It is possible to profile CPU, allocations, and locks at the same time.
|
||||
Instead of CPU, you may choose any other execution event: wall-clock,
|
||||
perf event, tracepoint, Java method, etc.
|
||||
|
||||
The only output format that supports multiple events together is JFR.
|
||||
The recording will contain the following event types:
|
||||
|
||||
- `jdk.ExecutionSample`
|
||||
- `jdk.ObjectAllocationInNewTLAB` (alloc)
|
||||
- `jdk.ObjectAllocationOutsideTLAB` (alloc)
|
||||
- `jdk.JavaMonitorEnter` (lock)
|
||||
- `jdk.ThreadPark` (lock)
|
||||
|
||||
To start profiling cpu + allocations + locks together, specify
|
||||
|
||||
```
|
||||
asprof -e cpu,alloc,lock -f profile.jfr ...
|
||||
```
|
||||
|
||||
or use `--alloc` and `--lock` parameters with the desired threshold:
|
||||
|
||||
```
|
||||
asprof -e cpu --alloc 2m --lock 10ms -f profile.jfr ...
|
||||
```
|
||||
|
||||
The same, when starting profiler as an agent:
|
||||
|
||||
```
|
||||
-agentpath:/path/to/libasyncProfiler.so=start,event=cpu,alloc=2m,lock=10ms,file=profile.jfr
|
||||
```
|
||||
|
||||
### Multi-event profiling using `--all`
|
||||
|
||||
The `--all` flag offers a way to simultaneously enable predefined collection of common profiling events. By default, `--all` activates profiling for `cpu`, `wall`, `alloc`, `live`, `lock` and `nativemem`.
|
||||
|
||||
**Important consideration**
|
||||
|
||||
While the `--all` flag can be useful for development environments to get a wide overview, it is not recommended to enable this in production, especially for continuous profiling. Users are invited to select carefully what to profile and with what settings.
|
||||
|
||||
**Sample command:**
|
||||
|
||||
This command enables the default set of events included in `--all`:
|
||||
|
||||
```
|
||||
asprof --all -f profile.jfr
|
||||
```
|
||||
|
||||
or combine it with `--alloc`/`--wall`/`--lock`/`--nativemem` options to override individual settings. For example:
|
||||
|
||||
```
|
||||
asprof --all --alloc 2m --lock 10ms -f profile.jfr
|
||||
```
|
||||
|
||||
The same, when starting profiler as an agent:
|
||||
|
||||
```
|
||||
-agentpath:/path/to/libasyncProfiler.so=start,all,alloc=2m,lock=10ms,file=profile.jfr
|
||||
```
|
||||
|
||||
Instead of `cpu`, it is possible to override the `--all` parameter with any other event type of your choice. For instance, the following command will profile `cycles` along with ` wall`, `alloc`, `live`, `lock` and `nativemem`:
|
||||
|
||||
```
|
||||
asprof --all -e cycles -f profile.jfr
|
||||
```
|
||||
|
||||
## Continuous profiling
|
||||
|
||||
Continuous profiling is a means by which an application can be profiled
|
||||
continuously and dump profile results every specified time period.
|
||||
It is a very effective technique in finding performance degradations proactively
|
||||
and efficiently. Continuous profiling helps users to understand performance
|
||||
differences between versions of the same application. Recent outputs can
|
||||
be compared with continuous profiling output history to find differences
|
||||
and optimize the changes introduced in case of performance degradations.
|
||||
aysnc-profiler provides the ability to continously profile an application with
|
||||
the `loop` option. Make sure the filename includes a timestamp pattern, or the
|
||||
output will be overwritten on each iteration.
|
||||
|
||||
```
|
||||
asprof --loop 1h -f /var/log/profile-%t.jfr 8983
|
||||
```
|
||||
|
||||
## perf event types supported on Linux
|
||||
|
||||
| Usage | Description |
|
||||
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Predefined: | |
|
||||
| `-e cpu-clock` | High-resolution per-CPU timer. Similar to `-e cpu` but forces using perf_events. |
|
||||
| `-e page-faults` | Software page faults |
|
||||
| `-e context-switches` | Context switches |
|
||||
| `-e cycles` | Total CPU cycles |
|
||||
| `-e ref-cycles` | CPU reference cycles, not affected by CPU frequency scaling |
|
||||
| `-e instructions` | Retired CPU instructions |
|
||||
| `-e cache-references` | Cache accesses (usually Last Level Cache, but may depend on the architecture) |
|
||||
| `-e cache-misses` | Cache accesses requiring fetching data from a higher-level cache or main memory |
|
||||
| `-e branch-instructions` | Retired branch instructions |
|
||||
| `-e branch-misses` | Mispredicted branch instructions |
|
||||
| `-e bus-cycles` | Bus cycles |
|
||||
| `-e L1-dcache-load-misses` | Cache misses on Level 1 Data Cache |
|
||||
| `-e LLC-load-misses` | Cache misses on the Last Level Cache |
|
||||
| `-e dTLB-load-misses` | Data load misses on the Translation Lookaside Buffer |
|
||||
| Breakpoint: | |
|
||||
| `-e mem:<addr>` | Breakpoint on a decimal or hex (0x) address |
|
||||
| `-e mem:<func>` | Breakpoint on a public or a private symbol |
|
||||
| `-e mem:<func>[+<offset>][/<len>][:rwx>]` | Breakpoint on a symbol or an address with offset, length and read/write/exec. Address, offset and length can be hex or dec. The format of `mem` event is the same as in [`perf-record`](https://man7.org/linux/man-pages/man1/perf-record.1.html). |
|
||||
| `-e <symbol>` | Equivalent to an execution breakpoint on a symbol: `mem:<symbol>:x`. Example: `-e strcmp` will trace all calls of native `strcmp` function. |
|
||||
| Tracepoint: | |
|
||||
| `-e trace:<id>` | Kernel tracepoint with the given numeric id |
|
||||
| `-e <tracepoint>` | Kernel tracepoint with the specified name. Example: `-e syscalls:sys_enter_open` will trace all `open` syscalls. |
|
||||
| Probes: | |
|
||||
| `-e kprobe:<func>[+<offset>]` | Kernel probe. Example: `-e kprobe:do_sys_open`. |
|
||||
| `-e kretprobe:<func>[+<offset>]` | Kernel return probe. Example: `-e kretprobe:do_sys_open`. |
|
||||
| `-e uprobe:<func>[+<offset>]` | Userspace probe. Example: `-e uprobe:/usr/lib64/libc-2.17.so+0x114790`. |
|
||||
| `-e uretprobe:<func>[+<offset>]` | Userspace return probe |
|
||||
| PMU: | |
|
||||
| `-e r<NNN>` | Architecture-specific PMU event with the given number. Example: `-e r4d2` selects `MEM_LOAD_L3_HIT_RETIRED.XSNP_HITM` event, which corresponds to event 0xd2, umask 0x4. |
|
||||
| `-e <pmu descriptor>` | PMU event descriptor. Example: `-e cpu/cache-misses/`, `-e cpu/event=0xd2,umask=4/`. The same syntax can be used for uncore and vendor-specific events, e.g. `amd_l3/event=0x01,umask=0x80/` |
|
||||
@@ -1,95 +0,0 @@
|
||||
# Profiling Non-Java applications
|
||||
|
||||
The scope of profiling non-Java applications is limited to the case when profiler is controlled
|
||||
programmatically from the process being profiled or with `LD_PRELOAD`. It is worth noting that
|
||||
[dynamic attach](IntegratingAsyncProfiler.md#launching-as-an-agent)
|
||||
which is available for Java is not supported for non-Java profiling.
|
||||
|
||||
## LD_PRELOAD
|
||||
|
||||
async-profiler can be injected into a native application through the `LD_PRELOAD` mechanism:
|
||||
|
||||
```
|
||||
LD_PRELOAD=/path/to/libasyncProfiler.so ASPROF_COMMAND=start,event=cpu,file=profile.jfr NativeApp [args]
|
||||
```
|
||||
|
||||
All basic functionality remains the same. Profiler can run in `cpu`, `wall`, `nativemem` and other perf_events
|
||||
modes. Flame Graph and JFR output formats are supported, although JFR files will obviously lack
|
||||
Java-specific events.
|
||||
|
||||
See [Profiling Modes](ProfilingModes.md) for more examples.
|
||||
|
||||
## Controlling async-profiler via the C API
|
||||
|
||||
Similar to the
|
||||
[Java API](IntegratingAsyncProfiler.md#using-java-api),
|
||||
there is a C API for using profiler inside a native application.
|
||||
|
||||
Header file for the API is bundled in the async-profiler release package under [`include/asprof.h`](../src/asprof.h).
|
||||
|
||||
To use it in a C/C++ application, include the mentioned `asprof.h`. Below is an example showing how to invoke async-profiler with the API:
|
||||
|
||||
```
|
||||
#include "asprof.h"
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void test_output_callback(const char* buffer, size_t size) {
|
||||
fwrite(buffer, sizeof(char), size, stderr);
|
||||
}
|
||||
|
||||
int main() {
|
||||
void* lib = dlopen("/path/to/libasyncProfiler.so", RTLD_NOW);
|
||||
if (lib == NULL) {
|
||||
printf("%s\n", dlerror());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
asprof_init_t asprof_init = (asprof_init_t)dlsym(lib, "asprof_init");
|
||||
asprof_execute_t asprof_execute = (asprof_execute_t)dlsym(lib, "asprof_execute");
|
||||
asprof_error_str_t asprof_error_str = (asprof_error_str_t)dlsym(lib, "asprof_error_str");
|
||||
|
||||
if (asprof_init == NULL || asprof_execute == NULL || asprof_error_str == NULL) {
|
||||
printf("%s\n", dlerror());
|
||||
dlclose(lib);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
asprof_init();
|
||||
|
||||
printf("Starting profiler\n");
|
||||
|
||||
char cmd[] = "start,event=cpu,loglevel=debug,file=profile.jfr";
|
||||
asprof_error_t err = asprof_execute(cmd, test_output_callback);
|
||||
if (err != NULL) {
|
||||
fprintf(stderr, "%s\n", asprof_error_str(err));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// ... some meaningful work ...
|
||||
|
||||
printf("Stopping profiler\n");
|
||||
|
||||
err = asprof_execute("stop", test_output_callback);
|
||||
if (err != NULL) {
|
||||
fprintf(stderr, "%s\n", asprof_error_str(err));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## Unstable APIs
|
||||
|
||||
These APIs are unstable and might change or be removed in the next version of async-profiler.
|
||||
|
||||
### Advanced Sampling
|
||||
|
||||
The `asprof_get_thread_local_data` function returns a pointer to async-profiler's
|
||||
thread-local data structure. The structure is guaranteed to live as long as the thread.
|
||||
|
||||
The returned structure contains a pointer that increments every time there is a sample. This gives
|
||||
native code an easy way to detect when a sample event had occurred, and to log metadata about what the
|
||||
program was doing when the event happened.
|
||||
@@ -1,56 +0,0 @@
|
||||
# Stack Walking Modes
|
||||
|
||||
## Frame Pointer
|
||||
|
||||
`Frame Pointer (FP)` stack walking is a technique for collecting call stacks by tracking frame pointers in memory.
|
||||
Each function call maintains a pointer to its caller's stack frame, creating a linked chain that can be traversed
|
||||
to reconstruct the program's execution path. It's particularly efficient as it is very fast compared to other
|
||||
stack walking methods introducing less overhead but requires code to be compiled with frame
|
||||
pointers enabled (`-fno-omit-frame-pointer`).
|
||||
|
||||
Before async-profiler 4.2, Frame Pointer was the default stack walking mode.
|
||||
Since version 4.2, the default was changed to [VM Structs](#vm-structs).
|
||||
|
||||
## DWARF
|
||||
|
||||
DWARF stack walking is a method to reconstruct call stacks using unwinding information embedded in executables
|
||||
(typically in `.eh_frame` section). Unlike frame-pointer-based unwinding, it works reliably even with optimized code
|
||||
where frame pointers are omitted.
|
||||
|
||||
DWARF unwinding requires extra memory (e.g. the lookup table for `libjvm.so` is about 2MB).
|
||||
It is also slower than the traditional FP-based stack walker, but it's still fast enough for on-the-fly unwinding
|
||||
due to being signal safe in async-profiler.
|
||||
|
||||
The feature can be enabled with the option `--cstack dwarf` (or its agent equivalent `cstack=dwarf`).
|
||||
|
||||
## VM Structs
|
||||
|
||||
async-profiler can leverage JVM internal structures to replicate the logic of Java stack walking
|
||||
in the profiler itself without depending on the unstable JVM API.
|
||||
|
||||
This mode of stack walking has been introduced in async-profiler due to issues with `AsyncCallGetTrace`.
|
||||
AsyncGetCallTrace (AGCT) is a non-standard extension of HotSpot JVM to obtain Java stack traces outside safepoints.
|
||||
async-profiler had been relying on AGCT heavily, and it even got its name after this function.
|
||||
|
||||
`AsyncGetCallTrace` being non-API, was never supported in OpenJDK well enough, it did not receive enough testing, it was
|
||||
broken several times even in minor JDK updates, e.g. [JDK-8307549](https://bugs.openjdk.org/browse/JDK-8307549).
|
||||
|
||||
AsyncGetCallTrace is notorious for its inability to walk Java stack in different corner cases. There is a long-standing
|
||||
bug [JDK-8178287](https://bugs.openjdk.org/browse/JDK-8178287) with several examples. But the worst aspect is that
|
||||
AsyncGetCallTrace can crash JVM, and there is no reliable way to get around this outside the JVM.
|
||||
|
||||
Due to issues with AGCT from time to time, including random crashes and missing stack traces,
|
||||
`vm` stack walking mode based on HotSpot VM Structs was introduced in async-profiler.
|
||||
`vm` stack walker has the following advantages:
|
||||
|
||||
- Fully enclosed by the crash protection based on `setjmp`/`longjmp`.
|
||||
- Can show all frames: Java, native and JVM stubs throughout the whole stack.
|
||||
- Provides additional information on each frame, like JIT compilation type.
|
||||
|
||||
The feature can be enabled with the option `--cstack vm` (or its agent equivalent `cstack=vm`).
|
||||
Since async-profiler 4.2, this is the default mode when running on the HotSpot JVM.
|
||||
|
||||
Another variant of this option: `--cstack vmx` activates an "expert" unwinding based on VM Structs.
|
||||
With this option, async-profiler collects mixed stack traces that have Java and native frames interleaved.
|
||||
|
||||
The maximum stack depth for `vm` or `vmx` stack walking is controlled with `-j depth` option.
|
||||
@@ -1,133 +0,0 @@
|
||||
# Troubleshooting
|
||||
|
||||
## Error Messages
|
||||
|
||||
### perf_event mmap failed: Operation not permitted
|
||||
|
||||
Profiler allocates 8 kB perf_event buffer for each thread of the target process.
|
||||
The above error may appear if the total size of perf_event buffers (`8 * threads` kB)
|
||||
exceeds locked memory limit. This limit is comprised of `ulimit -l` plus
|
||||
the value of `kernel.perf_event_mlock_kb` sysctl multiplied by the number of CPU cores.
|
||||
For example, on a 16-core machine, `ulimit -l 65536` and `kernel.perf_event_mlock_kb=516`
|
||||
is enough for profiling `(65536 + 516*16) / 8 = 9224` threads.
|
||||
If an application has more threads, increase one of the above limits, or native stacks
|
||||
will not be collected for some threads.
|
||||
|
||||
A privileged process is not subject to the locked memory limit.
|
||||
|
||||
### Failed to change credentials to match the target process: Operation not permitted
|
||||
|
||||
Due to limitation of HotSpot Dynamic Attach mechanism, the profiler must be run
|
||||
by exactly the same user (and group) as the owner of target JVM process.
|
||||
If profiler is run by a different user, it will try to automatically change
|
||||
current user and group. This will likely succeed for `root`, but not for
|
||||
other users, resulting in the above error.
|
||||
|
||||
### Could not start attach mechanism: No such file or directory
|
||||
|
||||
The profiler cannot establish communication with the target JVM through UNIX domain socket.
|
||||
Usually this happens in one of the following cases:
|
||||
|
||||
1. Attach socket `/tmp/.java_pidNNN` has been deleted. It is a common
|
||||
practice to clean `/tmp` automatically with some scheduled script.
|
||||
Configure the cleanup software to exclude `.java_pid*` files from deletion.
|
||||
|
||||
- How to check: run `lsof -p PID | grep java_pid`. If it lists a socket file, but the file does not exist, then this is exactly
|
||||
the described problem.
|
||||
|
||||
2. JVM is started with `-XX:+DisableAttachMechanism` option.
|
||||
3. `/tmp` directory of Java process is not physically the same directory
|
||||
as `/tmp` of your shell, because Java is running in a container or in
|
||||
`chroot` environment. `asprof` attempts to solve this automatically,
|
||||
but it might lack the required permissions to do so.
|
||||
- Check `strace asprof PID jcmd`
|
||||
4. JVM is busy and cannot reach a safepoint. For instance,
|
||||
JVM is in the middle of long-running garbage collection.
|
||||
- How to check: run `kill -3 PID`. Healthy JVM process should print
|
||||
a thread dump and heap info in its console.
|
||||
|
||||
### Target JVM failed to load libasyncProfiler.so
|
||||
|
||||
The connection with the target JVM has been established, but JVM is unable to load profiler shared library.
|
||||
Make sure the user of JVM process has permissions to access `libasyncProfiler.so` by exactly the same absolute path.
|
||||
For more information see [#78](https://github.com/async-profiler/async-profiler/issues/78).
|
||||
|
||||
### Perf events unavailable
|
||||
|
||||
`perf_event_open()` syscall has failed. Typical reasons include:
|
||||
|
||||
1. `/proc/sys/kernel/perf_event_paranoid` is set to restricted mode (>=2).
|
||||
2. seccomp disables `perf_event_open` API in a container.
|
||||
3. OS runs under a hypervisor that does not virtualize performance counters.
|
||||
4. perf_event_open API is not supported on this system, e.g. WSL.
|
||||
|
||||
<br>For permissions-related reasons (such as 1 and 2), using `--fdtransfer` while running the profiler
|
||||
as a privileged user may solve the issue.
|
||||
|
||||
If changing the configuration is not possible, you may fall back to
|
||||
`-e ctimer` profiling mode. It is similar to `cpu` mode, but does not
|
||||
require perf_events support. As a drawback, there will be no kernel
|
||||
stack traces.
|
||||
|
||||
### No AllocTracer symbols found. Are JDK debug symbols installed?
|
||||
|
||||
The OpenJDK debug symbols are required for allocation profiling for applications developed
|
||||
with JDK prior to 11. See [Installing Debug Symbols](ProfilingModes.md#installing-debug-symbols) for more
|
||||
details. If the error message persists after a successful installation of the debug symbols,
|
||||
it is possible that the JDK was upgraded when installing the debug symbols.
|
||||
In this case, profiling any Java process which had started prior to the installation
|
||||
will continue to display this message, since the process had loaded
|
||||
the older version of the JDK which lacked debug symbols.
|
||||
Restarting the affected Java processes should resolve the issue.
|
||||
|
||||
### VMStructs unavailable. Unsupported JVM?
|
||||
|
||||
JVM shared library does not export `gHotSpotVMStructs*` symbols -
|
||||
apparently this is not a HotSpot JVM. Sometimes the same message
|
||||
can be also caused by an incorrectly built JDK
|
||||
(see [#218](https://github.com/async-profiler/async-profiler/issues/218)).
|
||||
In these cases installing JDK debug symbols may solve the problem.
|
||||
|
||||
### Could not parse symbols from <libname.so>
|
||||
|
||||
Async-profiler was unable to parse non-Java function names because of
|
||||
the corrupted contents in `/proc/[pid]/maps`. The problem is known to
|
||||
occur in a container when running Ubuntu with Linux kernel 5.x.
|
||||
This is the OS bug, see <https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1843018>.
|
||||
|
||||
### Could not open output file
|
||||
|
||||
Output file is written by the target JVM process, not by the profiler script.
|
||||
Make sure the path specified in `-f` option is correct and is accessible by the JVM.
|
||||
|
||||
## Known Limitations
|
||||
|
||||
- No Java stacks will be collected if `-XX:MaxJavaStackTraceDepth` is zero
|
||||
or negative. The exception is `--cstack vm` mode, which does not take
|
||||
`MaxJavaStackTraceDepth` into account.
|
||||
|
||||
- Too short profiling interval may cause continuous interruption of heavy
|
||||
system calls like `clone()`, so that it will never complete;
|
||||
see [#97](https://github.com/async-profiler/async-profiler/issues/97).
|
||||
The workaround is simply to increase the interval.
|
||||
|
||||
- When agent is not loaded at JVM startup (by using -agentpath option) it is
|
||||
highly recommended to use `-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints` JVM flags.
|
||||
Without those flags the profiler will still work correctly but results might be
|
||||
less accurate. For example, without `-XX:+DebugNonSafepoints` there is a high chance
|
||||
that simple inlined methods will not appear in the profile. When the agent is attached at runtime,
|
||||
`CompiledMethodLoad` JVMTI event enables debug info, but only for methods compiled after attaching.
|
||||
|
||||
- On most Linux systems, `perf_events` captures call stacks with a maximum depth
|
||||
of 127 frames. On recent Linux kernels, this can be configured using
|
||||
`sysctl kernel.perf_event_max_stack` or by writing to the
|
||||
`/proc/sys/kernel/perf_event_max_stack` file.
|
||||
|
||||
- You will not see the non-Java frames _preceding_ the Java frames on the
|
||||
stack, unless `--cstack vmx` is specified.
|
||||
For example, if `start_thread` called `JavaMain` and then your Java
|
||||
code started running, you will not see the first two frames in the resulting
|
||||
stack. On the other hand, you _will_ see non-Java frames (user and kernel)
|
||||
invoked by your Java code.
|
||||
|
||||
- macOS profiling is limited to user space code only.
|
||||
@@ -2,8 +2,8 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>tools.profiler</groupId>
|
||||
<artifactId>jfr-converter</artifactId>
|
||||
<version>4.4</version>
|
||||
<artifactId>async-profiler-converter</artifactId>
|
||||
<version>2.9</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>async-profiler</name>
|
||||
@@ -18,9 +18,9 @@
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<url>https://github.com/async-profiler/async-profiler</url>
|
||||
<connection>scm:git:git@github.com:async-profiler/async-profiler.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:async-profiler/async-profiler.git</developerConnection>
|
||||
<url>https://github.com/jvm-profiling-tools/async-profiler</url>
|
||||
<connection>scm:git:git@github.com:jvm-profiling-tools/async-profiler.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:jvm-profiling-tools/async-profiler.git</developerConnection>
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
@@ -47,7 +47,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>8</release>
|
||||
<source>7</source>
|
||||
<target>7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -57,7 +58,7 @@
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>one.convert.Main</mainClass>
|
||||
<mainClass>Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
@@ -102,15 +103,17 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.central</groupId>
|
||||
<artifactId>central-publishing-maven-plugin</artifactId>
|
||||
<version>0.8.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<publishingServerId>central</publishingServerId>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
71
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>tools.profiler</groupId>
|
||||
<artifactId>async-profiler</artifactId>
|
||||
<version>4.4</version>
|
||||
<version>2.9</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>async-profiler</name>
|
||||
@@ -18,9 +18,9 @@
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<url>https://github.com/async-profiler/async-profiler</url>
|
||||
<connection>scm:git:git@github.com:async-profiler/async-profiler.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:async-profiler/async-profiler.git</developerConnection>
|
||||
<url>https://github.com/jvm-profiling-tools/async-profiler</url>
|
||||
<connection>scm:git:git@github.com:jvm-profiling-tools/async-profiler.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:jvm-profiling-tools/async-profiler.git</developerConnection>
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
@@ -47,7 +47,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>8</release>
|
||||
<source>7</source>
|
||||
<target>7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -56,53 +57,19 @@
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>linux-x64-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classifier>linux-x64</classifier>
|
||||
<classifier>${native.platform}</classifier>
|
||||
<includes>
|
||||
<include>linux-x64/*</include>
|
||||
<include>one/**</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>linux-arm64-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classifier>linux-arm64</classifier>
|
||||
<includes>
|
||||
<include>linux-arm64/*</include>
|
||||
<include>one/**</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>macos-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classifier>macos</classifier>
|
||||
<includes>
|
||||
<include>macos/*</include>
|
||||
<include>${native.platform}/*</include>
|
||||
<include>one/**</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>src/api/one/profiler/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -150,15 +117,17 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.central</groupId>
|
||||
<artifactId>central-publishing-maven-plugin</artifactId>
|
||||
<version>0.8.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<publishingServerId>central</publishingServerId>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
381
profiler.sh
Executable file
@@ -0,0 +1,381 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [action] [options] <pid>"
|
||||
echo "Actions:"
|
||||
echo " start start profiling and return immediately"
|
||||
echo " resume resume profiling without resetting collected data"
|
||||
echo " stop stop profiling"
|
||||
echo " dump dump collected data without stopping profiling session"
|
||||
echo " check check if the specified profiling event is available"
|
||||
echo " status print profiling status"
|
||||
echo " meminfo print profiler memory stats"
|
||||
echo " list list profiling events supported by the target JVM"
|
||||
echo " collect collect profile for the specified period of time"
|
||||
echo " and then stop (default action)"
|
||||
echo "Options:"
|
||||
echo " -e event profiling event: cpu|alloc|lock|cache-misses etc."
|
||||
echo " -d duration run profiling for <duration> seconds"
|
||||
echo " -f filename dump output to <filename>"
|
||||
echo " -i interval sampling interval in nanoseconds"
|
||||
echo " -j jstackdepth maximum Java stack depth"
|
||||
echo " -t profile different threads separately"
|
||||
echo " -s simple class names instead of FQN"
|
||||
echo " -g print method signatures"
|
||||
echo " -a annotate Java methods"
|
||||
echo " -l prepend library names"
|
||||
echo " -o fmt output format: flat|traces|collapsed|flamegraph|tree|jfr"
|
||||
echo " -I include output only stack traces containing the specified pattern"
|
||||
echo " -X exclude exclude stack traces with the specified pattern"
|
||||
echo " -v, --version display version string"
|
||||
echo ""
|
||||
echo " --title string FlameGraph title"
|
||||
echo " --minwidth pct skip frames smaller than pct%"
|
||||
echo " --reverse generate stack-reversed FlameGraph / Call tree"
|
||||
echo ""
|
||||
echo " --loop time run profiler in a loop"
|
||||
echo " --alloc bytes allocation profiling interval in bytes"
|
||||
echo " --live build allocation profile from live objects only"
|
||||
echo " --lock duration lock profiling threshold in nanoseconds"
|
||||
echo " --total accumulate the total value (time, bytes, etc.)"
|
||||
echo " --all-user only include user-mode events"
|
||||
echo " --sched group threads by scheduling policy"
|
||||
echo " --cstack mode how to traverse C stack: fp|dwarf|lbr|no"
|
||||
echo " --begin function begin profiling when function is executed"
|
||||
echo " --end function end profiling when function is executed"
|
||||
echo " --ttsp time-to-safepoint profiling"
|
||||
echo " --jfrsync config synchronize profiler with JFR recording"
|
||||
echo " --lib path full path to libasyncProfiler.so in the container"
|
||||
echo " --fdtransfer use fdtransfer to serve perf requests"
|
||||
echo " from the non-privileged target"
|
||||
echo ""
|
||||
echo "<pid> is a numeric process ID of the target JVM"
|
||||
echo " or 'jps' keyword to find running JVM automatically"
|
||||
echo " or the application's name as it would appear in the jps tool"
|
||||
echo ""
|
||||
echo "Example: $0 -d 30 -f profile.html 3456"
|
||||
echo " $0 start -i 999000 jps"
|
||||
echo " $0 stop -o flat jps"
|
||||
echo " $0 -d 5 -e alloc MyAppName"
|
||||
exit 1
|
||||
}
|
||||
|
||||
mirror_output() {
|
||||
# Mirror output from temporary file to local terminal
|
||||
if [ "$USE_TMP" = true ]; then
|
||||
if [ -f "$FILE" ]; then
|
||||
cat "$FILE"
|
||||
rm "$FILE"
|
||||
elif [ -f "$ROOT_PREFIX$FILE" ]; then
|
||||
cat "$ROOT_PREFIX$FILE"
|
||||
rm "$ROOT_PREFIX$FILE"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
mirror_log() {
|
||||
# Try to access the log file both directly and through /proc/[pid]/root,
|
||||
# in case the target namespace differs
|
||||
if [ -f "$LOG" ]; then
|
||||
cat "$LOG" >&2
|
||||
rm "$LOG"
|
||||
elif [ -f "$ROOT_PREFIX$LOG" ]; then
|
||||
cat "$ROOT_PREFIX$LOG" >&2
|
||||
rm "$ROOT_PREFIX$LOG"
|
||||
fi
|
||||
}
|
||||
|
||||
check_if_terminated() {
|
||||
if ! kill -0 "$PID" 2> /dev/null; then
|
||||
mirror_output
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
fdtransfer() {
|
||||
if [ "$USE_FDTRANSFER" = "true" ]; then
|
||||
FDTRANSFER_PATH="@async-profiler-$(od -An -N3 -i /dev/random | xargs)"
|
||||
PARAMS="$PARAMS,fdtransfer=$FDTRANSFER_PATH"
|
||||
"$FDTRANSFER" "$FDTRANSFER_PATH" "$PID"
|
||||
fi
|
||||
}
|
||||
|
||||
jattach() {
|
||||
set +e
|
||||
"$JATTACH" "$PID" load "$PROFILER" true "$1,log=$LOG" > /dev/null
|
||||
RET=$?
|
||||
|
||||
# Check if jattach failed
|
||||
if [ $RET -ne 0 ]; then
|
||||
if [ $RET -eq 255 ]; then
|
||||
echo "Failed to inject profiler into $PID"
|
||||
if [ "$UNAME_S" = "Darwin" ]; then
|
||||
otool -L "$PROFILER"
|
||||
else
|
||||
LD_PRELOAD="$PROFILER" /bin/true
|
||||
fi
|
||||
fi
|
||||
|
||||
mirror_log
|
||||
exit $RET
|
||||
fi
|
||||
|
||||
mirror_log
|
||||
mirror_output
|
||||
set -e
|
||||
}
|
||||
|
||||
SCRIPT_BIN="$0"
|
||||
while [ -h "$SCRIPT_BIN" ]; do
|
||||
SCRIPT_BIN="$(readlink "$SCRIPT_BIN")"
|
||||
done
|
||||
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_BIN")" > /dev/null 2>&1; pwd -P)"
|
||||
|
||||
JATTACH=$SCRIPT_DIR/build/jattach
|
||||
FDTRANSFER=$SCRIPT_DIR/build/fdtransfer
|
||||
USE_FDTRANSFER="false"
|
||||
FDTRANSFER_PATH=""
|
||||
PROFILER=$SCRIPT_DIR/build/libasyncProfiler.so
|
||||
ACTION="collect"
|
||||
DURATION="60"
|
||||
FILE=""
|
||||
USE_TMP="true"
|
||||
OUTPUT=""
|
||||
FORMAT=""
|
||||
PARAMS=""
|
||||
PID=""
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
-h|"-?")
|
||||
usage
|
||||
;;
|
||||
start|resume|stop|dump|check|status|meminfo|list|collect)
|
||||
ACTION="$1"
|
||||
;;
|
||||
-v|--version)
|
||||
ACTION="version"
|
||||
;;
|
||||
-e)
|
||||
PARAMS="$PARAMS,event=$2"
|
||||
shift
|
||||
;;
|
||||
-d)
|
||||
DURATION="$2"
|
||||
shift
|
||||
;;
|
||||
-f)
|
||||
FILE="$2"
|
||||
USE_TMP=false
|
||||
shift
|
||||
;;
|
||||
-i)
|
||||
PARAMS="$PARAMS,interval=$2"
|
||||
shift
|
||||
;;
|
||||
-j)
|
||||
PARAMS="$PARAMS,jstackdepth=$2"
|
||||
shift
|
||||
;;
|
||||
-t)
|
||||
PARAMS="$PARAMS,threads"
|
||||
;;
|
||||
-s)
|
||||
FORMAT="$FORMAT,simple"
|
||||
;;
|
||||
-g)
|
||||
FORMAT="$FORMAT,sig"
|
||||
;;
|
||||
-a)
|
||||
FORMAT="$FORMAT,ann"
|
||||
;;
|
||||
-l)
|
||||
FORMAT="$FORMAT,lib"
|
||||
;;
|
||||
-o)
|
||||
OUTPUT="$2"
|
||||
shift
|
||||
;;
|
||||
-I|--include)
|
||||
FORMAT="$FORMAT,include=$2"
|
||||
shift
|
||||
;;
|
||||
-X|--exclude)
|
||||
FORMAT="$FORMAT,exclude=$2"
|
||||
shift
|
||||
;;
|
||||
--filter)
|
||||
FILTER="$(echo "$2" | sed 's/,/;/g')"
|
||||
FORMAT="$FORMAT,filter=$FILTER"
|
||||
shift
|
||||
;;
|
||||
--title)
|
||||
# escape XML special characters and comma
|
||||
TITLE="$(echo "$2" | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/,/\,/g')"
|
||||
FORMAT="$FORMAT,title=$TITLE"
|
||||
shift
|
||||
;;
|
||||
--width|--height|--minwidth)
|
||||
FORMAT="$FORMAT,${1#--}=$2"
|
||||
shift
|
||||
;;
|
||||
--reverse)
|
||||
FORMAT="$FORMAT,reverse"
|
||||
;;
|
||||
--samples|--total)
|
||||
FORMAT="$FORMAT,${1#--}"
|
||||
;;
|
||||
--alloc|--lock|--chunksize|--chunktime)
|
||||
PARAMS="$PARAMS,${1#--}=$2"
|
||||
shift
|
||||
;;
|
||||
--timeout|--loop)
|
||||
if [ "$ACTION" = "collect" ]; then
|
||||
ACTION="start"
|
||||
fi
|
||||
PARAMS="$PARAMS,${1#--}=$2"
|
||||
shift
|
||||
;;
|
||||
--all-user)
|
||||
PARAMS="$PARAMS,alluser"
|
||||
;;
|
||||
--sched)
|
||||
PARAMS="$PARAMS,sched"
|
||||
;;
|
||||
--live)
|
||||
PARAMS="$PARAMS,live"
|
||||
;;
|
||||
--cstack|--call-graph)
|
||||
PARAMS="$PARAMS,cstack=$2"
|
||||
shift
|
||||
;;
|
||||
--begin|--end)
|
||||
PARAMS="$PARAMS,${1#--}=$2"
|
||||
shift
|
||||
;;
|
||||
--ttsp)
|
||||
PARAMS="$PARAMS,begin=SafepointSynchronize::begin,end=RuntimeService::record_safepoint_synchronized"
|
||||
;;
|
||||
--jfrsync)
|
||||
OUTPUT="jfr"
|
||||
PARAMS="$PARAMS,jfrsync=$2"
|
||||
shift
|
||||
;;
|
||||
--lib)
|
||||
PROFILER="$2"
|
||||
shift
|
||||
;;
|
||||
--fdtransfer)
|
||||
USE_FDTRANSFER="true"
|
||||
;;
|
||||
--safe-mode)
|
||||
PARAMS="$PARAMS,safemode=$2"
|
||||
shift
|
||||
;;
|
||||
[0-9]*)
|
||||
PID="$1"
|
||||
;;
|
||||
jps)
|
||||
# A shortcut for getting PID of a running Java application
|
||||
# -XX:+PerfDisableSharedMem prevents jps from appearing in its own list
|
||||
PID=$(pgrep -n java || jps -q -J-XX:+PerfDisableSharedMem)
|
||||
if [ "$PID" = "" ]; then
|
||||
echo "No Java process could be found!"
|
||||
fi
|
||||
;;
|
||||
-*)
|
||||
echo "Unrecognized option: $1"
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
if [ $# -eq 1 ]; then
|
||||
# the last argument is the application name as it would appear in the jps tool
|
||||
PID=$(jps -J-XX:+PerfDisableSharedMem | grep " $1$" | head -n 1 | cut -d ' ' -f 1)
|
||||
if [ "$PID" = "" ]; then
|
||||
echo "No Java process '$1' could be found!"
|
||||
fi
|
||||
else
|
||||
echo "Unrecognized option: $1"
|
||||
usage
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$PID" = "" ]; then
|
||||
case "$ACTION" in
|
||||
version)
|
||||
java "-agentpath:$PROFILER=version=full" -version 2> /dev/null
|
||||
;;
|
||||
list)
|
||||
java "-agentpath:$PROFILER=list" -version 2> /dev/null
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If no -f argument is given, use temporary file to transfer output to caller terminal.
|
||||
# Let the target process create the file in case this script is run by superuser.
|
||||
if [ "$USE_TMP" = true ]; then
|
||||
FILE=/tmp/async-profiler.$$.$PID
|
||||
else
|
||||
case "$FILE" in
|
||||
/*)
|
||||
# Path is absolute
|
||||
;;
|
||||
*)
|
||||
# Output file is written by the target process. Make the path absolute to avoid confusion.
|
||||
FILE=$PWD/$FILE
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
LOG=/tmp/async-profiler-log.$$.$PID
|
||||
|
||||
UNAME_S=$(uname -s)
|
||||
if [ "$UNAME_S" = "Linux" ]; then
|
||||
ROOT_PREFIX="/proc/$PID/root"
|
||||
else
|
||||
ROOT_PREFIX=""
|
||||
fi
|
||||
|
||||
case $ACTION in
|
||||
start|resume)
|
||||
fdtransfer
|
||||
jattach "$ACTION,file=$FILE,$OUTPUT$FORMAT$PARAMS"
|
||||
;;
|
||||
check)
|
||||
jattach "$ACTION,file=$FILE,$OUTPUT$FORMAT$PARAMS"
|
||||
;;
|
||||
stop|dump)
|
||||
jattach "$ACTION,file=$FILE,$OUTPUT$FORMAT"
|
||||
;;
|
||||
status|meminfo|list)
|
||||
jattach "$ACTION,file=$FILE"
|
||||
;;
|
||||
version)
|
||||
jattach "version=full,file=$FILE"
|
||||
;;
|
||||
collect)
|
||||
fdtransfer
|
||||
jattach "start,file=$FILE,$OUTPUT$FORMAT$PARAMS"
|
||||
echo Profiling for "$DURATION" seconds >&2
|
||||
set +e
|
||||
trap 'DURATION=0' INT
|
||||
|
||||
while [ "$DURATION" -gt 0 ]; do
|
||||
DURATION=$(( DURATION-1 ))
|
||||
check_if_terminated
|
||||
sleep 1
|
||||
done
|
||||
|
||||
set -e
|
||||
trap - INT
|
||||
echo Done >&2
|
||||
jattach "stop,file=$FILE,$OUTPUT$FORMAT"
|
||||
;;
|
||||
esac
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright The async-profiler authors
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function list-archive() {
|
||||
case "${1}" in
|
||||
*.tar.gz) tar -tzvf "${1}" --wildcards '*/bin/*' '*/lib/*' | awk '$1 ~ /^-/ { print $NF, $3 }' ;;
|
||||
*.zip) zipinfo -l "${1}" '*/bin/*' '*/lib/*' | awk '$1 ~ /^-/ { print $NF, $4 }' ;;
|
||||
esac | cut -d/ -f2- | sort
|
||||
}
|
||||
|
||||
function main() {
|
||||
if [[ ${#} -ne 2 ]]; then
|
||||
printf 'Usage: compare-binary-sizes.sh <base-archive> <treatment-archive>\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[[ ${1} =~ (linux-x64|linux-arm64|macos) ]]
|
||||
printf '### %s\n\n| File | Base (KiB) | Treatment (KiB) | Delta (KiB) | %% Change |\n| --- | ---: | ---: | ---: | ---: |\n' "${BASH_REMATCH[1]}"
|
||||
join -a1 -a2 -e0 -o '0,1.2,2.2' \
|
||||
<(list-archive "${1}") \
|
||||
<(list-archive "${2}") \
|
||||
| awk '{
|
||||
b = $2; t = $3; d = t - b; pct = b > 0 ? d * 100 / b : 0
|
||||
printf "| `%s` | %.2f | %.2f | %+.2f | %+.2f%% |\n", $1, b/1024, t/1024, d/1024, pct
|
||||
}'
|
||||
}
|
||||
|
||||
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && main "$@"
|
||||
@@ -1,54 +1,38 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2017 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "allocTracer.h"
|
||||
#include "profiler.h"
|
||||
#include "stackFrame.h"
|
||||
#include "tsc.h"
|
||||
#include "vmStructs.h"
|
||||
|
||||
|
||||
int AllocTracer::_trap_kind;
|
||||
Trap AllocTracer::_in_new_tlab(0);
|
||||
Trap AllocTracer::_outside_tlab(1);
|
||||
volatile bool AllocTracer::_use_hook = false;
|
||||
|
||||
u64 AllocTracer::_interval;
|
||||
volatile u64 AllocTracer::_allocated_bytes;
|
||||
|
||||
|
||||
Error AllocTracer::initialize() {
|
||||
if (_in_new_tlab.entry() == 0 || _outside_tlab.entry() == 0) {
|
||||
CodeCache* libjvm = VMStructs::libjvm();
|
||||
const void* ne;
|
||||
const void* oe;
|
||||
|
||||
if ((ne = libjvm->findSymbolByPrefix("_ZN11AllocTracer27send_allocation_in_new_tlab")) != NULL &&
|
||||
(oe = libjvm->findSymbolByPrefix("_ZN11AllocTracer28send_allocation_outside_tlab")) != NULL) {
|
||||
_trap_kind = 1; // JDK 10+
|
||||
} else if ((ne = libjvm->findSymbolByPrefix("_ZN11AllocTracer33send_allocation_in_new_tlab_eventE11KlassHandleP8HeapWord")) != NULL &&
|
||||
(oe = libjvm->findSymbolByPrefix("_ZN11AllocTracer34send_allocation_outside_tlab_eventE11KlassHandleP8HeapWord")) != NULL) {
|
||||
_trap_kind = 1; // JDK 8u262+
|
||||
} else if ((ne = libjvm->findSymbolByPrefix("_ZN11AllocTracer33send_allocation_in_new_tlab_event")) != NULL &&
|
||||
(oe = libjvm->findSymbolByPrefix("_ZN11AllocTracer34send_allocation_outside_tlab_event")) != NULL) {
|
||||
_trap_kind = 2; // JDK 7-9
|
||||
} else {
|
||||
return Error("No AllocTracer symbols found. Are JDK debug symbols installed?");
|
||||
}
|
||||
|
||||
_in_new_tlab.assign(ne);
|
||||
_outside_tlab.assign(oe);
|
||||
_in_new_tlab.pair(_outside_tlab);
|
||||
}
|
||||
|
||||
return Error::OK;
|
||||
}
|
||||
|
||||
// Called whenever our breakpoint trap is hit
|
||||
void AllocTracer::trapHandler(int signo, siginfo_t* siginfo, void* ucontext) {
|
||||
StackFrame frame(ucontext);
|
||||
EventType event_type;
|
||||
int event_type;
|
||||
uintptr_t total_size;
|
||||
uintptr_t instance_size;
|
||||
|
||||
@@ -56,13 +40,13 @@ void AllocTracer::trapHandler(int signo, siginfo_t* siginfo, void* ucontext) {
|
||||
if (_in_new_tlab.covers(frame.pc())) {
|
||||
// send_allocation_in_new_tlab(Klass* klass, HeapWord* obj, size_t tlab_size, size_t alloc_size, Thread* thread)
|
||||
// send_allocation_in_new_tlab_event(KlassHandle klass, size_t tlab_size, size_t alloc_size)
|
||||
event_type = ALLOC_SAMPLE;
|
||||
event_type = BCI_ALLOC;
|
||||
total_size = _trap_kind == 1 ? frame.arg2() : frame.arg1();
|
||||
instance_size = _trap_kind == 1 ? frame.arg3() : frame.arg2();
|
||||
} else if (_outside_tlab.covers(frame.pc())) {
|
||||
// send_allocation_outside_tlab(Klass* klass, HeapWord* obj, size_t alloc_size, Thread* thread)
|
||||
// send_allocation_outside_tlab_event(KlassHandle klass, size_t alloc_size);
|
||||
event_type = ALLOC_OUTSIDE_TLAB;
|
||||
event_type = BCI_ALLOC_OUTSIDE_TLAB;
|
||||
total_size = _trap_kind == 1 ? frame.arg2() : frame.arg1();
|
||||
instance_size = 0;
|
||||
} else {
|
||||
@@ -80,10 +64,33 @@ void AllocTracer::trapHandler(int signo, siginfo_t* siginfo, void* ucontext) {
|
||||
}
|
||||
}
|
||||
|
||||
void AllocTracer::recordAllocation(void* ucontext, EventType event_type, uintptr_t rklass,
|
||||
void AllocTracer::inNewTLAB1(uintptr_t klass, void* obj, size_t tlab_size, size_t alloc_size) {
|
||||
if (_use_hook && _enabled && updateCounter(_allocated_bytes, tlab_size, _interval)) {
|
||||
recordAllocation(NULL, BCI_ALLOC, klass, tlab_size, alloc_size);
|
||||
}
|
||||
}
|
||||
|
||||
void AllocTracer::outsideTLAB1(uintptr_t klass, void* obj, size_t alloc_size) {
|
||||
if (_use_hook && _enabled && updateCounter(_allocated_bytes, alloc_size, _interval)) {
|
||||
recordAllocation(NULL, BCI_ALLOC_OUTSIDE_TLAB, klass, alloc_size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void AllocTracer::inNewTLAB2(uintptr_t klass, size_t tlab_size, size_t alloc_size) {
|
||||
if (_use_hook && _enabled && updateCounter(_allocated_bytes, tlab_size, _interval)) {
|
||||
recordAllocation(NULL, BCI_ALLOC, klass, tlab_size, alloc_size);
|
||||
}
|
||||
}
|
||||
|
||||
void AllocTracer::outsideTLAB2(uintptr_t klass, size_t alloc_size) {
|
||||
if (_use_hook && _enabled && updateCounter(_allocated_bytes, alloc_size, _interval)) {
|
||||
recordAllocation(NULL, BCI_ALLOC_OUTSIDE_TLAB, klass, alloc_size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void AllocTracer::recordAllocation(void* ucontext, int event_type, uintptr_t rklass,
|
||||
uintptr_t total_size, uintptr_t instance_size) {
|
||||
AllocEvent event;
|
||||
event._start_time = TSC::ticks();
|
||||
event._class_id = 0;
|
||||
event._total_size = total_size;
|
||||
event._instance_size = instance_size;
|
||||
@@ -96,27 +103,66 @@ void AllocTracer::recordAllocation(void* ucontext, EventType event_type, uintptr
|
||||
Profiler::instance()->recordSample(ucontext, total_size, event_type, &event);
|
||||
}
|
||||
|
||||
Error AllocTracer::start(Arguments& args) {
|
||||
if (args._live && !args._all) {
|
||||
// This engine is only going to be selected in Profiler::selectAllocEngine
|
||||
// when can_generate_sampled_object_alloc_events is not available, i.e. JDK<11.
|
||||
Error AllocTracer::check(Arguments& args) {
|
||||
if (args._live) {
|
||||
return Error("'live' option is supported on OpenJDK 11+");
|
||||
}
|
||||
|
||||
Error error = initialize();
|
||||
if (error) return error;
|
||||
|
||||
_interval = args._alloc > 0 ? args._alloc : 0;
|
||||
_allocated_bytes = 0;
|
||||
|
||||
if (!_in_new_tlab.install() || !_outside_tlab.install()) {
|
||||
return Error("Cannot install allocation breakpoints");
|
||||
if (_in_new_tlab.entry() != 0 && _outside_tlab.entry() != 0) {
|
||||
return Error::OK;
|
||||
}
|
||||
|
||||
CodeCache* libjvm = VMStructs::libjvm();
|
||||
const void* ne;
|
||||
const void* oe;
|
||||
|
||||
if ((ne = libjvm->findSymbolByPrefix("_ZN11AllocTracer27send_allocation_in_new_tlab")) != NULL &&
|
||||
(oe = libjvm->findSymbolByPrefix("_ZN11AllocTracer28send_allocation_outside_tlab")) != NULL) {
|
||||
_trap_kind = 1; // JDK 10+
|
||||
} else if ((ne = libjvm->findSymbolByPrefix("_ZN11AllocTracer33send_allocation_in_new_tlab_eventE11KlassHandleP8HeapWord")) != NULL &&
|
||||
(oe = libjvm->findSymbolByPrefix("_ZN11AllocTracer34send_allocation_outside_tlab_eventE11KlassHandleP8HeapWord")) != NULL) {
|
||||
_trap_kind = 1; // JDK 8u262+
|
||||
} else if ((ne = libjvm->findSymbolByPrefix("_ZN11AllocTracer33send_allocation_in_new_tlab_event")) != NULL &&
|
||||
(oe = libjvm->findSymbolByPrefix("_ZN11AllocTracer34send_allocation_outside_tlab_event")) != NULL) {
|
||||
_trap_kind = 2; // JDK 7-9
|
||||
} else {
|
||||
return Error("No AllocTracer symbols found. Are JDK debug symbols installed?");
|
||||
}
|
||||
|
||||
_in_new_tlab.assign(ne);
|
||||
_outside_tlab.assign(oe);
|
||||
_in_new_tlab.pair(_outside_tlab);
|
||||
|
||||
return Error::OK;
|
||||
}
|
||||
|
||||
void AllocTracer::stop() {
|
||||
_in_new_tlab.uninstall();
|
||||
_outside_tlab.uninstall();
|
||||
Error AllocTracer::start(Arguments& args) {
|
||||
Error error = check(args);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
_interval = args._alloc > 0 ? args._alloc : 0;
|
||||
_allocated_bytes = 0;
|
||||
|
||||
if (args._alloc_hook) {
|
||||
if ((_trap_kind == 1 && _in_new_tlab.install((void*)inNewTLAB1) && _outside_tlab.install((void*)outsideTLAB1)) ||
|
||||
(_trap_kind == 2 && _in_new_tlab.install((void*)inNewTLAB2) && _outside_tlab.install((void*)outsideTLAB2))) {
|
||||
_use_hook = true;
|
||||
return Error::OK;
|
||||
}
|
||||
} else if (_in_new_tlab.install() && _outside_tlab.install()) {
|
||||
return Error::OK;
|
||||
}
|
||||
|
||||
return Error("Cannot install allocation breakpoints");
|
||||
}
|
||||
|
||||
void AllocTracer::stop() {
|
||||
if (_use_hook) {
|
||||
_use_hook = false;
|
||||
} else {
|
||||
_in_new_tlab.uninstall();
|
||||
_outside_tlab.uninstall();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2017 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ALLOCTRACER_H
|
||||
@@ -9,7 +20,6 @@
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include "engine.h"
|
||||
#include "event.h"
|
||||
#include "trap.h"
|
||||
|
||||
|
||||
@@ -18,19 +28,20 @@ class AllocTracer : public Engine {
|
||||
static int _trap_kind;
|
||||
static Trap _in_new_tlab;
|
||||
static Trap _outside_tlab;
|
||||
static volatile bool _use_hook;
|
||||
|
||||
static u64 _interval;
|
||||
static volatile u64 _allocated_bytes;
|
||||
|
||||
static Error initialize();
|
||||
static void recordAllocation(void* ucontext, EventType event_type, uintptr_t rklass,
|
||||
static void inNewTLAB1(uintptr_t klass, void* obj, size_t tlab_size, size_t alloc_size);
|
||||
static void outsideTLAB1(uintptr_t klass, void* obj, size_t alloc_size);
|
||||
static void inNewTLAB2(uintptr_t klass, size_t tlab_size, size_t alloc_size);
|
||||
static void outsideTLAB2(uintptr_t klass, size_t alloc_size);
|
||||
|
||||
static void recordAllocation(void* ucontext, int event_type, uintptr_t rklass,
|
||||
uintptr_t total_size, uintptr_t instance_size);
|
||||
|
||||
public:
|
||||
const char* type() {
|
||||
return "alloc_tracer";
|
||||
}
|
||||
|
||||
const char* title() {
|
||||
return "Allocation profile";
|
||||
}
|
||||
@@ -39,6 +50,7 @@ class AllocTracer : public Engine {
|
||||
return "bytes";
|
||||
}
|
||||
|
||||
Error check(Arguments& args);
|
||||
Error start(Arguments& args);
|
||||
void stop();
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package one.profiler;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
public class Agent {
|
||||
|
||||
public static void premain(String args) throws Exception {
|
||||
agentmain(args);
|
||||
}
|
||||
|
||||
public static void agentmain(String args) throws Exception {
|
||||
AsyncProfiler profiler = AsyncProfiler.getInstance();
|
||||
ManagementFactory.getPlatformMBeanServer().registerMBean(
|
||||
profiler,
|
||||
new ObjectName(AsyncProfilerMXBean.OBJECT_NAME));
|
||||
if (args != null && !args.isEmpty()) {
|
||||
profiler.execute(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2018 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package one.profiler;
|
||||
@@ -39,22 +50,16 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
|
||||
// No need to load library, if it has been preloaded with -agentpath
|
||||
profiler.getVersion();
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
String libraryPath = System.getProperty("one.profiler.libraryPath");
|
||||
if (libraryPath != null && !libraryPath.isEmpty()) {
|
||||
System.load(new File(libraryPath).getAbsolutePath());
|
||||
} else {
|
||||
File file = extractEmbeddedLib();
|
||||
if (file != null) {
|
||||
try {
|
||||
System.load(file.getAbsolutePath());
|
||||
} finally {
|
||||
file.delete();
|
||||
}
|
||||
} else {
|
||||
System.loadLibrary("asyncProfiler");
|
||||
File file = extractEmbeddedLib();
|
||||
if (file != null) {
|
||||
try {
|
||||
System.load(file.getPath());
|
||||
} finally {
|
||||
file.delete();
|
||||
}
|
||||
} else {
|
||||
System.loadLibrary("asyncProfiler");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +182,7 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
|
||||
|
||||
/**
|
||||
* Execute an agent-compatible profiling command -
|
||||
* the comma-separated list of arguments defined in arguments.cpp
|
||||
* the comma-separated list of arguments described in arguments.cpp
|
||||
*
|
||||
* @param command Profiling command
|
||||
* @return The command result
|
||||
@@ -201,7 +206,7 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
|
||||
@Override
|
||||
public String dumpCollapsed(Counter counter) {
|
||||
try {
|
||||
return execute0("collapsed," + (counter == Counter.SAMPLES ? "samples" : "total"));
|
||||
return execute0("collapsed," + counter.name().toLowerCase());
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
@@ -237,23 +242,6 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump collected data in OTLP format.
|
||||
* <p>
|
||||
* This API is UNSTABLE and might change or be removed in the next version of async-profiler.
|
||||
*
|
||||
* @param counter Which counter to use for aggregation
|
||||
* @return OTLP representation of the profile
|
||||
*/
|
||||
@Override
|
||||
public byte[] dumpOtlp(Counter counter) {
|
||||
try {
|
||||
return execute1("otlp," + (counter == Counter.SAMPLES ? "samples" : "total"));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given thread to the set of profiled threads.
|
||||
* 'filter' option must be enabled to use this method.
|
||||
@@ -294,7 +282,5 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
|
||||
|
||||
private native String execute0(String command) throws IllegalArgumentException, IllegalStateException, IOException;
|
||||
|
||||
private native byte[] execute1(String command) throws IllegalArgumentException, IllegalStateException, IOException;
|
||||
|
||||
private native void filterThread0(Thread thread, boolean enable);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2018 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package one.profiler;
|
||||
@@ -17,8 +28,6 @@ package one.profiler;
|
||||
* }</pre>
|
||||
*/
|
||||
public interface AsyncProfilerMXBean {
|
||||
String OBJECT_NAME = "one.profiler:type=AsyncProfiler";
|
||||
|
||||
void start(String event, long interval) throws IllegalStateException;
|
||||
void resume(String event, long interval) throws IllegalStateException;
|
||||
void stop() throws IllegalStateException;
|
||||
@@ -31,5 +40,4 @@ public interface AsyncProfilerMXBean {
|
||||
String dumpCollapsed(Counter counter);
|
||||
String dumpTraces(int maxTraces);
|
||||
String dumpFlat(int maxMethods);
|
||||
byte[] dumpOtlp(Counter counter);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2018 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package one.profiler;
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2018 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package one.profiler;
|
||||
@@ -13,6 +24,5 @@ public class Events {
|
||||
public static final String ALLOC = "alloc";
|
||||
public static final String LOCK = "lock";
|
||||
public static final String WALL = "wall";
|
||||
public static final String CTIMER = "ctimer";
|
||||
public static final String ITIMER = "itimer";
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Agent-Class: one.profiler.Agent
|
||||
Premain-Class: one.profiler.Agent
|
||||
133
src/arch.h
@@ -1,52 +1,45 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2017 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ARCH_H
|
||||
#define _ARCH_H
|
||||
|
||||
|
||||
#ifndef likely
|
||||
# define likely(x) (__builtin_expect(!!(x), 1))
|
||||
#endif
|
||||
|
||||
#ifndef unlikely
|
||||
# define unlikely(x) (__builtin_expect(!!(x), 0))
|
||||
#endif
|
||||
|
||||
#ifdef _LP64
|
||||
# define LP64_ONLY(code) code
|
||||
#else // !_LP64
|
||||
# define LP64_ONLY(code)
|
||||
#endif // _LP64
|
||||
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
template<typename T>
|
||||
static inline T atomicInc(T& var, T increment = 1) {
|
||||
return __atomic_fetch_add(&var, increment, __ATOMIC_ACQ_REL);
|
||||
static inline u64 atomicInc(volatile u64& var, u64 increment = 1) {
|
||||
return __sync_fetch_and_add(&var, increment);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline T atomicDec(T& var, T decrement = 1) {
|
||||
return __atomic_fetch_sub(&var, decrement, __ATOMIC_ACQ_REL);
|
||||
static inline int atomicInc(volatile int& var, int increment = 1) {
|
||||
return __sync_fetch_and_add(&var, increment);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline T loadAcquire(T& var) {
|
||||
static inline u64 loadAcquire(u64& var) {
|
||||
return __atomic_load_n(&var, __ATOMIC_ACQUIRE);
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
static inline void storeRelease(T& var, U value) {
|
||||
__atomic_store_n(&var, static_cast<T>(value), __ATOMIC_RELEASE);
|
||||
static inline void storeRelease(u64& var, u64 value) {
|
||||
return __atomic_store_n(&var, value, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
|
||||
typedef unsigned char instruction_t;
|
||||
@@ -55,6 +48,8 @@ const int BREAKPOINT_OFFSET = 0;
|
||||
|
||||
const int SYSCALL_SIZE = 2;
|
||||
const int FRAME_PC_SLOT = 1;
|
||||
const int ADJUST_RET = 1;
|
||||
const int PROBE_SP_LIMIT = 4;
|
||||
const int PLT_HEADER_SIZE = 16;
|
||||
const int PLT_ENTRY_SIZE = 16;
|
||||
const int PERF_REG_PC = 8; // PERF_REG_X86_IP
|
||||
@@ -63,10 +58,6 @@ const int PERF_REG_PC = 8; // PERF_REG_X86_IP
|
||||
#define rmb() asm volatile("lfence" : : : "memory")
|
||||
#define flushCache(addr) asm volatile("mfence; clflush (%0); mfence" : : "r" (addr) : "memory")
|
||||
|
||||
#define callerPC() __builtin_return_address(0)
|
||||
#define callerFP() __builtin_frame_address(1)
|
||||
#define callerSP() ((void**)__builtin_frame_address(0) + 2)
|
||||
|
||||
#elif defined(__arm__) || defined(__thumb__)
|
||||
|
||||
typedef unsigned int instruction_t;
|
||||
@@ -76,6 +67,8 @@ const int BREAKPOINT_OFFSET = 0;
|
||||
|
||||
const int SYSCALL_SIZE = sizeof(instruction_t);
|
||||
const int FRAME_PC_SLOT = 1;
|
||||
const int ADJUST_RET = 0;
|
||||
const int PROBE_SP_LIMIT = 0;
|
||||
const int PLT_HEADER_SIZE = 20;
|
||||
const int PLT_ENTRY_SIZE = 12;
|
||||
const int PERF_REG_PC = 15; // PERF_REG_ARM_PC
|
||||
@@ -84,10 +77,6 @@ const int PERF_REG_PC = 15; // PERF_REG_ARM_PC
|
||||
#define rmb() asm volatile("dmb ish" : : : "memory")
|
||||
#define flushCache(addr) __builtin___clear_cache((char*)(addr), (char*)(addr) + sizeof(instruction_t))
|
||||
|
||||
#define callerPC() __builtin_return_address(0)
|
||||
#define callerFP() __builtin_frame_address(1)
|
||||
#define callerSP() __builtin_frame_address(1)
|
||||
|
||||
#elif defined(__aarch64__)
|
||||
|
||||
typedef unsigned int instruction_t;
|
||||
@@ -96,6 +85,8 @@ const int BREAKPOINT_OFFSET = 0;
|
||||
|
||||
const int SYSCALL_SIZE = sizeof(instruction_t);
|
||||
const int FRAME_PC_SLOT = 1;
|
||||
const int ADJUST_RET = 0;
|
||||
const int PROBE_SP_LIMIT = 0;
|
||||
const int PLT_HEADER_SIZE = 32;
|
||||
const int PLT_ENTRY_SIZE = 16;
|
||||
const int PERF_REG_PC = 32; // PERF_REG_ARM64_PC
|
||||
@@ -104,10 +95,6 @@ const int PERF_REG_PC = 32; // PERF_REG_ARM64_PC
|
||||
#define rmb() asm volatile("dmb ish" : : : "memory")
|
||||
#define flushCache(addr) __builtin___clear_cache((char*)(addr), (char*)(addr) + sizeof(instruction_t))
|
||||
|
||||
#define callerPC() ({ void* pc; asm volatile("adr %0, ." : "=r"(pc)); pc; })
|
||||
#define callerFP() ({ void* fp; asm volatile("mov %0, fp" : "=r"(fp)); fp; })
|
||||
#define callerSP() ({ void* sp; asm volatile("mov %0, sp" : "=r"(sp)); sp; })
|
||||
|
||||
#elif defined(__PPC64__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
|
||||
typedef unsigned int instruction_t;
|
||||
@@ -118,6 +105,8 @@ const int BREAKPOINT_OFFSET = 8;
|
||||
|
||||
const int SYSCALL_SIZE = sizeof(instruction_t);
|
||||
const int FRAME_PC_SLOT = 2;
|
||||
const int ADJUST_RET = 0;
|
||||
const int PROBE_SP_LIMIT = 0;
|
||||
const int PLT_HEADER_SIZE = 24;
|
||||
const int PLT_ENTRY_SIZE = 24;
|
||||
const int PERF_REG_PC = 32; // PERF_REG_POWERPC_NIP
|
||||
@@ -126,54 +115,6 @@ const int PERF_REG_PC = 32; // PERF_REG_POWERPC_NIP
|
||||
#define rmb() asm volatile ("sync" : : : "memory") // lwsync would do but better safe than sorry
|
||||
#define flushCache(addr) __builtin___clear_cache((char*)(addr), (char*)(addr) + sizeof(instruction_t))
|
||||
|
||||
#define callerPC() __builtin_return_address(0)
|
||||
#define callerFP() __builtin_frame_address(1)
|
||||
#define callerSP() __builtin_frame_address(0)
|
||||
|
||||
#elif defined(__riscv) && (__riscv_xlen == 64)
|
||||
|
||||
typedef unsigned int instruction_t;
|
||||
#if defined(__riscv_compressed)
|
||||
const instruction_t BREAKPOINT = 0x9002; // EBREAK (compressed form)
|
||||
#else
|
||||
const instruction_t BREAKPOINT = 0x00100073; // EBREAK
|
||||
#endif
|
||||
const int BREAKPOINT_OFFSET = 0;
|
||||
|
||||
const int SYSCALL_SIZE = sizeof(instruction_t);
|
||||
const int FRAME_PC_SLOT = 1; // return address is at -1 from FP
|
||||
const int PLT_HEADER_SIZE = 24; // Best guess from examining readelf
|
||||
const int PLT_ENTRY_SIZE = 24; // ...same...
|
||||
const int PERF_REG_PC = 0; // PERF_REG_RISCV_PC
|
||||
|
||||
#define spinPause() // No architecture support
|
||||
#define rmb() asm volatile ("fence" : : : "memory")
|
||||
#define flushCache(addr) __builtin___clear_cache((char*)(addr), (char*)(addr) + sizeof(instruction_t))
|
||||
|
||||
#define callerPC() __builtin_return_address(0)
|
||||
#define callerFP() __builtin_frame_address(1)
|
||||
#define callerSP() __builtin_frame_address(0)
|
||||
|
||||
#elif defined(__loongarch_lp64)
|
||||
|
||||
typedef unsigned int instruction_t;
|
||||
const instruction_t BREAKPOINT = 0x002a0005; // EBREAK
|
||||
const int BREAKPOINT_OFFSET = 0;
|
||||
|
||||
const int SYSCALL_SIZE = sizeof(instruction_t);
|
||||
const int FRAME_PC_SLOT = 1;
|
||||
const int PLT_HEADER_SIZE = 32;
|
||||
const int PLT_ENTRY_SIZE = 16;
|
||||
const int PERF_REG_PC = 0; // PERF_REG_LOONGARCH_PC
|
||||
|
||||
#define spinPause() asm volatile("ibar 0x0")
|
||||
#define rmb() asm volatile("dbar 0x0" : : : "memory")
|
||||
#define flushCache(addr) __builtin___clear_cache((char*)(addr), (char*)(addr) + sizeof(instruction_t))
|
||||
|
||||
#define callerPC() __builtin_return_address(0)
|
||||
#define callerFP() __builtin_frame_address(1)
|
||||
#define callerSP() __builtin_frame_address(0)
|
||||
|
||||
#else
|
||||
|
||||
#error "Compiling on unsupported arch"
|
||||
@@ -181,20 +122,18 @@ const int PERF_REG_PC = 0; // PERF_REG_LOONGARCH_PC
|
||||
#endif
|
||||
|
||||
|
||||
// On Apple M1 and later processors, memory is either writable or executable (W^X)
|
||||
// Return address signing support.
|
||||
// Apple M1 has 47 bit virtual addresses.
|
||||
#if defined(__aarch64__) && defined(__APPLE__)
|
||||
# define WX_MEMORY true
|
||||
# define ADDRESS_BITS 47
|
||||
# define WX_MEMORY true
|
||||
#else
|
||||
# define WX_MEMORY false
|
||||
# define WX_MEMORY false
|
||||
#endif
|
||||
|
||||
// Pointer authentication (PAC) support.
|
||||
// Only 48-bit virtual addresses are currently supported.
|
||||
#ifdef __aarch64__
|
||||
const unsigned long PAC_MASK = WX_MEMORY ? 0x7fffffffffffUL : 0xffffffffffffUL;
|
||||
|
||||
#ifdef ADDRESS_BITS
|
||||
static inline const void* stripPointer(const void* p) {
|
||||
return (const void*) ((unsigned long)p & PAC_MASK);
|
||||
return (const void*) ((unsigned long)p & ((1UL << ADDRESS_BITS) - 1));
|
||||
}
|
||||
#else
|
||||
# define stripPointer(p) (p)
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2017 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
@@ -11,18 +22,20 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "arguments.h"
|
||||
#include "os.h"
|
||||
|
||||
|
||||
// Arguments of the last start/resume command; reused for shutdown and restart
|
||||
Arguments _global_args;
|
||||
|
||||
// Predefined value that denotes successful operation
|
||||
const Error Error::OK(NULL);
|
||||
|
||||
// Extra buffer space for expanding file pattern
|
||||
const size_t EXTRA_BUF_SIZE = 512;
|
||||
|
||||
static const Multiplier NANOS[] = {{'n', 1}, {'u', 1000}, {'m', 1000000}, {'s', 1000000000}, {0, 0}};
|
||||
static const Multiplier BYTES[] = {{'b', 1}, {'k', 1024}, {'m', 1048576}, {'g', 1073741824}, {0, 0}};
|
||||
static const Multiplier SECONDS[] = {{'s', 1}, {'m', 60}, {'h', 3600}, {'d', 86400}, {0, 0}};
|
||||
static const Multiplier UNIVERSAL[] = {{'n', 1}, {'u', 1000}, {'m', 1000000}, {'s', 1000000000}, {'b', 1}, {'k', 1024}, {'g', 1073741824}, {0, 0}};
|
||||
|
||||
|
||||
// Statically compute hash code of a string containing up to 12 [a-z] letters
|
||||
#define HASH(s) ((s[0] & 31LL) | (s[1] & 31LL) << 5 | (s[2] & 31LL) << 10 | (s[3] & 31LL) << 15 | \
|
||||
(s[4] & 31LL) << 20 | (s[5] & 31LL) << 25 | (s[6] & 31LL) << 30 | (s[7] & 31LL) << 35 | \
|
||||
@@ -37,7 +50,66 @@ const size_t EXTRA_BUF_SIZE = 512;
|
||||
|
||||
|
||||
// Parses agent arguments.
|
||||
// The format of the string is: arg[,arg...]
|
||||
// The format of the string is:
|
||||
// arg[,arg...]
|
||||
// where arg is one of the following options:
|
||||
// start - start profiling
|
||||
// resume - start or resume profiling without resetting collected data
|
||||
// stop - stop profiling
|
||||
// dump - dump collected data without stopping profiling session
|
||||
// check - check if the specified profiling event is available
|
||||
// status - print profiling status (inactive / running for X seconds)
|
||||
// meminfo - print profiler memory stats
|
||||
// list - show the list of available profiling events
|
||||
// version[=full] - display the agent version
|
||||
// event=EVENT - which event to trace (cpu, wall, cache-misses, etc.)
|
||||
// alloc[=BYTES] - profile allocations with BYTES interval
|
||||
// live - build allocation profile from live objects only
|
||||
// lock[=DURATION] - profile contended locks longer than DURATION ns
|
||||
// collapsed - dump collapsed stacks (the format used by FlameGraph script)
|
||||
// flamegraph - produce Flame Graph in HTML format
|
||||
// tree - produce call tree in HTML format
|
||||
// jfr - dump events in Java Flight Recorder format
|
||||
// jfrsync[=CONFIG] - start Java Flight Recording with the given config along with the profiler
|
||||
// traces[=N] - dump top N call traces
|
||||
// flat[=N] - dump top N methods (aka flat profile)
|
||||
// samples - count the number of samples (default)
|
||||
// total - count the total value (time, bytes, etc.) instead of samples
|
||||
// chunksize=N - approximate size of JFR chunk in bytes (default: 100 MB)
|
||||
// chunktime=N - duration of JFR chunk in seconds (default: 1 hour)
|
||||
// timeout=TIME - automatically stop profiler at TIME (absolute or relative)
|
||||
// loop=TIME - run profiler in a loop (continuous profiling)
|
||||
// interval=N - sampling interval in ns (default: 10'000'000, i.e. 10 ms)
|
||||
// jstackdepth=N - maximum Java stack depth (default: 2048)
|
||||
// safemode=BITS - disable stack recovery techniques (default: 0, i.e. everything enabled)
|
||||
// file=FILENAME - output file name for dumping
|
||||
// log=FILENAME - log warnings and errors to the given dedicated stream
|
||||
// loglevel=LEVEL - logging level: TRACE, DEBUG, INFO, WARN, ERROR, or NONE
|
||||
// server=ADDRESS - start insecure HTTP server at ADDRESS/PORT
|
||||
// filter=FILTER - thread filter
|
||||
// threads - profile different threads separately
|
||||
// sched - group threads by scheduling policy
|
||||
// cstack=MODE - how to collect C stack frames in addition to Java stack
|
||||
// MODE is 'fp' (Frame Pointer), 'dwarf', 'lbr' (Last Branch Record) or 'no'
|
||||
// allkernel - include only kernel-mode events
|
||||
// alluser - include only user-mode events
|
||||
// fdtransfer - use fdtransfer to pass fds to the profiler
|
||||
// simple - simple class names instead of FQN
|
||||
// dot - dotted class names
|
||||
// sig - print method signatures
|
||||
// ann - annotate Java methods
|
||||
// lib - prepend library names
|
||||
// mcache - max age of jmethodID cache (default: 0 = disabled)
|
||||
// include=PATTERN - include stack traces containing PATTERN
|
||||
// exclude=PATTERN - exclude stack traces containing PATTERN
|
||||
// begin=FUNCTION - begin profiling when FUNCTION is executed
|
||||
// end=FUNCTION - end profiling when FUNCTION is executed
|
||||
// title=TITLE - FlameGraph title
|
||||
// minwidth=PCT - FlameGraph minimum frame width in percent
|
||||
// reverse - generate stack-reversed FlameGraph / Call tree
|
||||
//
|
||||
// It is possible to specify multiple dump options at the same time
|
||||
|
||||
Error Arguments::parse(const char* args) {
|
||||
if (args == NULL) {
|
||||
return Error::OK;
|
||||
@@ -51,7 +123,7 @@ Error Arguments::parse(const char* args) {
|
||||
}
|
||||
char* args_copy = strcpy(_buf + EXTRA_BUF_SIZE, args);
|
||||
|
||||
const char* msg = NULL;
|
||||
const char* msg = NULL;
|
||||
|
||||
for (char* arg = strtok(args_copy, ","); arg != NULL; arg = strtok(NULL, ",")) {
|
||||
char* value = strchr(arg, '=');
|
||||
@@ -71,17 +143,20 @@ Error Arguments::parse(const char* args) {
|
||||
CASE("dump")
|
||||
_action = ACTION_DUMP;
|
||||
|
||||
CASE("check")
|
||||
_action = ACTION_CHECK;
|
||||
|
||||
CASE("status")
|
||||
_action = ACTION_STATUS;
|
||||
|
||||
CASE("metrics")
|
||||
_action = ACTION_METRICS;
|
||||
CASE("meminfo")
|
||||
_action = ACTION_MEMINFO;
|
||||
|
||||
CASE("list")
|
||||
_action = ACTION_LIST;
|
||||
|
||||
CASE("version")
|
||||
_action = ACTION_VERSION;
|
||||
_action = value == NULL ? ACTION_VERSION : ACTION_FULL_VERSION;
|
||||
|
||||
// Output formats
|
||||
CASE("collapsed")
|
||||
@@ -95,20 +170,13 @@ Error Arguments::parse(const char* args) {
|
||||
|
||||
CASE("jfr")
|
||||
_output = OUTPUT_JFR;
|
||||
|
||||
CASE("jfropts")
|
||||
_output = OUTPUT_JFR;
|
||||
if (value == NULL) {
|
||||
msg = "Invalid jfropts";
|
||||
} else if (value[0] >= '0' && value[0] <= '9') {
|
||||
if (value != NULL) {
|
||||
_jfr_options = (int)strtol(value, NULL, 0);
|
||||
} else if (strstr(value, "mem")) {
|
||||
_jfr_options |= IN_MEMORY;
|
||||
}
|
||||
|
||||
CASE("jfrsync")
|
||||
_output = OUTPUT_JFR;
|
||||
_jfr_options |= JFR_SYNC_OPTS;
|
||||
_jfr_options = JFR_SYNC_OPTS;
|
||||
_jfr_sync = value == NULL ? "default" : value;
|
||||
|
||||
CASE("traces")
|
||||
@@ -119,9 +187,6 @@ Error Arguments::parse(const char* args) {
|
||||
_output = OUTPUT_TEXT;
|
||||
_dump_flat = value == NULL ? INT_MAX : atoi(value);
|
||||
|
||||
CASE("otlp")
|
||||
_output = OUTPUT_OTLP;
|
||||
|
||||
CASE("samples")
|
||||
_counter = COUNTER_SAMPLES;
|
||||
|
||||
@@ -144,91 +209,30 @@ Error Arguments::parse(const char* args) {
|
||||
msg = "event must not be empty";
|
||||
} else if (strcmp(value, EVENT_ALLOC) == 0) {
|
||||
if (_alloc < 0) _alloc = 0;
|
||||
} else if (strcmp(value, EVENT_NATIVEMEM) == 0) {
|
||||
if (_nativemem < 0) _nativemem = 0;
|
||||
} else if (strcmp(value, EVENT_LOCK) == 0) {
|
||||
if (_lock < 0) _lock = DEFAULT_LOCK_INTERVAL;
|
||||
} else if (strcmp(value, EVENT_NATIVELOCK) == 0) {
|
||||
if (_nativelock < 0) _nativelock = DEFAULT_LOCK_INTERVAL;
|
||||
} else if (_event != NULL && !_all) {
|
||||
if (_lock < 0) _lock = 0;
|
||||
} else if (_event != NULL) {
|
||||
msg = "Duplicate event argument";
|
||||
} else {
|
||||
_event = value;
|
||||
}
|
||||
|
||||
CASE("timeout")
|
||||
if (value == NULL || (_timeout = parseTimeout(value)) == -1) {
|
||||
if (value == NULL || (_timeout = parseTimeout(value)) == -1 || !_persistent) {
|
||||
msg = "Invalid timeout";
|
||||
}
|
||||
|
||||
CASE("loop")
|
||||
if (value == NULL || (_loop = parseTimeout(value)) == -1) {
|
||||
_loop = true;
|
||||
if (value == NULL || (_timeout = parseTimeout(value)) == -1 || !_persistent) {
|
||||
msg = "Invalid loop duration";
|
||||
}
|
||||
|
||||
CASE("memlimit")
|
||||
_mem_limit = value == NULL ? 0 : parseUnits(value, BYTES);
|
||||
|
||||
CASE("alloc")
|
||||
_alloc = value == NULL ? 0 : parseUnits(value, BYTES);
|
||||
|
||||
CASE("tlab")
|
||||
_tlab = true;
|
||||
|
||||
CASE("nativemem")
|
||||
_nativemem = value == NULL ? 0 : parseUnits(value, BYTES);
|
||||
|
||||
CASE("nofree")
|
||||
_nofree = true;
|
||||
|
||||
CASE("trace")
|
||||
_trace.push_back(value);
|
||||
|
||||
CASE("lock")
|
||||
_lock = value == NULL ? DEFAULT_LOCK_INTERVAL : parseUnits(value, NANOS);
|
||||
|
||||
CASE("nativelock")
|
||||
_nativelock = value == NULL ? DEFAULT_LOCK_INTERVAL : parseUnits(value, NANOS);
|
||||
|
||||
CASE("wall")
|
||||
_wall = value == NULL ? 0 : parseUnits(value, NANOS);
|
||||
|
||||
CASE("proc")
|
||||
_proc = value == NULL ? DEFAULT_PROC_INTERVAL : parseUnits(value, SECONDS);
|
||||
|
||||
CASE("cpu")
|
||||
if (_event != NULL) {
|
||||
msg = "Duplicate event argument";
|
||||
} else {
|
||||
_event = EVENT_CPU;
|
||||
}
|
||||
|
||||
CASE("all")
|
||||
_all = true;
|
||||
_live = true;
|
||||
if (_wall < 0) {
|
||||
_wall = 0;
|
||||
}
|
||||
if (_alloc < 0) {
|
||||
_alloc = 0;
|
||||
}
|
||||
if (_lock < 0) {
|
||||
_lock = DEFAULT_LOCK_INTERVAL;
|
||||
}
|
||||
if (_nativelock < 0) {
|
||||
_nativelock = DEFAULT_LOCK_INTERVAL;
|
||||
}
|
||||
if (_nativemem < 0) {
|
||||
_nativemem = DEFAULT_ALLOC_INTERVAL;
|
||||
}
|
||||
|
||||
if (_proc < 0 && OS::isLinux()) {
|
||||
_proc = DEFAULT_PROC_INTERVAL;
|
||||
}
|
||||
|
||||
if (_event == NULL && OS::isLinux()) {
|
||||
_event = EVENT_CPU;
|
||||
}
|
||||
_lock = value == NULL ? 0 : parseUnits(value, NANOS);
|
||||
|
||||
CASE("interval")
|
||||
if (value == NULL || (_interval = parseUnits(value, UNIVERSAL)) <= 0) {
|
||||
@@ -238,29 +242,10 @@ Error Arguments::parse(const char* args) {
|
||||
CASE("jstackdepth")
|
||||
if (value == NULL || (_jstackdepth = atoi(value)) <= 0) {
|
||||
msg = "jstackdepth must be > 0";
|
||||
} else {
|
||||
char* slash = strchr(value, '/');
|
||||
_truncated_stack_depth = slash != NULL ? atoi(slash + 1) : _jstackdepth;
|
||||
}
|
||||
|
||||
CASE("signal")
|
||||
if (value == NULL || (_signal = atoi(value)) <= 0) {
|
||||
msg = "signal must be > 0";
|
||||
} else if ((value = strchr(value, '/')) != NULL) {
|
||||
// Two signals were specified: one for CPU profiling, another for wall clock
|
||||
_signal |= atoi(value + 1) << 8;
|
||||
}
|
||||
|
||||
CASE("features")
|
||||
if (value != NULL) {
|
||||
if (strstr(value, "stats")) _features.stats = 1;
|
||||
if (strstr(value, "jnienv")) _features.jnienv = 1;
|
||||
if (strstr(value, "agct")) _features.agct = 1;
|
||||
if (strstr(value, "mixed")) _features.mixed = 1;
|
||||
if (strstr(value, "vtable")) _features.vtable_target = 1;
|
||||
if (strstr(value, "comptask")) _features.comp_task = 1;
|
||||
if (strstr(value, "pcaddr")) _features.pc_addr = 1;
|
||||
}
|
||||
CASE("safemode")
|
||||
_safe_mode = value == NULL ? INT_MAX : (int)strtol(value, NULL, 0);
|
||||
|
||||
CASE("file")
|
||||
if (value == NULL || value[0] == 0) {
|
||||
@@ -277,9 +262,6 @@ Error Arguments::parse(const char* args) {
|
||||
}
|
||||
_loglevel = value;
|
||||
|
||||
CASE("quiet")
|
||||
_quiet = true;
|
||||
|
||||
CASE("server")
|
||||
if (value == NULL || value[0] == 0) {
|
||||
msg = "server address must not be empty";
|
||||
@@ -293,15 +275,42 @@ Error Arguments::parse(const char* args) {
|
||||
}
|
||||
_fdtransfer_path = value;
|
||||
|
||||
CASE("cloud")
|
||||
// Meta option for continuous eBPF-assisted cloud profiling
|
||||
if (_action == ACTION_NONE) {
|
||||
_action = ACTION_START;
|
||||
}
|
||||
if (_event == NULL) {
|
||||
_event = EVENT_BPF;
|
||||
_sched = true;
|
||||
_alloc_hook = true;
|
||||
}
|
||||
if (_fdtransfer_path == NULL) {
|
||||
_fdtransfer = true;
|
||||
_fdtransfer_path = "/one/profile/profile.sock";
|
||||
}
|
||||
if (_file == NULL) {
|
||||
_file = "/one/logs/%{cloud_image}-%t.jfr";
|
||||
}
|
||||
if (_timeout == 0) {
|
||||
_loop = true;
|
||||
_timeout = 0xff0000ff; // rotate at 00:00
|
||||
}
|
||||
if (_chunk_time == 0) {
|
||||
_chunk_time = 300; // 5 min
|
||||
}
|
||||
|
||||
// Filters
|
||||
CASE("filter")
|
||||
_filter = value == NULL ? "" : value;
|
||||
|
||||
CASE("include")
|
||||
_include.push_back(value);
|
||||
// Workaround -Wstringop-overflow warning
|
||||
if (value == arg + 8) appendToEmbeddedList(_include, arg + 8);
|
||||
|
||||
CASE("exclude")
|
||||
_exclude.push_back(value);
|
||||
// Workaround -Wstringop-overflow warning
|
||||
if (value == arg + 8) appendToEmbeddedList(_exclude, arg + 8);
|
||||
|
||||
CASE("threads")
|
||||
_threads = true;
|
||||
@@ -309,49 +318,31 @@ Error Arguments::parse(const char* args) {
|
||||
CASE("sched")
|
||||
_sched = true;
|
||||
|
||||
CASE("record-cpu")
|
||||
_record_cpu = true;
|
||||
|
||||
CASE("live")
|
||||
_live = true;
|
||||
|
||||
CASE("nobatch")
|
||||
_nobatch = true;
|
||||
CASE("allochook")
|
||||
_alloc_hook = true;
|
||||
|
||||
CASE("allkernel")
|
||||
_ring = RING_KERNEL;
|
||||
|
||||
CASE("alluser")
|
||||
_alluser = true;
|
||||
_ring = RING_USER;
|
||||
|
||||
CASE("cstack")
|
||||
if (value != NULL) {
|
||||
if (strcmp(value, "fp") == 0) {
|
||||
_cstack = CSTACK_FP;
|
||||
} else if (strcmp(value, "dwarf") == 0) {
|
||||
_cstack = CSTACK_DWARF;
|
||||
} else if (strcmp(value, "vm") == 0) {
|
||||
_cstack = CSTACK_VM;
|
||||
} else if (strcmp(value, "vmx") == 0) {
|
||||
// cstack=vmx is a shorthand for cstack=vm,features=mixed
|
||||
_cstack = CSTACK_VM;
|
||||
_features.mixed = 1;
|
||||
} else {
|
||||
if (value[0] == 'n') {
|
||||
_cstack = CSTACK_NO;
|
||||
} else if (value[0] == 'd') {
|
||||
_cstack = CSTACK_DWARF;
|
||||
} else if (value[0] == 'l') {
|
||||
_cstack = CSTACK_LBR;
|
||||
} else {
|
||||
_cstack = CSTACK_FP;
|
||||
}
|
||||
}
|
||||
|
||||
CASE("clock")
|
||||
if (value != NULL) {
|
||||
if (value[0] == 't') {
|
||||
_clock = CLK_TSC;
|
||||
} else if (value[0] == 'm') {
|
||||
_clock = CLK_MONOTONIC;
|
||||
}
|
||||
}
|
||||
|
||||
CASE("target-cpu")
|
||||
if (value == NULL || (_target_cpu = atoi(value)) < 0) {
|
||||
_target_cpu = -1;
|
||||
}
|
||||
|
||||
// Output style modifiers
|
||||
CASE("simple")
|
||||
_style |= STYLE_SIMPLE;
|
||||
@@ -359,9 +350,6 @@ Error Arguments::parse(const char* args) {
|
||||
CASE("dot")
|
||||
_style |= STYLE_DOTTED;
|
||||
|
||||
CASE("norm")
|
||||
_style |= STYLE_NORMALIZE;
|
||||
|
||||
CASE("sig")
|
||||
_style |= STYLE_SIGNATURES;
|
||||
|
||||
@@ -380,16 +368,6 @@ Error Arguments::parse(const char* args) {
|
||||
CASE("end")
|
||||
_end = value;
|
||||
|
||||
CASE("nostop")
|
||||
_nostop = true;
|
||||
|
||||
CASE("ttsp")
|
||||
if (_begin != NULL || _end != NULL) {
|
||||
msg = "begin and end must both be empty when ttsp is set";
|
||||
}
|
||||
_begin = "SafepointSynchronize::begin";
|
||||
_end = "RuntimeService::record_safepoint_synchronized";
|
||||
|
||||
// FlameGraph options
|
||||
CASE("title")
|
||||
_title = value;
|
||||
@@ -400,9 +378,6 @@ Error Arguments::parse(const char* args) {
|
||||
CASE("reverse")
|
||||
_reverse = true;
|
||||
|
||||
CASE("inverted")
|
||||
_inverted = true;
|
||||
|
||||
DEFAULT()
|
||||
if (_unknown_arg == NULL) _unknown_arg = arg;
|
||||
}
|
||||
@@ -413,7 +388,7 @@ Error Arguments::parse(const char* args) {
|
||||
return Error(msg);
|
||||
}
|
||||
|
||||
if (_event == NULL && _alloc < 0 && _lock < 0 && _wall < 0 && _nativemem < 0 && _nativelock < 0 && _trace.empty()) {
|
||||
if (_event == NULL && _alloc < 0 && _lock < 0) {
|
||||
_event = EVENT_CPU;
|
||||
}
|
||||
|
||||
@@ -440,9 +415,10 @@ const char* Arguments::file() {
|
||||
return _file;
|
||||
}
|
||||
|
||||
// Returns true if the log file is a temporary file of asprof launcher
|
||||
bool Arguments::hasTemporaryLog() const {
|
||||
return _log != NULL && strncmp(_log, "/tmp/asprof-log.", 16) == 0;
|
||||
// The linked list of string offsets is embedded right into _buf array
|
||||
void Arguments::appendToEmbeddedList(int& list, char* value) {
|
||||
((int*)value)[-1] = list;
|
||||
list = (int)(value - _buf);
|
||||
}
|
||||
|
||||
// Should match statically computed HASH(arg)
|
||||
@@ -567,10 +543,8 @@ Arguments::~Arguments() {
|
||||
if (!_shared) free(_buf);
|
||||
}
|
||||
|
||||
void Arguments::save() {
|
||||
if (this != &_global_args) {
|
||||
free(_global_args._buf);
|
||||
_global_args = *this;
|
||||
_shared = true;
|
||||
}
|
||||
void Arguments::save(Arguments& other) {
|
||||
if (!_shared) free(_buf);
|
||||
*this = other;
|
||||
other._shared = true;
|
||||
}
|
||||
|
||||
210
src/arguments.h
@@ -1,83 +1,86 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2017 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ARGUMENTS_H
|
||||
#define _ARGUMENTS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
const long DEFAULT_INTERVAL = 10000000; // 10 ms
|
||||
const long DEFAULT_ALLOC_INTERVAL = 524287; // 512 KiB
|
||||
const long DEFAULT_LOCK_INTERVAL = 10000; // 10 us
|
||||
const long DEFAULT_PROC_INTERVAL = 30; // 30 seconds
|
||||
const int DEFAULT_JSTACKDEPTH = 2048;
|
||||
|
||||
const char* const EVENT_CPU = "cpu";
|
||||
const char* const EVENT_ALLOC = "alloc";
|
||||
const char* const EVENT_NATIVEMEM = "nativemem";
|
||||
const char* const EVENT_LOCK = "lock";
|
||||
const char* const EVENT_NATIVELOCK = "nativelock";
|
||||
const char* const EVENT_WALL = "wall";
|
||||
const char* const EVENT_CTIMER = "ctimer";
|
||||
const char* const EVENT_ITIMER = "itimer";
|
||||
const char* const EVENT_CPU = "cpu";
|
||||
const char* const EVENT_BPF = "bpf";
|
||||
const char* const EVENT_ALLOC = "alloc";
|
||||
const char* const EVENT_LOCK = "lock";
|
||||
const char* const EVENT_WALL = "wall";
|
||||
const char* const EVENT_ITIMER = "itimer";
|
||||
|
||||
#define SHORT_ENUM __attribute__((__packed__))
|
||||
|
||||
enum SHORT_ENUM Action {
|
||||
enum Action {
|
||||
ACTION_NONE,
|
||||
ACTION_START,
|
||||
ACTION_RESUME,
|
||||
ACTION_STOP,
|
||||
ACTION_DUMP,
|
||||
ACTION_CHECK,
|
||||
ACTION_STATUS,
|
||||
ACTION_METRICS,
|
||||
ACTION_MEMINFO,
|
||||
ACTION_LIST,
|
||||
ACTION_VERSION
|
||||
ACTION_VERSION,
|
||||
ACTION_FULL_VERSION
|
||||
};
|
||||
|
||||
enum SHORT_ENUM Counter {
|
||||
enum Counter {
|
||||
COUNTER_SAMPLES,
|
||||
COUNTER_TOTAL
|
||||
};
|
||||
|
||||
enum Ring {
|
||||
RING_ANY,
|
||||
RING_KERNEL,
|
||||
RING_USER
|
||||
};
|
||||
|
||||
enum Style {
|
||||
STYLE_SIMPLE = 0x1,
|
||||
STYLE_DOTTED = 0x2,
|
||||
STYLE_NORMALIZE = 0x4,
|
||||
STYLE_SIGNATURES = 0x8,
|
||||
STYLE_ANNOTATE = 0x10,
|
||||
STYLE_LIB_NAMES = 0x20,
|
||||
STYLE_NO_SEMICOLON = 0x40
|
||||
STYLE_SIMPLE = 1,
|
||||
STYLE_DOTTED = 2,
|
||||
STYLE_SIGNATURES = 4,
|
||||
STYLE_ANNOTATE = 8,
|
||||
STYLE_LIB_NAMES = 16,
|
||||
STYLE_NO_SEMICOLON = 32
|
||||
};
|
||||
|
||||
// Whenever enum changes, update SETTING_CSTACK in FlightRecorder
|
||||
enum SHORT_ENUM CStack {
|
||||
CSTACK_DEFAULT, // use perf_event_open stack if available or Frame Pointer links otherwise
|
||||
CSTACK_NO, // do not collect native frames
|
||||
CSTACK_FP, // walk stack using Frame Pointer links
|
||||
CSTACK_DWARF, // use DWARF unwinding info from .eh_frame section
|
||||
CSTACK_VM // unwind using HotSpot VMStructs
|
||||
enum CStack {
|
||||
CSTACK_DEFAULT,
|
||||
CSTACK_NO,
|
||||
CSTACK_FP,
|
||||
CSTACK_DWARF,
|
||||
CSTACK_LBR
|
||||
};
|
||||
|
||||
enum SHORT_ENUM Clock {
|
||||
CLK_DEFAULT,
|
||||
CLK_TSC,
|
||||
CLK_MONOTONIC
|
||||
};
|
||||
|
||||
enum SHORT_ENUM Output {
|
||||
enum Output {
|
||||
OUTPUT_NONE,
|
||||
OUTPUT_TEXT,
|
||||
OUTPUT_SVG, // obsolete
|
||||
OUTPUT_COLLAPSED,
|
||||
OUTPUT_FLAMEGRAPH,
|
||||
OUTPUT_TREE,
|
||||
OUTPUT_JFR,
|
||||
OUTPUT_OTLP
|
||||
OUTPUT_JFR
|
||||
};
|
||||
|
||||
enum JfrOption {
|
||||
@@ -85,34 +88,8 @@ enum JfrOption {
|
||||
NO_SYSTEM_PROPS = 0x2,
|
||||
NO_NATIVE_LIBS = 0x4,
|
||||
NO_CPU_LOAD = 0x8,
|
||||
NO_HEAP_SUMMARY = 0x10,
|
||||
|
||||
IN_MEMORY = 0x100,
|
||||
|
||||
JFR_SYNC_OPTS = NO_SYSTEM_INFO | NO_SYSTEM_PROPS | NO_NATIVE_LIBS | NO_CPU_LOAD | NO_HEAP_SUMMARY
|
||||
};
|
||||
|
||||
// Keep this in sync with JfrSync.java
|
||||
enum EventMask {
|
||||
EM_CPU = 1,
|
||||
EM_ALLOC = 2,
|
||||
EM_LOCK = 4,
|
||||
EM_WALL = 8,
|
||||
EM_NATIVEMEM = 16,
|
||||
EM_NATIVELOCK = 32,
|
||||
EM_METHOD_TRACE = 64
|
||||
};
|
||||
constexpr int EVENT_MASK_SIZE = 7;
|
||||
|
||||
struct StackWalkFeatures {
|
||||
unsigned short stats : 1; // collect stack walking duration statistics
|
||||
unsigned short jnienv : 1; // verify JNIEnv* obtained using VMStructs
|
||||
unsigned short agct : 1; // force usage of AsyncGetCallTrace instead of VMStructs
|
||||
unsigned short mixed : 1; // mixed stack traces with Java and native frames interleaved
|
||||
unsigned short vtable_target : 1; // show receiver classes of vtable/itable stubs
|
||||
unsigned short comp_task : 1; // display current compilation task for JIT threads
|
||||
unsigned short pc_addr : 1; // record exact PC address for each sample
|
||||
unsigned short _padding : 9; // pad structure to 16 bits
|
||||
JFR_SYNC_OPTS = NO_SYSTEM_INFO | NO_SYSTEM_PROPS | NO_NATIVE_LIBS | NO_CPU_LOAD
|
||||
};
|
||||
|
||||
|
||||
@@ -121,10 +98,6 @@ struct Multiplier {
|
||||
long multiplier;
|
||||
};
|
||||
|
||||
constexpr Multiplier NANOS[] = {{'n', 1}, {'u', 1000}, {'m', 1000000}, {'s', 1000000000}, {0, 0}};
|
||||
constexpr Multiplier BYTES[] = {{'b', 1}, {'k', 1024}, {'m', 1048576}, {'g', 1073741824}, {0, 0}};
|
||||
constexpr Multiplier SECONDS[] = {{'s', 1}, {'m', 60}, {'h', 3600}, {'d', 86400}, {0, 0}};
|
||||
constexpr Multiplier UNIVERSAL[] = {{'n', 1}, {'u', 1000}, {'m', 1000000}, {'s', 1000000000}, {'b', 1}, {'k', 1024}, {'g', 1073741824}, {0, 0}};
|
||||
|
||||
class Error {
|
||||
private:
|
||||
@@ -150,59 +123,45 @@ class Arguments {
|
||||
private:
|
||||
char* _buf;
|
||||
bool _shared;
|
||||
bool _persistent;
|
||||
|
||||
void appendToEmbeddedList(int& list, char* value);
|
||||
const char* expandFilePattern(const char* pattern);
|
||||
|
||||
static long long hash(const char* arg);
|
||||
static Output detectOutputFormat(const char* file);
|
||||
static long parseUnits(const char* str, const Multiplier* multipliers);
|
||||
static int parseTimeout(const char* str);
|
||||
|
||||
public:
|
||||
Action _action;
|
||||
Counter _counter;
|
||||
Ring _ring;
|
||||
const char* _event;
|
||||
std::vector<const char*> _trace;
|
||||
int _timeout;
|
||||
int _loop;
|
||||
size_t _mem_limit;
|
||||
long _interval;
|
||||
long _alloc;
|
||||
long _nativemem;
|
||||
long _lock;
|
||||
long _nativelock;
|
||||
long _wall;
|
||||
long _proc;
|
||||
bool _all;
|
||||
int _jstackdepth;
|
||||
int _truncated_stack_depth;
|
||||
int _signal;
|
||||
int _jstackdepth;
|
||||
int _safe_mode;
|
||||
const char* _file;
|
||||
const char* _log;
|
||||
const char* _loglevel;
|
||||
const char* _unknown_arg;
|
||||
const char* _server;
|
||||
const char* _filter;
|
||||
std::vector<const char*> _include;
|
||||
std::vector<const char*> _exclude;
|
||||
int _include;
|
||||
int _exclude;
|
||||
unsigned char _mcache;
|
||||
bool _preloaded;
|
||||
bool _quiet;
|
||||
bool _loop;
|
||||
bool _threads;
|
||||
bool _sched;
|
||||
bool _record_cpu;
|
||||
bool _tlab;
|
||||
bool _live;
|
||||
bool _nofree;
|
||||
bool _nobatch;
|
||||
bool _nostop;
|
||||
bool _alluser;
|
||||
bool _alloc_hook;
|
||||
bool _fdtransfer;
|
||||
const char* _fdtransfer_path;
|
||||
int _target_cpu;
|
||||
int _style;
|
||||
StackWalkFeatures _features;
|
||||
CStack _cstack;
|
||||
Clock _clock;
|
||||
Output _output;
|
||||
long _chunk_size;
|
||||
long _chunk_time;
|
||||
@@ -217,59 +176,42 @@ class Arguments {
|
||||
const char* _title;
|
||||
double _minwidth;
|
||||
bool _reverse;
|
||||
bool _inverted;
|
||||
|
||||
Arguments() :
|
||||
Arguments(bool persistent = false) :
|
||||
_buf(NULL),
|
||||
_shared(false),
|
||||
_persistent(persistent),
|
||||
_action(ACTION_NONE),
|
||||
_counter(COUNTER_SAMPLES),
|
||||
_ring(RING_ANY),
|
||||
_event(NULL),
|
||||
_trace(),
|
||||
_timeout(0),
|
||||
_loop(0),
|
||||
_mem_limit(0),
|
||||
_interval(0),
|
||||
_alloc(-1),
|
||||
_nativemem(-1),
|
||||
_lock(-1),
|
||||
_nativelock(-1),
|
||||
_wall(-1),
|
||||
_proc(-1),
|
||||
_all(false),
|
||||
_jstackdepth(DEFAULT_JSTACKDEPTH),
|
||||
_truncated_stack_depth(DEFAULT_JSTACKDEPTH),
|
||||
_signal(0),
|
||||
_safe_mode(0),
|
||||
_file(NULL),
|
||||
_log(NULL),
|
||||
_loglevel(NULL),
|
||||
_unknown_arg(NULL),
|
||||
_server(NULL),
|
||||
_filter(NULL),
|
||||
_include(),
|
||||
_exclude(),
|
||||
_include(0),
|
||||
_exclude(0),
|
||||
_mcache(0),
|
||||
_preloaded(false),
|
||||
_quiet(false),
|
||||
_loop(false),
|
||||
_threads(false),
|
||||
_sched(false),
|
||||
_record_cpu(false),
|
||||
_tlab(false),
|
||||
_live(false),
|
||||
_nofree(false),
|
||||
_nobatch(false),
|
||||
_nostop(false),
|
||||
_alluser(false),
|
||||
_alloc_hook(false),
|
||||
_fdtransfer(false),
|
||||
_fdtransfer_path(NULL),
|
||||
_target_cpu(-1),
|
||||
_style(0),
|
||||
_features{},
|
||||
_cstack(CSTACK_DEFAULT),
|
||||
_clock(CLK_DEFAULT),
|
||||
_output(OUTPUT_NONE),
|
||||
_chunk_size(100 * 1024 * 1024),
|
||||
_chunk_time(3600),
|
||||
_chunk_time(0),
|
||||
_jfr_sync(NULL),
|
||||
_jfr_options(0),
|
||||
_dump_traces(0),
|
||||
@@ -279,20 +221,17 @@ class Arguments {
|
||||
_end(NULL),
|
||||
_title(NULL),
|
||||
_minwidth(0),
|
||||
_reverse(false),
|
||||
_inverted(false) {
|
||||
_reverse(false) {
|
||||
}
|
||||
|
||||
~Arguments();
|
||||
|
||||
void save();
|
||||
void save(Arguments& other);
|
||||
|
||||
Error parse(const char* args);
|
||||
|
||||
const char* file();
|
||||
|
||||
bool hasTemporaryLog() const;
|
||||
|
||||
bool hasOutputFile() const {
|
||||
return _file != NULL &&
|
||||
(_action == ACTION_STOP || _action == ACTION_DUMP ? _output != OUTPUT_JFR : _action >= ACTION_STATUS);
|
||||
@@ -302,19 +241,8 @@ class Arguments {
|
||||
return (_jfr_options & option) != 0;
|
||||
}
|
||||
|
||||
int eventMask() const {
|
||||
return (_event != NULL ? EM_CPU : 0) |
|
||||
(_alloc >= 0 ? EM_ALLOC : 0) |
|
||||
(_lock >= 0 ? EM_LOCK : 0) |
|
||||
(_wall >= 0 ? EM_WALL : 0) |
|
||||
(_nativemem >= 0 ? EM_NATIVEMEM : 0) |
|
||||
(_nativelock >= 0 ? EM_NATIVELOCK : 0) |
|
||||
(!_trace.empty() ? EM_METHOD_TRACE : 0);
|
||||
}
|
||||
|
||||
static long parseUnits(const char* str, const Multiplier* multipliers);
|
||||
friend class FrameName;
|
||||
friend class Recording;
|
||||
};
|
||||
|
||||
extern Arguments _global_args;
|
||||
|
||||
#endif // _ARGUMENTS_H
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "asprof.h"
|
||||
#include "hooks.h"
|
||||
#include "profiler.h"
|
||||
#include "tsc.h"
|
||||
#include "threadLocalData.h"
|
||||
#include "userEvents.h"
|
||||
|
||||
static asprof_error_t asprof_error(const char* msg) {
|
||||
return (asprof_error_t)msg;
|
||||
}
|
||||
|
||||
|
||||
DLLEXPORT void asprof_init() {
|
||||
Hooks::init(true);
|
||||
}
|
||||
|
||||
DLLEXPORT const char* asprof_error_str(asprof_error_t err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
DLLEXPORT asprof_error_t asprof_execute(const char* command, asprof_writer_t output_callback) {
|
||||
Arguments args;
|
||||
Error error = args.parse(command);
|
||||
if (error) {
|
||||
return asprof_error(error.message());
|
||||
}
|
||||
|
||||
Log::open(args);
|
||||
|
||||
if (!args.hasOutputFile()) {
|
||||
CallbackWriter out(output_callback);
|
||||
error = Profiler::instance()->runInternal(args, out);
|
||||
if (!error) {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
FileWriter out(args.file());
|
||||
if (!out.is_open()) {
|
||||
return asprof_error("Could not open output file");
|
||||
}
|
||||
error = Profiler::instance()->runInternal(args, out);
|
||||
if (!error) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return asprof_error(error.message());
|
||||
}
|
||||
|
||||
DLLEXPORT asprof_thread_local_data* asprof_get_thread_local_data(void) {
|
||||
return ThreadLocalData::getThreadLocalData();
|
||||
}
|
||||
|
||||
DLLEXPORT asprof_jfr_event_key asprof_register_jfr_event(const char* name) {
|
||||
return UserEvents::registerEvent(name);
|
||||
}
|
||||
|
||||
#define asprof_str(s) #s
|
||||
|
||||
DLLEXPORT asprof_error_t asprof_emit_jfr_event(asprof_jfr_event_key type, const uint8_t* data, size_t len) {
|
||||
if (len > ASPROF_MAX_JFR_EVENT_LENGTH) {
|
||||
return asprof_error("Unable to emit JFR event larger than " asprof_str(ASPROF_MAX_JFR_EVENT_LENGTH) " bytes");
|
||||
}
|
||||
|
||||
UserEvent event;
|
||||
event._start_time = TSC::ticks();
|
||||
event._type = type;
|
||||
event._data = data;
|
||||
event._len = len;
|
||||
Profiler::instance()->recordEventOnly(USER_EVENT, &event);
|
||||
return NULL;
|
||||
}
|
||||
106
src/asprof.h
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ASPROF_H
|
||||
#define _ASPROF_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __clang__
|
||||
# define DLLEXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
# define DLLEXPORT __attribute__((visibility("default"),externally_visible))
|
||||
#endif
|
||||
|
||||
#define WEAK __attribute__((weak))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef const char* asprof_error_t;
|
||||
typedef void (*asprof_writer_t)(const char* buf, size_t size);
|
||||
|
||||
// Should be called once prior to any other API functions
|
||||
DLLEXPORT void asprof_init();
|
||||
typedef void (*asprof_init_t)();
|
||||
|
||||
// Returns an error message for the given error code or NULL if there is no error
|
||||
DLLEXPORT const char* asprof_error_str(asprof_error_t err);
|
||||
typedef const char* (*asprof_error_str_t)(asprof_error_t err);
|
||||
|
||||
// Executes async-profiler command using output_callback as an optional sink
|
||||
// for the profiler output. Returning an error code or NULL on success.
|
||||
DLLEXPORT asprof_error_t asprof_execute(const char* command, asprof_writer_t output_callback);
|
||||
typedef asprof_error_t (*asprof_execute_t)(const char* command, asprof_writer_t output_callback);
|
||||
|
||||
// This API is UNSTABLE and might change or be removed in the next version of async-profiler.
|
||||
typedef struct {
|
||||
// A thread-local sample counter, which increments (not necessarily by 1) every time a
|
||||
// stack profiling sample is taken using a profiling signal.
|
||||
//
|
||||
// The counter might be initialized lazily, only starting counting from 0 the first time
|
||||
// `asprof_get_thread_local_data` is called on a given thread. Further calls to
|
||||
// `asprof_get_thread_local_data` on a given thread will of course not reset the counter.
|
||||
volatile uint64_t sample_counter;
|
||||
} asprof_thread_local_data;
|
||||
|
||||
// This API is UNSTABLE and might change or be removed in the next version of async-profiler.
|
||||
//
|
||||
// Gets a pointer to asprof's thread-local data structure, see `asprof_thread_local_data`'s
|
||||
// documentation for the details of each field. This function might lazily initialize that
|
||||
// structure.
|
||||
//
|
||||
// This function can return NULL either if the profiler is not yet initializer, or in
|
||||
// case of an allocation failure.
|
||||
//
|
||||
// This function is *not* async-signal-safe. However, it is safe to call concurrently
|
||||
// with async-profiler operations, including initialization.
|
||||
DLLEXPORT asprof_thread_local_data* asprof_get_thread_local_data(void);
|
||||
typedef asprof_thread_local_data* (*asprof_get_thread_local_data_t)(void);
|
||||
|
||||
|
||||
typedef int asprof_jfr_event_key;
|
||||
|
||||
// This API is UNSTABLE and might change or be removed in the next version of async-profiler.
|
||||
//
|
||||
// Return a asprof_jfr_event_key identifier for a user-defined JFR key.
|
||||
// That identifier can then be used in `asprof_emit_jfr_event`
|
||||
//
|
||||
// The name is required to be valid (since it's a C string, NUL-free) UTF-8.
|
||||
//
|
||||
// Returns -1 on failure.
|
||||
DLLEXPORT asprof_jfr_event_key asprof_register_jfr_event(const char* name);
|
||||
typedef asprof_jfr_event_key (*asprof_register_jfr_event_t)(const char* name);
|
||||
|
||||
|
||||
#define ASPROF_MAX_JFR_EVENT_LENGTH 2048
|
||||
|
||||
// This API is UNSTABLE and might change or be removed in the next version of async-profiler.
|
||||
//
|
||||
// Emits a custom, user-defined JFR event. The key should be created via `asprof_register_jfr_event`.
|
||||
// The data can be arbitrary binary data, with size <= ASPROF_MAX_JFR_EVENT_LENGTH.
|
||||
//
|
||||
// User-defined events are included in the JFR under a `profiler.UserEvent` event type. That type will contain
|
||||
// (at least) the following fields:
|
||||
// 1. `startTime` [Long] - the emitted event's time in ticks.
|
||||
// 2. `eventThread` [java.lang.Thread] - the thread that emitted the events.
|
||||
// 3. `type` [profiler.types.UserEventType] - the event's type,
|
||||
// where `profiler.types.UserEventType` is an indexed string from the JFR constant pool.
|
||||
// 4. `data` [String] - the event data. This is the Latin-1 encoded version of the inputted data.
|
||||
// The Latin-1 encoding is used as a way to stuff the arbitrary byte input into something
|
||||
// that JFR supports (JFR technically supports byte arrays, but `jfr print` doesn't).
|
||||
//
|
||||
// Returns an error code or NULL on success.
|
||||
DLLEXPORT asprof_error_t asprof_emit_jfr_event(asprof_jfr_event_key type, const uint8_t* data, size_t len);
|
||||
typedef asprof_error_t (*asprof_emit_jfr_event_t)(asprof_jfr_event_key type, const uint8_t* data, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _ASPROF_H
|
||||
138
src/bpfClient.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright 2021 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include "bpfClient.h"
|
||||
#include "fdtransferClient.h"
|
||||
#include "os.h"
|
||||
#include "profiler.h"
|
||||
#include "stackWalker.h"
|
||||
#include "vmStructs.h"
|
||||
|
||||
|
||||
// Use different profiling signal to allow running two profilers together
|
||||
const int BPF_SIGNAL = SIGSTKFLT;
|
||||
|
||||
struct BpfStackTrace {
|
||||
u32 pid;
|
||||
u32 tid;
|
||||
u64 counter;
|
||||
u16 event_type;
|
||||
u16 sched_policy;
|
||||
u32 depth;
|
||||
u64 ip[0];
|
||||
};
|
||||
|
||||
struct BpfMap {
|
||||
char* addr;
|
||||
size_t size;
|
||||
u32 salt;
|
||||
u32 mask;
|
||||
u32 entry_size;
|
||||
|
||||
BpfStackTrace* getStackForThread(u32 tid) const {
|
||||
char* base = __atomic_load_n(&addr, __ATOMIC_ACQUIRE);
|
||||
if (base == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
size_t index = (salt + tid) & mask;
|
||||
return (BpfStackTrace*)(base + index * entry_size);
|
||||
}
|
||||
};
|
||||
|
||||
static BpfMap _bpf_map = {0};
|
||||
|
||||
static unsigned int _interval;
|
||||
static unsigned int _counter;
|
||||
|
||||
|
||||
void BpfClient::signalHandler(int signo, siginfo_t* siginfo, void* ucontext) {
|
||||
if (!_enabled) return;
|
||||
|
||||
if (_interval <= 1 || __sync_add_and_fetch(&_counter, 1) % _interval == 0) {
|
||||
ExecutionEvent event;
|
||||
Profiler::instance()->recordSample(ucontext, _interval, 0, &event);
|
||||
}
|
||||
}
|
||||
|
||||
Error BpfClient::check(Arguments& args) {
|
||||
return Error::OK;
|
||||
}
|
||||
|
||||
Error BpfClient::start(Arguments& args) {
|
||||
OS::installSignalHandler(BPF_SIGNAL, signalHandler);
|
||||
|
||||
struct bpfmap_params params;
|
||||
int fd = FdTransferClient::requestBpfMapFd(¶ms);
|
||||
if (fd < 0) {
|
||||
return Error("Failed to request bpf map");
|
||||
}
|
||||
|
||||
_interval = args._interval;
|
||||
_counter = 0;
|
||||
|
||||
_bpf_map.salt = params.salt;
|
||||
_bpf_map.mask = params.num_entries - 1;
|
||||
_bpf_map.entry_size = params.entry_size;
|
||||
_bpf_map.size = (size_t)params.entry_size * params.num_entries;
|
||||
|
||||
char* addr = (char*)mmap(NULL, _bpf_map.size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
close(fd);
|
||||
return Error("Failed to mmap stack trace buffer");
|
||||
}
|
||||
|
||||
close(fd);
|
||||
__atomic_store_n(&_bpf_map.addr, addr, __ATOMIC_RELEASE);
|
||||
|
||||
return Error::OK;
|
||||
}
|
||||
|
||||
void BpfClient::stop() {
|
||||
OS::installSignalHandler(BPF_SIGNAL, NULL, SIG_IGN);
|
||||
|
||||
char* addr = __atomic_exchange_n(&_bpf_map.addr, NULL, __ATOMIC_ACQ_REL);
|
||||
munmap(addr, _bpf_map.size);
|
||||
}
|
||||
|
||||
int BpfClient::walk(int tid, void* ucontext, const void** callchain, int max_depth, StackContext* java_ctx) {
|
||||
int depth = 0;
|
||||
|
||||
// Fill kernel frames from bpf map
|
||||
BpfStackTrace* trace = _bpf_map.getStackForThread(tid);
|
||||
if (trace != NULL && trace->tid == tid) {
|
||||
int limit = trace->depth < max_depth ? trace->depth : max_depth;
|
||||
while (depth < limit && (intptr_t)trace->ip[depth] < 0) {
|
||||
callchain[depth] = (const void*)trace->ip[depth];
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
|
||||
// Add user-space frames by manual stack walking
|
||||
depth += StackWalker::walkDwarf(ucontext, callchain + depth, max_depth - depth, java_ctx);
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
const char* BpfClient::schedPolicy(int tid) {
|
||||
BpfStackTrace* trace = _bpf_map.getStackForThread(tid);
|
||||
if (trace == NULL || trace->tid != tid || trace->sched_policy < SCHED_BATCH) {
|
||||
return "SCHED_OTHER";
|
||||
}
|
||||
return trace->sched_policy >= SCHED_IDLE ? "SCHED_IDLE" : "SCHED_BATCH";
|
||||
}
|
||||
47
src/bpfClient.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2021 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BPFCLIENT_H
|
||||
#define _BPFCLIENT_H
|
||||
|
||||
#include <signal.h>
|
||||
#include "engine.h"
|
||||
|
||||
|
||||
class BpfClient : public Engine {
|
||||
private:
|
||||
|
||||
static void signalHandler(int signo, siginfo_t* siginfo, void* ucontext);
|
||||
|
||||
public:
|
||||
const char* title() {
|
||||
return "CPU profile";
|
||||
}
|
||||
|
||||
const char* units() {
|
||||
return "cycles";
|
||||
}
|
||||
|
||||
Error check(Arguments& args);
|
||||
Error start(Arguments& args);
|
||||
void stop();
|
||||
|
||||
static int walk(int tid, void* ucontext, const void** callchain, int max_depth, StackContext* java_ctx);
|
||||
|
||||
static const char* schedPolicy(int tid);
|
||||
};
|
||||
|
||||
#endif // _BPFCLIENT_H
|
||||
@@ -1,41 +1,49 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2020 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "callTraceStorage.h"
|
||||
#include "os.h"
|
||||
|
||||
#define COMMA ,
|
||||
|
||||
static const u32 INITIAL_CAPACITY = 65536;
|
||||
static const u32 CAPACITY = 131072;
|
||||
static const u32 CALL_TRACE_CHUNK = 8 * 1024 * 1024;
|
||||
static const u32 OVERFLOW_TRACE_ID = 0x7fffffff;
|
||||
static const size_t MEM_LIMIT_EXTRA = 0x10000; // reserve up to 64 KB for LongHashTable headers
|
||||
|
||||
|
||||
class LongHashTable {
|
||||
private:
|
||||
LongHashTable* _prev;
|
||||
void* _padding0;
|
||||
u32 _capacity;
|
||||
u32 _base;
|
||||
u32 _padding1[15];
|
||||
volatile u32 _size;
|
||||
u32 _padding2[15];
|
||||
|
||||
static size_t getSize(u32 capacity) {
|
||||
size_t size = sizeof(LongHashTable) + (sizeof(u64) + sizeof(CallTraceSample)) * capacity;
|
||||
static size_t getSize() {
|
||||
size_t size = sizeof(LongHashTable) + (sizeof(u64) + sizeof(CallTraceSample)) * CAPACITY;
|
||||
return (size + OS::page_mask) & ~OS::page_mask;
|
||||
}
|
||||
|
||||
public:
|
||||
static LongHashTable* allocate(LongHashTable* prev, u32 capacity) {
|
||||
LongHashTable* table = (LongHashTable*)OS::safeAlloc(getSize(capacity));
|
||||
static LongHashTable* allocate(LongHashTable* prev, u32 base) {
|
||||
LongHashTable* table = (LongHashTable*)OS::safeAlloc(getSize());
|
||||
if (table != NULL) {
|
||||
table->_prev = prev;
|
||||
table->_capacity = capacity;
|
||||
table->_base = base;
|
||||
table->_size = 0;
|
||||
}
|
||||
return table;
|
||||
@@ -43,23 +51,27 @@ class LongHashTable {
|
||||
|
||||
LongHashTable* destroy() {
|
||||
LongHashTable* prev = _prev;
|
||||
OS::safeFree(this, getSize(_capacity));
|
||||
OS::safeFree(this, getSize());
|
||||
return prev;
|
||||
}
|
||||
|
||||
size_t usedMemory() {
|
||||
return getSize(_capacity);
|
||||
size_t usedMemory() const {
|
||||
return getSize();
|
||||
}
|
||||
|
||||
LongHashTable* prev() {
|
||||
LongHashTable* trim() {
|
||||
return __atomic_exchange_n(&_prev, NULL, __ATOMIC_ACQ_REL);
|
||||
}
|
||||
|
||||
LongHashTable* prev() const {
|
||||
return _prev;
|
||||
}
|
||||
|
||||
u32 capacity() {
|
||||
return _capacity;
|
||||
u32 base() const {
|
||||
return _base;
|
||||
}
|
||||
|
||||
u32 size() {
|
||||
u32 size() const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
@@ -72,21 +84,20 @@ class LongHashTable {
|
||||
}
|
||||
|
||||
CallTraceSample* values() {
|
||||
return (CallTraceSample*)(keys() + _capacity);
|
||||
return (CallTraceSample*)(keys() + CAPACITY);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
memset(keys(), 0, (sizeof(u64) + sizeof(CallTraceSample)) * _capacity);
|
||||
memset(keys(), 0, (sizeof(u64) + sizeof(CallTraceSample)) * CAPACITY);
|
||||
_size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
CallTrace CallTraceStorage::_overflow_trace = {1, {BCI_ERROR, LP64_ONLY(0 COMMA) (jmethodID)"storage_overflow"}};
|
||||
|
||||
CallTrace CallTraceStorage::_overflow_trace = {1, {BCI_ERROR, (jmethodID)"storage_overflow"}};
|
||||
|
||||
CallTraceStorage::CallTraceStorage() : _allocator(CALL_TRACE_CHUNK) {
|
||||
_current_table = LongHashTable::allocate(NULL, INITIAL_CAPACITY);
|
||||
_used_memory = _current_table->usedMemory();
|
||||
_mem_limit = SIZE_MAX;
|
||||
_current_table = LongHashTable::allocate(NULL, 1);
|
||||
_overflow = 0;
|
||||
}
|
||||
|
||||
@@ -96,40 +107,51 @@ CallTraceStorage::~CallTraceStorage() {
|
||||
}
|
||||
}
|
||||
|
||||
void CallTraceStorage::clear(size_t mem_limit) {
|
||||
void CallTraceStorage::clear() {
|
||||
while (_current_table->prev() != NULL) {
|
||||
_current_table = _current_table->destroy();
|
||||
}
|
||||
_current_table->clear();
|
||||
_used_memory = _current_table->usedMemory();
|
||||
_allocator.clear();
|
||||
_mem_limit = mem_limit ? mem_limit | MEM_LIMIT_EXTRA : SIZE_MAX;
|
||||
_overflow = 0;
|
||||
}
|
||||
|
||||
u32 CallTraceStorage::capacity() {
|
||||
// As capacity of each subsequent table doubles,
|
||||
// total capacity is a sum of geometric series: 64K + 128K + 256K...
|
||||
return _current_table->capacity() * 2 - INITIAL_CAPACITY;
|
||||
size_t CallTraceStorage::usedMemory() {
|
||||
size_t bytes = _allocator.usedMemory();
|
||||
for (LongHashTable* table = _current_table; table != NULL; table = table->prev()) {
|
||||
bytes += table->usedMemory();
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
size_t CallTraceStorage::usedMemory() {
|
||||
return _used_memory + _allocator.usedMemory();
|
||||
Chunk* CallTraceStorage::trimAllocator() {
|
||||
return _allocator.trim();
|
||||
}
|
||||
|
||||
LongHashTable* CallTraceStorage::trimTable() {
|
||||
return _current_table->trim();
|
||||
}
|
||||
|
||||
void CallTraceStorage::freeMemory(Chunk* chunk, LongHashTable* table) {
|
||||
_allocator.freeChain(chunk);
|
||||
while (table != NULL) {
|
||||
table = table->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void CallTraceStorage::collectTraces(std::map<u32, CallTrace*>& map) {
|
||||
for (LongHashTable* table = _current_table; table != NULL; table = table->prev()) {
|
||||
u64* keys = table->keys();
|
||||
CallTraceSample* values = table->values();
|
||||
u32 capacity = table->capacity();
|
||||
u32 base = table->base();
|
||||
|
||||
for (u32 slot = 0; slot < capacity; slot++) {
|
||||
if (keys[slot] != 0 && loadAcquire(values[slot].samples) != 0) {
|
||||
// Reset samples to avoid duplication of call traces between JFR chunks
|
||||
values[slot].samples = 0;
|
||||
for (u32 slot = 0; slot < CAPACITY; slot++) {
|
||||
if (keys[slot] != 0 && loadAcquire(values[slot].counter) != 0) {
|
||||
CallTrace* trace = values[slot].acquireTrace();
|
||||
if (trace != NULL) {
|
||||
map[capacity - (INITIAL_CAPACITY - 1) + slot] = trace;
|
||||
map[base + slot] = trace;
|
||||
// Reset to make sure each trace is dumped only once
|
||||
values[slot].setTrace(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,9 +166,8 @@ void CallTraceStorage::collectSamples(std::vector<CallTraceSample*>& samples) {
|
||||
for (LongHashTable* table = _current_table; table != NULL; table = table->prev()) {
|
||||
u64* keys = table->keys();
|
||||
CallTraceSample* values = table->values();
|
||||
u32 capacity = table->capacity();
|
||||
|
||||
for (u32 slot = 0; slot < capacity; slot++) {
|
||||
for (u32 slot = 0; slot < CAPACITY; slot++) {
|
||||
if (keys[slot] != 0) {
|
||||
samples.push_back(&values[slot]);
|
||||
}
|
||||
@@ -158,9 +179,8 @@ void CallTraceStorage::collectSamples(std::map<u64, CallTraceSample>& map) {
|
||||
for (LongHashTable* table = _current_table; table != NULL; table = table->prev()) {
|
||||
u64* keys = table->keys();
|
||||
CallTraceSample* values = table->values();
|
||||
u32 capacity = table->capacity();
|
||||
|
||||
for (u32 slot = 0; slot < capacity; slot++) {
|
||||
for (u32 slot = 0; slot < CAPACITY; slot++) {
|
||||
if (keys[slot] != 0 && values[slot].acquireTrace() != NULL) {
|
||||
map[keys[slot]] += values[slot];
|
||||
}
|
||||
@@ -213,72 +233,40 @@ CallTrace* CallTraceStorage::storeCallTrace(int num_frames, ASGCT_CallFrame* fra
|
||||
return buf;
|
||||
}
|
||||
|
||||
CallTrace* CallTraceStorage::findCallTrace(LongHashTable* table, u64 hash) {
|
||||
u64* keys = table->keys();
|
||||
u32 capacity = table->capacity();
|
||||
u32 slot = hash & (capacity - 1);
|
||||
u32 step = 0;
|
||||
|
||||
while (keys[slot] != hash) {
|
||||
if (keys[slot] == 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (++step >= capacity) {
|
||||
return NULL;
|
||||
}
|
||||
slot = (slot + step) & (capacity - 1);
|
||||
}
|
||||
|
||||
return table->values()[slot].trace;
|
||||
}
|
||||
|
||||
u32 CallTraceStorage::put(int num_frames, ASGCT_CallFrame* frames, u64 counter) {
|
||||
u64 hash = calcHash(num_frames, frames);
|
||||
|
||||
LongHashTable* table = _current_table;
|
||||
u64* keys = table->keys();
|
||||
u32 capacity = table->capacity();
|
||||
u32 slot = hash & (capacity - 1);
|
||||
u32 slot = hash & (CAPACITY - 1);
|
||||
u32 step = 0;
|
||||
|
||||
while (keys[slot] != hash) {
|
||||
if (keys[slot] == 0) {
|
||||
if (usedMemory() > _mem_limit) {
|
||||
// Stop adding new stack traces once memory limit is exceeded
|
||||
atomicInc(_overflow);
|
||||
return OVERFLOW_TRACE_ID;
|
||||
}
|
||||
|
||||
if (!__sync_bool_compare_and_swap(&keys[slot], 0, hash)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Increment the table size, and if the load factor exceeds 0.75, reserve a new table.
|
||||
// This condition can be hit only once per table, so the below allocation is race-free.
|
||||
if (table->incSize() == capacity * 3 / 4) {
|
||||
LongHashTable* new_table = LongHashTable::allocate(table, capacity * 2);
|
||||
// Increment the table size, and if the load factor exceeds 0.75, reserve a new table
|
||||
if (table->incSize() == CAPACITY * 3 / 4) {
|
||||
LongHashTable* new_table = LongHashTable::allocate(table, table->base() + CAPACITY);
|
||||
if (new_table != NULL) {
|
||||
atomicInc(_used_memory, new_table->usedMemory());
|
||||
storeRelease(_current_table, new_table);
|
||||
__sync_bool_compare_and_swap(&_current_table, table, new_table);
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate from a previous table to save space
|
||||
CallTrace* trace = table->prev() == NULL ? NULL : findCallTrace(table->prev(), hash);
|
||||
if (trace == NULL) {
|
||||
trace = storeCallTrace(num_frames, frames);
|
||||
}
|
||||
CallTrace* trace = storeCallTrace(num_frames, frames);
|
||||
table->values()[slot].setTrace(trace);
|
||||
break;
|
||||
}
|
||||
|
||||
if (++step >= capacity) {
|
||||
if (++step >= CAPACITY) {
|
||||
// Very unlikely case of a table overflow
|
||||
atomicInc(_overflow);
|
||||
return OVERFLOW_TRACE_ID;
|
||||
}
|
||||
// Improved version of linear probing
|
||||
slot = (slot + step) & (capacity - 1);
|
||||
slot = (slot + step) & (CAPACITY - 1);
|
||||
}
|
||||
|
||||
if (counter != 0) {
|
||||
@@ -287,37 +275,20 @@ u32 CallTraceStorage::put(int num_frames, ASGCT_CallFrame* frames, u64 counter)
|
||||
atomicInc(s.counter, counter);
|
||||
}
|
||||
|
||||
return capacity - (INITIAL_CAPACITY - 1) + slot;
|
||||
return table->base() + slot;
|
||||
}
|
||||
|
||||
void CallTraceStorage::add(u32 call_trace_id, u64 samples, u64 counter) {
|
||||
if (call_trace_id > capacity()) { // this also covers call_trace_id == OVERFLOW_TRACE_ID
|
||||
void CallTraceStorage::add(u32 call_trace_id, u64 counter) {
|
||||
if (call_trace_id == OVERFLOW_TRACE_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
call_trace_id += (INITIAL_CAPACITY - 1);
|
||||
for (LongHashTable* table = _current_table; table != NULL; table = table->prev()) {
|
||||
if (call_trace_id >= table->capacity()) {
|
||||
CallTraceSample& s = table->values()[call_trace_id - table->capacity()];
|
||||
atomicInc(s.samples, samples);
|
||||
if (call_trace_id >= table->base()) {
|
||||
CallTraceSample& s = table->values()[call_trace_id - table->base()];
|
||||
atomicInc(s.samples);
|
||||
atomicInc(s.counter, counter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CallTraceStorage::resetCounters() {
|
||||
for (LongHashTable* table = _current_table; table != NULL; table = table->prev()) {
|
||||
u64* keys = table->keys();
|
||||
CallTraceSample* values = table->values();
|
||||
u32 capacity = table->capacity();
|
||||
|
||||
for (u32 slot = 0; slot < capacity; slot++) {
|
||||
if (keys[slot] != 0) {
|
||||
CallTraceSample& s = values[slot];
|
||||
storeRelease(s.samples, 0);
|
||||
storeRelease(s.counter, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2020 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _CALLTRACESTORAGE_H
|
||||
@@ -26,11 +37,11 @@ struct CallTraceSample {
|
||||
u64 counter;
|
||||
|
||||
CallTrace* acquireTrace() {
|
||||
return loadAcquire(trace);
|
||||
return __atomic_load_n(&trace, __ATOMIC_ACQUIRE);
|
||||
}
|
||||
|
||||
void setTrace(CallTrace* value) {
|
||||
storeRelease(trace, value);
|
||||
return __atomic_store_n(&trace, value, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
CallTraceSample& operator+=(const CallTraceSample& s) {
|
||||
@@ -39,6 +50,10 @@ struct CallTraceSample {
|
||||
counter += s.counter;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator<(const CallTraceSample& other) const {
|
||||
return counter > other.counter;
|
||||
}
|
||||
};
|
||||
|
||||
class CallTraceStorage {
|
||||
@@ -47,30 +62,27 @@ class CallTraceStorage {
|
||||
|
||||
LinearAllocator _allocator;
|
||||
LongHashTable* _current_table;
|
||||
size_t _used_memory;
|
||||
size_t _mem_limit;
|
||||
u64 _overflow;
|
||||
|
||||
u64 calcHash(int num_frames, ASGCT_CallFrame* frames);
|
||||
CallTrace* storeCallTrace(int num_frames, ASGCT_CallFrame* frames);
|
||||
CallTrace* findCallTrace(LongHashTable* table, u64 hash);
|
||||
|
||||
public:
|
||||
CallTraceStorage();
|
||||
~CallTraceStorage();
|
||||
|
||||
void clear(size_t mem_limit);
|
||||
u32 capacity();
|
||||
void clear();
|
||||
size_t usedMemory();
|
||||
u64 overflow() { return _overflow; }
|
||||
Chunk* trimAllocator();
|
||||
LongHashTable* trimTable();
|
||||
void freeMemory(Chunk* chunk, LongHashTable* table);
|
||||
|
||||
void collectTraces(std::map<u32, CallTrace*>& map);
|
||||
void collectSamples(std::vector<CallTraceSample*>& samples);
|
||||
void collectSamples(std::map<u64, CallTraceSample>& map);
|
||||
|
||||
u32 put(int num_frames, ASGCT_CallFrame* frames, u64 counter);
|
||||
void add(u32 call_trace_id, u64 samples, u64 counter);
|
||||
void resetCounters();
|
||||
void add(u32 call_trace_id, u64 counter);
|
||||
};
|
||||
|
||||
#endif // _CALLTRACESTORAGE
|
||||
|
||||
32
src/chk.cpp
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __clang__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "asprof.h"
|
||||
|
||||
|
||||
// libgcc refers to __sprintf_chk, but there is no such symbol in musl libc.
|
||||
// Export a weak symbol in order to make profiler library work both with glibc and musl.
|
||||
|
||||
extern "C" WEAK DLLEXPORT
|
||||
int __sprintf_chk(char* s, int flag, size_t slen, const char* format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int ret = vsnprintf(s, slen, format, args);
|
||||
va_end(args);
|
||||
|
||||
if (ret >= slen) {
|
||||
fprintf(stderr, "__sprintf_chk failed\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // __clang__
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2016 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -9,7 +20,6 @@
|
||||
#include <sys/mman.h>
|
||||
#include "codeCache.h"
|
||||
#include "dwarf.h"
|
||||
#include "log.h"
|
||||
#include "os.h"
|
||||
|
||||
|
||||
@@ -29,22 +39,16 @@ size_t NativeFunc::usedMemory(const char* name) {
|
||||
}
|
||||
|
||||
|
||||
CodeCache::CodeCache(const char* name, short lib_index,
|
||||
const void* min_address, const void* max_address,
|
||||
const char* image_base) {
|
||||
CodeCache::CodeCache(const char* name, short lib_index, const void* min_address, const void* max_address) {
|
||||
_name = NativeFunc::create(name, -1);
|
||||
|
||||
_lib_index = lib_index;
|
||||
_min_address = min_address;
|
||||
_max_address = max_address;
|
||||
_text_base = NULL;
|
||||
_image_base = image_base;
|
||||
|
||||
_plt_offset = 0;
|
||||
_plt_size = 0;
|
||||
|
||||
memset(_imports, 0, sizeof(_imports));
|
||||
_imports_patchable = false;
|
||||
_got_start = NULL;
|
||||
_got_end = NULL;
|
||||
_got_patchable = false;
|
||||
_debug_symbols = false;
|
||||
|
||||
_dwarf_table = NULL;
|
||||
@@ -111,17 +115,16 @@ void CodeCache::sort() {
|
||||
if (_max_address == NO_MAX_ADDRESS) _max_address = _blobs[_count - 1]._end;
|
||||
}
|
||||
|
||||
CodeBlob* CodeCache::findBlob(const char* name) {
|
||||
void CodeCache::mark(NamePredicate predicate) {
|
||||
for (int i = 0; i < _count; i++) {
|
||||
const char* blob_name = _blobs[i]._name;
|
||||
if (blob_name != NULL && strcmp(blob_name, name) == 0) {
|
||||
return &_blobs[i];
|
||||
if (blob_name != NULL && predicate(blob_name)) {
|
||||
NativeFunc::mark(blob_name);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CodeBlob* CodeCache::findBlobByAddress(const void* address) {
|
||||
CodeBlob* CodeCache::find(const void* address) {
|
||||
for (int i = 0; i < _count; i++) {
|
||||
if (address >= _blobs[i]._start && address < _blobs[i]._end) {
|
||||
return &_blobs[i];
|
||||
@@ -154,8 +157,13 @@ const char* CodeCache::binarySearch(const void* address) {
|
||||
}
|
||||
|
||||
const void* CodeCache::findSymbol(const char* name) {
|
||||
CodeBlob* blob = findBlob(name);
|
||||
return blob == NULL ? NULL : blob->_start;
|
||||
for (int i = 0; i < _count; i++) {
|
||||
const char* blob_name = _blobs[i]._name;
|
||||
if (blob_name != NULL && strcmp(blob_name, name) == 0) {
|
||||
return _blobs[i]._start;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const void* CodeCache::findSymbolByPrefix(const char* prefix) {
|
||||
@@ -163,127 +171,49 @@ const void* CodeCache::findSymbolByPrefix(const char* prefix) {
|
||||
}
|
||||
|
||||
const void* CodeCache::findSymbolByPrefix(const char* prefix, int prefix_len) {
|
||||
const void* result = NULL;
|
||||
for (int i = 0; i < _count; i++) {
|
||||
const char* blob_name = _blobs[i]._name;
|
||||
if (blob_name != NULL && strncmp(blob_name, prefix, prefix_len) == 0) {
|
||||
result = _blobs[i]._start;
|
||||
// Symbols which contain a dot are only patched if no alternative is found,
|
||||
// see #1247
|
||||
if (strchr(blob_name + prefix_len, '.') == NULL) {
|
||||
return result;
|
||||
}
|
||||
return _blobs[i]._start;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CodeCache::saveImport(ImportId id, void** entry) {
|
||||
for (int ty = 0; ty < NUM_IMPORT_TYPES; ty++) {
|
||||
if (_imports[id][ty] == nullptr) {
|
||||
_imports[id][ty] = entry;
|
||||
return;
|
||||
CodeBlob* CodeCache::findBlobByPrefix(const char* prefix) {
|
||||
size_t prefix_len = strlen(prefix);
|
||||
for (int i = 0; i < _count; i++) {
|
||||
const char* blob_name = _blobs[i]._name;
|
||||
if (blob_name != NULL && strncmp(blob_name, prefix, prefix_len) == 0) {
|
||||
return &_blobs[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CodeCache::addImport(void** entry, const char* name) {
|
||||
switch (name[0]) {
|
||||
case 'a':
|
||||
if (strcmp(name, "aligned_alloc") == 0) {
|
||||
saveImport(im_aligned_alloc, entry);
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
if (strcmp(name, "calloc") == 0) {
|
||||
saveImport(im_calloc, entry);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
if (strcmp(name, "dlopen") == 0) {
|
||||
saveImport(im_dlopen, entry);
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
if (strcmp(name, "free") == 0) {
|
||||
saveImport(im_free, entry);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
if (strcmp(name, "malloc") == 0) {
|
||||
saveImport(im_malloc, entry);
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
if (strcmp(name, "pthread_create") == 0) {
|
||||
saveImport(im_pthread_create, entry);
|
||||
} else if (strcmp(name, "pthread_exit") == 0) {
|
||||
saveImport(im_pthread_exit, entry);
|
||||
} else if (strcmp(name, "pthread_mutex_lock") == 0) {
|
||||
saveImport(im_pthread_mutex_lock, entry);
|
||||
} else if (strcmp(name, "pthread_rwlock_rdlock") == 0) {
|
||||
saveImport(im_pthread_rwlock_rdlock, entry);
|
||||
} else if (strcmp(name, "pthread_rwlock_wrlock") == 0) {
|
||||
saveImport(im_pthread_rwlock_wrlock, entry);
|
||||
} else if (strcmp(name, "pthread_setspecific") == 0) {
|
||||
saveImport(im_pthread_setspecific, entry);
|
||||
} else if (strcmp(name, "poll") == 0) {
|
||||
saveImport(im_poll, entry);
|
||||
} else if (strcmp(name, "posix_memalign") == 0) {
|
||||
saveImport(im_posix_memalign, entry);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if (strcmp(name, "realloc") == 0) {
|
||||
saveImport(im_realloc, entry);
|
||||
}
|
||||
break;
|
||||
}
|
||||
void CodeCache::setGlobalOffsetTable(void** start, void** end, bool patchable) {
|
||||
_got_start = start;
|
||||
_got_end = end;
|
||||
_got_patchable = patchable;
|
||||
}
|
||||
|
||||
void** CodeCache::findImport(ImportId id) {
|
||||
if (!_imports_patchable) {
|
||||
makeImportsPatchable();
|
||||
}
|
||||
return _imports[id][PRIMARY];
|
||||
}
|
||||
|
||||
void CodeCache::patchImport(ImportId id, void* hook_func) {
|
||||
if (!_imports_patchable && !makeImportsPatchable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int ty = 0; ty < NUM_IMPORT_TYPES; ty++) {
|
||||
void** entry = _imports[id][ty];
|
||||
if (entry != NULL) {
|
||||
*entry = hook_func;
|
||||
void** CodeCache::findGlobalOffsetEntry(void* address) {
|
||||
for (void** entry = _got_start; entry < _got_end; entry++) {
|
||||
if (*entry == address) {
|
||||
makeGotPatchable();
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CodeCache::makeImportsPatchable() {
|
||||
void** min_import = (void**)-1;
|
||||
void** max_import = NULL;
|
||||
for (int i = 0; i < NUM_IMPORTS; i++) {
|
||||
for (int j = 0; j < NUM_IMPORT_TYPES; j++) {
|
||||
void** entry = _imports[i][j];
|
||||
if (entry == NULL) continue;
|
||||
if (entry < min_import) min_import = entry;
|
||||
if (entry > max_import) max_import = entry;
|
||||
}
|
||||
void CodeCache::makeGotPatchable() {
|
||||
if (!_got_patchable) {
|
||||
uintptr_t got_start = (uintptr_t)_got_start & ~OS::page_mask;
|
||||
uintptr_t got_size = ((uintptr_t)_got_end - got_start + OS::page_mask) & ~OS::page_mask;
|
||||
mprotect((void*)got_start, got_size, PROT_READ | PROT_WRITE);
|
||||
_got_patchable = true;
|
||||
}
|
||||
|
||||
if (max_import != NULL) {
|
||||
uintptr_t patch_start = (uintptr_t)min_import & ~OS::page_mask;
|
||||
uintptr_t patch_end = (uintptr_t)max_import & ~OS::page_mask;
|
||||
if (OS::mprotect((void*)patch_start, patch_end - patch_start + OS::page_size, PROT_READ | PROT_WRITE) != 0) {
|
||||
Log::warn("Could not patch %s", name());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_imports_patchable = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodeCache::setDwarfTable(FrameDesc* table, int length) {
|
||||
@@ -307,13 +237,7 @@ FrameDesc* CodeCache::findFrameDesc(const void* pc) {
|
||||
}
|
||||
}
|
||||
|
||||
if (low > 0) {
|
||||
return &_dwarf_table[low - 1];
|
||||
} else if (target_loc - _plt_offset < _plt_size) {
|
||||
return &FrameDesc::empty_frame;
|
||||
} else {
|
||||
return &FrameDesc::default_frame;
|
||||
}
|
||||
return low > 0 ? &_dwarf_table[low - 1] : NULL;
|
||||
}
|
||||
|
||||
size_t CodeCache::usedMemory() {
|
||||
@@ -323,5 +247,5 @@ size_t CodeCache::usedMemory() {
|
||||
for (int i = 0; i < _count; i++) {
|
||||
bytes += NativeFunc::usedMemory(_blobs[i]._name);
|
||||
}
|
||||
return bytes + sizeof(CodeCache);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
129
src/codeCache.h
@@ -1,54 +1,34 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2017 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _CODECACHE_H
|
||||
#define _CODECACHE_H
|
||||
|
||||
#include <jvmti.h>
|
||||
#include "arch.h"
|
||||
|
||||
|
||||
#define NO_MIN_ADDRESS ((const void*)-1)
|
||||
#define NO_MAX_ADDRESS ((const void*)0)
|
||||
|
||||
typedef bool (*NamePredicate)(const char* name);
|
||||
|
||||
const int INITIAL_CODE_CACHE_CAPACITY = 1000;
|
||||
const int MAX_NATIVE_LIBS = 2048;
|
||||
|
||||
|
||||
enum ImportId {
|
||||
im_dlopen,
|
||||
im_pthread_create,
|
||||
im_pthread_exit,
|
||||
im_pthread_mutex_lock,
|
||||
im_pthread_rwlock_rdlock,
|
||||
im_pthread_rwlock_wrlock,
|
||||
im_pthread_setspecific,
|
||||
im_poll,
|
||||
im_malloc,
|
||||
im_calloc,
|
||||
im_realloc,
|
||||
im_free,
|
||||
im_posix_memalign,
|
||||
im_aligned_alloc,
|
||||
NUM_IMPORTS
|
||||
};
|
||||
|
||||
enum ImportType {
|
||||
PRIMARY,
|
||||
SECONDARY,
|
||||
NUM_IMPORT_TYPES
|
||||
};
|
||||
|
||||
enum Mark {
|
||||
MARK_VM_RUNTIME = 1,
|
||||
MARK_INTERPRETER = 2,
|
||||
MARK_COMPILER_ENTRY = 3,
|
||||
MARK_ASYNC_PROFILER = 4, // async-profiler internals such as native hooks.
|
||||
};
|
||||
|
||||
|
||||
class NativeFunc {
|
||||
private:
|
||||
short _lib_index;
|
||||
@@ -70,12 +50,12 @@ class NativeFunc {
|
||||
return from(name)->_lib_index;
|
||||
}
|
||||
|
||||
static char mark(const char* name) {
|
||||
return from(name)->_mark;
|
||||
static bool isMarked(const char* name) {
|
||||
return from(name)->_mark != 0;
|
||||
}
|
||||
|
||||
static void mark(const char* name, char value) {
|
||||
from(name)->_mark = value;
|
||||
static void mark(const char* name) {
|
||||
from(name)->_mark = 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -105,19 +85,16 @@ class CodeBlob {
|
||||
class FrameDesc;
|
||||
|
||||
class CodeCache {
|
||||
private:
|
||||
protected:
|
||||
char* _name;
|
||||
short _lib_index;
|
||||
const void* _min_address;
|
||||
const void* _max_address;
|
||||
const char* _text_base;
|
||||
const char* _image_base;
|
||||
|
||||
unsigned int _plt_offset;
|
||||
unsigned int _plt_size;
|
||||
|
||||
void** _imports[NUM_IMPORTS][NUM_IMPORT_TYPES];
|
||||
bool _imports_patchable;
|
||||
void** _got_start;
|
||||
void** _got_end;
|
||||
bool _got_patchable;
|
||||
bool _debug_symbols;
|
||||
|
||||
FrameDesc* _dwarf_table;
|
||||
@@ -128,15 +105,12 @@ class CodeCache {
|
||||
CodeBlob* _blobs;
|
||||
|
||||
void expand();
|
||||
bool makeImportsPatchable();
|
||||
void saveImport(ImportId id, void** entry);
|
||||
|
||||
public:
|
||||
CodeCache(const char* name,
|
||||
short lib_index = -1,
|
||||
const void* min_address = NO_MIN_ADDRESS,
|
||||
const void* max_address = NO_MAX_ADDRESS,
|
||||
const char* image_base = NULL);
|
||||
const void* max_address = NO_MAX_ADDRESS);
|
||||
|
||||
~CodeCache();
|
||||
|
||||
@@ -152,10 +126,6 @@ class CodeCache {
|
||||
return _max_address;
|
||||
}
|
||||
|
||||
const char* imageBase() const {
|
||||
return _image_base;
|
||||
}
|
||||
|
||||
bool contains(const void* address) const {
|
||||
return address >= _min_address && address < _max_address;
|
||||
}
|
||||
@@ -164,9 +134,12 @@ class CodeCache {
|
||||
_text_base = text_base;
|
||||
}
|
||||
|
||||
void setPlt(unsigned int plt_offset, unsigned int plt_size) {
|
||||
_plt_offset = plt_offset;
|
||||
_plt_size = plt_size;
|
||||
void** gotStart() const {
|
||||
return _got_start;
|
||||
}
|
||||
|
||||
void** gotEnd() const {
|
||||
return _got_end;
|
||||
}
|
||||
|
||||
bool hasDebugSymbols() const {
|
||||
@@ -180,39 +153,23 @@ class CodeCache {
|
||||
void add(const void* start, int length, const char* name, bool update_bounds = false);
|
||||
void updateBounds(const void* start, const void* end);
|
||||
void sort();
|
||||
void mark(NamePredicate predicate);
|
||||
|
||||
template <typename NamePredicate>
|
||||
inline void mark(NamePredicate predicate, char value) {
|
||||
for (int i = 0; i < _count; i++) {
|
||||
const char* blob_name = _blobs[i]._name;
|
||||
if (blob_name != NULL && predicate(blob_name)) {
|
||||
NativeFunc::mark(blob_name, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (value == MARK_VM_RUNTIME && _name != NULL) {
|
||||
// In case a library has no debug symbols
|
||||
NativeFunc::mark(_name, value);
|
||||
}
|
||||
}
|
||||
|
||||
void addImport(void** entry, const char* name);
|
||||
void** findImport(ImportId id);
|
||||
void patchImport(ImportId id, void* hook_func);
|
||||
|
||||
CodeBlob* findBlob(const char* name);
|
||||
CodeBlob* findBlobByAddress(const void* address);
|
||||
CodeBlob* find(const void* address);
|
||||
const char* binarySearch(const void* address);
|
||||
const void* findSymbol(const char* name);
|
||||
CodeBlob* findBlobByPrefix(const char* name);
|
||||
const void* findSymbolByPrefix(const char* prefix);
|
||||
const void* findSymbolByPrefix(const char* prefix, int prefix_len);
|
||||
|
||||
void setGlobalOffsetTable(void** start, void** end, bool patchable);
|
||||
void** findGlobalOffsetEntry(void* address);
|
||||
void makeGotPatchable();
|
||||
|
||||
void setDwarfTable(FrameDesc* table, int length);
|
||||
FrameDesc* findFrameDesc(const void* pc);
|
||||
|
||||
size_t usedMemory();
|
||||
|
||||
friend class UnloadProtection;
|
||||
};
|
||||
|
||||
|
||||
@@ -220,7 +177,6 @@ class CodeCacheArray {
|
||||
private:
|
||||
CodeCache* _libs[MAX_NATIVE_LIBS];
|
||||
int _count;
|
||||
size_t _used_memory;
|
||||
|
||||
public:
|
||||
CodeCacheArray() : _count(0) {
|
||||
@@ -231,18 +187,13 @@ class CodeCacheArray {
|
||||
}
|
||||
|
||||
int count() {
|
||||
return loadAcquire(_count);
|
||||
}
|
||||
|
||||
size_t usedMemory() {
|
||||
return _used_memory;
|
||||
return __atomic_load_n(&_count, __ATOMIC_ACQUIRE);
|
||||
}
|
||||
|
||||
void add(CodeCache* lib) {
|
||||
int index = loadAcquire(_count);
|
||||
int index = __atomic_load_n(&_count, __ATOMIC_ACQUIRE);
|
||||
_libs[index] = lib;
|
||||
_used_memory += lib->usedMemory();
|
||||
storeRelease(_count, index + 1);
|
||||
__atomic_store_n(&_count, index + 1, __ATOMIC_RELEASE);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
106
src/converter/Arguments.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2022 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class Arguments {
|
||||
String title = "Flame Graph";
|
||||
String highlight;
|
||||
Pattern include;
|
||||
Pattern exclude;
|
||||
double minwidth;
|
||||
int skip;
|
||||
boolean reverse;
|
||||
boolean cpu;
|
||||
boolean alloc;
|
||||
boolean live;
|
||||
boolean lock;
|
||||
boolean threads;
|
||||
boolean total;
|
||||
boolean lines;
|
||||
boolean bci;
|
||||
boolean simple;
|
||||
boolean dot;
|
||||
boolean collapsed;
|
||||
long from;
|
||||
long to;
|
||||
String input;
|
||||
String output;
|
||||
|
||||
Arguments(String... args) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (arg.startsWith("--")) {
|
||||
try {
|
||||
Field f = Arguments.class.getDeclaredField(arg.substring(2));
|
||||
if ((f.getModifiers() & (Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL)) != 0) {
|
||||
throw new IllegalStateException(arg);
|
||||
}
|
||||
|
||||
Class<?> type = f.getType();
|
||||
if (type == String.class) {
|
||||
f.set(this, args[++i]);
|
||||
} else if (type == boolean.class) {
|
||||
f.setBoolean(this, true);
|
||||
} else if (type == int.class) {
|
||||
f.setInt(this, Integer.parseInt(args[++i]));
|
||||
} else if (type == double.class) {
|
||||
f.setDouble(this, Double.parseDouble(args[++i]));
|
||||
} else if (type == long.class) {
|
||||
f.setLong(this, parseTimestamp(args[++i]));
|
||||
} else if (type == Pattern.class) {
|
||||
f.set(this, Pattern.compile(args[++i]));
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new IllegalArgumentException(arg);
|
||||
}
|
||||
} else if (!arg.isEmpty()) {
|
||||
if (input == null) {
|
||||
input = arg;
|
||||
} else {
|
||||
output = arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Milliseconds or HH:mm:ss.S or yyyy-MM-dd'T'HH:mm:ss.S
|
||||
private long parseTimestamp(String time) {
|
||||
if (time.indexOf(':') < 0) {
|
||||
return Long.parseLong(time);
|
||||
}
|
||||
|
||||
GregorianCalendar cal = new GregorianCalendar();
|
||||
StringTokenizer st = new StringTokenizer(time, "-:.T");
|
||||
|
||||
if (time.indexOf('T') > 0) {
|
||||
cal.set(Calendar.YEAR, Integer.parseInt(st.nextToken()));
|
||||
cal.set(Calendar.MONTH, Integer.parseInt(st.nextToken()) - 1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
cal.set(Calendar.HOUR_OF_DAY, st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0);
|
||||
cal.set(Calendar.MINUTE, st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0);
|
||||
cal.set(Calendar.SECOND, st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0);
|
||||
cal.set(Calendar.MILLISECOND, st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0);
|
||||
|
||||
return cal.getTimeInMillis();
|
||||
}
|
||||
}
|
||||
50
src/converter/CollapsedStacks.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2022 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class CollapsedStacks extends FlameGraph {
|
||||
private final StringBuilder sb = new StringBuilder();
|
||||
private final PrintStream out;
|
||||
|
||||
public CollapsedStacks(Arguments args) throws IOException {
|
||||
super(args);
|
||||
this.out = args.output == null ? System.out : new PrintStream(
|
||||
new BufferedOutputStream(new FileOutputStream(args.output), 32768), false, "UTF-8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSample(String[] trace, long ticks) {
|
||||
for (String s : trace) {
|
||||
sb.append(s).append(';');
|
||||
}
|
||||
if (sb.length() > 0) sb.setCharAt(sb.length() - 1, ' ');
|
||||
sb.append(ticks);
|
||||
|
||||
out.println(sb.toString());
|
||||
sb.setLength(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump() {
|
||||
if (out != System.out) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
299
src/converter/FlameGraph.java
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Copyright 2020 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class FlameGraph {
|
||||
public static final byte FRAME_INTERPRETED = 0;
|
||||
public static final byte FRAME_JIT_COMPILED = 1;
|
||||
public static final byte FRAME_INLINED = 2;
|
||||
public static final byte FRAME_NATIVE = 3;
|
||||
public static final byte FRAME_CPP = 4;
|
||||
public static final byte FRAME_KERNEL = 5;
|
||||
public static final byte FRAME_C1_COMPILED = 6;
|
||||
|
||||
private final Arguments args;
|
||||
private final Frame root = new Frame(FRAME_NATIVE);
|
||||
private int depth;
|
||||
private long mintotal;
|
||||
|
||||
public FlameGraph(Arguments args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public FlameGraph(String... args) {
|
||||
this(new Arguments(args));
|
||||
}
|
||||
|
||||
public void parse() throws IOException {
|
||||
parse(new InputStreamReader(new FileInputStream(args.input), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public void parse(Reader in) throws IOException {
|
||||
try (BufferedReader br = new BufferedReader(in)) {
|
||||
for (String line; (line = br.readLine()) != null; ) {
|
||||
int space = line.lastIndexOf(' ');
|
||||
if (space <= 0) continue;
|
||||
|
||||
String[] trace = line.substring(0, space).split(";");
|
||||
long ticks = Long.parseLong(line.substring(space + 1));
|
||||
addSample(trace, ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addSample(String[] trace, long ticks) {
|
||||
if (excludeTrace(trace)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Frame frame = root;
|
||||
if (args.reverse) {
|
||||
for (int i = trace.length; --i >= args.skip; ) {
|
||||
frame = frame.addChild(trace[i], ticks);
|
||||
}
|
||||
} else {
|
||||
for (int i = args.skip; i < trace.length; i++) {
|
||||
frame = frame.addChild(trace[i], ticks);
|
||||
}
|
||||
}
|
||||
frame.addLeaf(ticks);
|
||||
|
||||
depth = Math.max(depth, trace.length);
|
||||
}
|
||||
|
||||
public void dump() throws IOException {
|
||||
if (args.output == null) {
|
||||
dump(System.out);
|
||||
} else {
|
||||
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(args.output), 32768);
|
||||
PrintStream out = new PrintStream(bos, false, "UTF-8")) {
|
||||
dump(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dump(PrintStream out) {
|
||||
mintotal = (long) (root.total * args.minwidth / 100);
|
||||
int depth = mintotal > 1 ? root.depth(mintotal) : this.depth + 1;
|
||||
|
||||
String tail = getResource("/flame.html");
|
||||
|
||||
tail = printTill(out, tail, "/*height:*/300");
|
||||
out.print(Math.min(depth * 16, 32767));
|
||||
|
||||
tail = printTill(out, tail, "/*title:*/");
|
||||
out.print(args.title);
|
||||
|
||||
tail = printTill(out, tail, "/*reverse:*/false");
|
||||
out.print(args.reverse);
|
||||
|
||||
tail = printTill(out, tail, "/*depth:*/0");
|
||||
out.print(depth);
|
||||
|
||||
tail = printTill(out, tail, "/*frames:*/");
|
||||
|
||||
printFrame(out, "all", root, 0, 0);
|
||||
|
||||
tail = printTill(out, tail, "/*highlight:*/");
|
||||
out.print(args.highlight != null ? "'" + escape(args.highlight) + "'" : "");
|
||||
|
||||
out.print(tail);
|
||||
}
|
||||
|
||||
private String printTill(PrintStream out, String data, String till) {
|
||||
int index = data.indexOf(till);
|
||||
out.print(data.substring(0, index));
|
||||
return data.substring(index + till.length());
|
||||
}
|
||||
|
||||
private void printFrame(PrintStream out, String title, Frame frame, int level, long x) {
|
||||
int type = frame.getType();
|
||||
if (type == FRAME_KERNEL) {
|
||||
title = stripSuffix(title);
|
||||
}
|
||||
|
||||
if ((frame.inlined | frame.c1 | frame.interpreted) != 0 && frame.inlined < frame.total && frame.interpreted < frame.total) {
|
||||
out.println("f(" + level + "," + x + "," + frame.total + "," + type + ",'" + escape(title) + "'," +
|
||||
frame.inlined + "," + frame.c1 + "," + frame.interpreted + ")");
|
||||
} else {
|
||||
out.println("f(" + level + "," + x + "," + frame.total + "," + type + ",'" + escape(title) + "')");
|
||||
}
|
||||
|
||||
x += frame.self;
|
||||
for (Map.Entry<String, Frame> e : frame.entrySet()) {
|
||||
Frame child = e.getValue();
|
||||
if (child.total >= mintotal) {
|
||||
printFrame(out, e.getKey(), child, level + 1, x);
|
||||
}
|
||||
x += child.total;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean excludeTrace(String[] trace) {
|
||||
Pattern include = args.include;
|
||||
Pattern exclude = args.exclude;
|
||||
if (include == null && exclude == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String frame : trace) {
|
||||
if (exclude != null && exclude.matcher(frame).matches()) {
|
||||
return true;
|
||||
}
|
||||
if (include != null && include.matcher(frame).matches()) {
|
||||
include = null;
|
||||
if (exclude == null) break;
|
||||
}
|
||||
}
|
||||
|
||||
return include != null;
|
||||
}
|
||||
|
||||
static String stripSuffix(String title) {
|
||||
return title.substring(0, title.length() - 4);
|
||||
}
|
||||
|
||||
static String escape(String s) {
|
||||
if (s.indexOf('\\') >= 0) s = s.replace("\\", "\\\\");
|
||||
if (s.indexOf('\'') >= 0) s = s.replace("'", "\\'");
|
||||
return s;
|
||||
}
|
||||
|
||||
private static String getResource(String name) {
|
||||
try (InputStream stream = FlameGraph.class.getResourceAsStream(name)) {
|
||||
if (stream == null) {
|
||||
throw new IOException("No resource found");
|
||||
}
|
||||
|
||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[64 * 1024];
|
||||
for (int length; (length = stream.read(buffer)) != -1; ) {
|
||||
result.write(buffer, 0, length);
|
||||
}
|
||||
return result.toString("UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Can't load resource with name " + name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] cmdline) throws IOException {
|
||||
Arguments args = new Arguments(cmdline);
|
||||
if (args.input == null) {
|
||||
System.out.println("Usage: java " + FlameGraph.class.getName() + " [options] input.collapsed [output.html]");
|
||||
System.out.println();
|
||||
System.out.println("Options:");
|
||||
System.out.println(" --title TITLE");
|
||||
System.out.println(" --reverse");
|
||||
System.out.println(" --minwidth PERCENT");
|
||||
System.out.println(" --skip FRAMES");
|
||||
System.out.println(" --include PATTERN");
|
||||
System.out.println(" --exclude PATTERN");
|
||||
System.out.println(" --highlight PATTERN");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
FlameGraph fg = new FlameGraph(args);
|
||||
fg.parse();
|
||||
fg.dump();
|
||||
}
|
||||
|
||||
static class Frame extends TreeMap<String, Frame> {
|
||||
final byte type;
|
||||
long total;
|
||||
long self;
|
||||
long inlined, c1, interpreted;
|
||||
|
||||
Frame(byte type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
byte getType() {
|
||||
if (inlined * 3 >= total) {
|
||||
return FRAME_INLINED;
|
||||
} else if (c1 * 2 >= total) {
|
||||
return FRAME_C1_COMPILED;
|
||||
} else if (interpreted * 2 >= total) {
|
||||
return FRAME_INTERPRETED;
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
private Frame getChild(String title, byte type) {
|
||||
Frame child = super.get(title);
|
||||
if (child == null) {
|
||||
super.put(title, child = new Frame(type));
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
Frame addChild(String title, long ticks) {
|
||||
total += ticks;
|
||||
|
||||
Frame child;
|
||||
if (title.endsWith("_[j]")) {
|
||||
child = getChild(stripSuffix(title), FRAME_JIT_COMPILED);
|
||||
} else if (title.endsWith("_[i]")) {
|
||||
(child = getChild(stripSuffix(title), FRAME_JIT_COMPILED)).inlined += ticks;
|
||||
} else if (title.endsWith("_[k]")) {
|
||||
child = getChild(title, FRAME_KERNEL);
|
||||
} else if (title.endsWith("_[1]")) {
|
||||
(child = getChild(stripSuffix(title), FRAME_JIT_COMPILED)).c1 += ticks;
|
||||
} else if (title.endsWith("_[0]")) {
|
||||
(child = getChild(stripSuffix(title), FRAME_JIT_COMPILED)).interpreted += ticks;
|
||||
} else if (title.contains("::") || title.startsWith("-[") || title.startsWith("+[")) {
|
||||
child = getChild(title, FRAME_CPP);
|
||||
} else if (title.indexOf('/') > 0 && title.charAt(0) != '['
|
||||
|| title.indexOf('.') > 0 && Character.isUpperCase(title.charAt(0))) {
|
||||
child = getChild(title, FRAME_JIT_COMPILED);
|
||||
} else {
|
||||
child = getChild(title, FRAME_NATIVE);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
void addLeaf(long ticks) {
|
||||
total += ticks;
|
||||
self += ticks;
|
||||
}
|
||||
|
||||
int depth(long cutoff) {
|
||||
int depth = 0;
|
||||
if (size() > 0) {
|
||||
for (Frame child : values()) {
|
||||
if (child.total >= cutoff) {
|
||||
depth = Math.max(depth, child.depth(cutoff));
|
||||
}
|
||||
}
|
||||
}
|
||||
return depth + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/converter/Main.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2020 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Main entry point of jar.
|
||||
* Lists available converters.
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Usage: java -cp converter.jar <Converter> [options] <input> <output>");
|
||||
System.out.println();
|
||||
System.out.println("Available converters:");
|
||||
System.out.println(" FlameGraph input.collapsed output.html");
|
||||
System.out.println(" jfr2flame input.jfr output.html");
|
||||
System.out.println(" jfr2nflx input.jfr output.nflx");
|
||||
System.out.println(" jfr2pprof input.jfr output.pprof");
|
||||
}
|
||||
}
|
||||
263
src/converter/jfr2flame.java
Normal file
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright 2020 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import one.jfr.ClassRef;
|
||||
import one.jfr.Dictionary;
|
||||
import one.jfr.JfrReader;
|
||||
import one.jfr.MethodRef;
|
||||
import one.jfr.StackTrace;
|
||||
import one.jfr.event.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Converts .jfr output produced by async-profiler to HTML Flame Graph.
|
||||
*/
|
||||
public class jfr2flame {
|
||||
|
||||
private static final String[] FRAME_SUFFIX = {"_[0]", "_[j]", "_[i]", "", "", "_[k]", "_[1]"};
|
||||
|
||||
private final JfrReader jfr;
|
||||
private final Arguments args;
|
||||
private final Dictionary<String> methodNames = new Dictionary<>();
|
||||
|
||||
public jfr2flame(JfrReader jfr, Arguments args) {
|
||||
this.jfr = jfr;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public void convert(final FlameGraph fg) throws IOException {
|
||||
EventAggregator agg = new EventAggregator(args.threads, args.total);
|
||||
|
||||
Class<? extends Event> eventClass =
|
||||
args.live ? LiveObject.class :
|
||||
args.alloc ? AllocationSample.class :
|
||||
args.lock ? ContendedLock.class : ExecutionSample.class;
|
||||
int threadState = args.cpu ? getMapKey(jfr.threadStates, "STATE_RUNNABLE") : -1;
|
||||
|
||||
long startTicks = args.from != 0 ? toTicks(args.from) : Long.MIN_VALUE;
|
||||
long endTicks = args.to != 0 ? toTicks(args.to) : Long.MAX_VALUE;
|
||||
|
||||
for (Event event; (event = jfr.readEvent(eventClass)) != null; ) {
|
||||
if (event.time >= startTicks && event.time <= endTicks) {
|
||||
if (threadState < 0 || ((ExecutionSample) event).threadState == threadState) {
|
||||
agg.collect(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final double ticksToNanos = 1e9 / jfr.ticksPerSec;
|
||||
final boolean scale = args.total && eventClass == ContendedLock.class && ticksToNanos != 1.0;
|
||||
|
||||
// Don't use lambda for faster startup
|
||||
agg.forEach(new EventAggregator.Visitor() {
|
||||
@Override
|
||||
public void visit(Event event, long value) {
|
||||
StackTrace stackTrace = jfr.stackTraces.get(event.stackTraceId);
|
||||
if (stackTrace != null) {
|
||||
Arguments args = jfr2flame.this.args;
|
||||
long[] methods = stackTrace.methods;
|
||||
byte[] types = stackTrace.types;
|
||||
int[] locations = stackTrace.locations;
|
||||
String classFrame = getClassFrame(event);
|
||||
String[] trace = new String[methods.length + (args.threads ? 1 : 0) + (classFrame != null ? 1 : 0)];
|
||||
if (args.threads) {
|
||||
trace[0] = getThreadFrame(event.tid);
|
||||
}
|
||||
int idx = trace.length;
|
||||
if (classFrame != null) {
|
||||
trace[--idx] = classFrame;
|
||||
}
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
String methodName = getMethodName(methods[i], types[i]);
|
||||
int location;
|
||||
if (args.lines && (location = locations[i] >>> 16) != 0) {
|
||||
methodName += ":" + location;
|
||||
} else if (args.bci && (location = locations[i] & 0xffff) != 0) {
|
||||
methodName += "@" + location;
|
||||
}
|
||||
trace[--idx] = methodName + FRAME_SUFFIX[types[i]];
|
||||
}
|
||||
fg.addSample(trace, scale ? (long) (value * ticksToNanos) : value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getThreadFrame(int tid) {
|
||||
String threadName = jfr.threads.get(tid);
|
||||
return threadName == null ? "[tid=" + tid + ']' : '[' + threadName + " tid=" + tid + ']';
|
||||
}
|
||||
|
||||
private String getClassFrame(Event event) {
|
||||
long classId;
|
||||
String suffix;
|
||||
if (event instanceof AllocationSample) {
|
||||
classId = ((AllocationSample) event).classId;
|
||||
suffix = ((AllocationSample) event).tlabSize == 0 ? "_[k]" : "_[i]";
|
||||
} else if (event instanceof ContendedLock) {
|
||||
classId = ((ContendedLock) event).classId;
|
||||
suffix = "_[i]";
|
||||
} else if (event instanceof LiveObject) {
|
||||
classId = ((LiveObject) event).classId;
|
||||
suffix = "_[i]";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
ClassRef cls = jfr.classes.get(classId);
|
||||
if (cls == null) {
|
||||
return "null";
|
||||
}
|
||||
byte[] className = jfr.symbols.get(cls.name);
|
||||
|
||||
int arrayDepth = 0;
|
||||
while (className[arrayDepth] == '[') {
|
||||
arrayDepth++;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(toJavaClassName(className, arrayDepth, true));
|
||||
while (arrayDepth-- > 0) {
|
||||
sb.append("[]");
|
||||
}
|
||||
return sb.append(suffix).toString();
|
||||
}
|
||||
|
||||
private String getMethodName(long methodId, byte methodType) {
|
||||
String result = methodNames.get(methodId);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
MethodRef method = jfr.methods.get(methodId);
|
||||
if (method == null) {
|
||||
result = "unknown";
|
||||
} else {
|
||||
ClassRef cls = jfr.classes.get(method.cls);
|
||||
byte[] className = jfr.symbols.get(cls.name);
|
||||
byte[] methodName = jfr.symbols.get(method.name);
|
||||
|
||||
if (className == null || className.length == 0 || isNativeFrame(methodType)) {
|
||||
result = new String(methodName, StandardCharsets.UTF_8);
|
||||
} else {
|
||||
String classStr = toJavaClassName(className, 0, args.dot);
|
||||
String methodStr = new String(methodName, StandardCharsets.UTF_8);
|
||||
result = classStr + '.' + methodStr;
|
||||
}
|
||||
}
|
||||
|
||||
methodNames.put(methodId, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isNativeFrame(byte methodType) {
|
||||
return methodType >= FlameGraph.FRAME_NATIVE && methodType <= FlameGraph.FRAME_KERNEL
|
||||
&& jfr.frameTypes.size() > FlameGraph.FRAME_NATIVE + 1;
|
||||
}
|
||||
|
||||
private String toJavaClassName(byte[] symbol, int start, boolean dotted) {
|
||||
int end = symbol.length;
|
||||
if (start > 0) {
|
||||
switch (symbol[start]) {
|
||||
case 'B':
|
||||
return "byte";
|
||||
case 'C':
|
||||
return "char";
|
||||
case 'S':
|
||||
return "short";
|
||||
case 'I':
|
||||
return "int";
|
||||
case 'J':
|
||||
return "long";
|
||||
case 'Z':
|
||||
return "boolean";
|
||||
case 'F':
|
||||
return "float";
|
||||
case 'D':
|
||||
return "double";
|
||||
case 'L':
|
||||
start++;
|
||||
end--;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.simple) {
|
||||
for (int i = end - 2; i >= start; i--) {
|
||||
if (symbol[i] == '/' && (symbol[i + 1] < '0' || symbol[i + 1] > '9')) {
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String s = new String(symbol, start, end - start, StandardCharsets.UTF_8);
|
||||
return dotted ? s.replace('/', '.') : s;
|
||||
}
|
||||
|
||||
// millis can be an absolute timestamp or an offset from the beginning/end of the recording
|
||||
private long toTicks(long millis) {
|
||||
long nanos = millis * 1_000_000;
|
||||
if (millis < 0) {
|
||||
nanos += jfr.endNanos;
|
||||
} else if (millis < 1500000000000L) {
|
||||
nanos += jfr.startNanos;
|
||||
}
|
||||
return jfr.nanosToTicks(nanos);
|
||||
}
|
||||
|
||||
private static int getMapKey(Map<Integer, String> map, String value) {
|
||||
for (Map.Entry<Integer, String> entry : map.entrySet()) {
|
||||
if (value.equals(entry.getValue())) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void main(String[] cmdline) throws Exception {
|
||||
Arguments args = new Arguments(cmdline);
|
||||
if (args.input == null) {
|
||||
System.out.println("Usage: java " + jfr2flame.class.getName() + " [options] input.jfr [output.html]");
|
||||
System.out.println();
|
||||
System.out.println("options include all supported FlameGraph options, plus the following:");
|
||||
System.out.println(" --cpu CPU Flame Graph");
|
||||
System.out.println(" --alloc Allocation Flame Graph");
|
||||
System.out.println(" --live Include only live objects in allocation profile");
|
||||
System.out.println(" --lock Lock contention Flame Graph");
|
||||
System.out.println(" --threads Split profile by threads");
|
||||
System.out.println(" --total Accumulate the total value (time, bytes, etc.)");
|
||||
System.out.println(" --lines Show line numbers");
|
||||
System.out.println(" --bci Show bytecode indices");
|
||||
System.out.println(" --simple Simple class names instead of FQN");
|
||||
System.out.println(" --dot Dotted class names");
|
||||
System.out.println(" --from TIME Start time in ms (absolute or relative)");
|
||||
System.out.println(" --to TIME End time in ms (absolute or relative)");
|
||||
System.out.println(" --collapsed Use collapsed stacks output format");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
boolean collapsed = args.collapsed || args.output != null && args.output.endsWith(".collapsed");
|
||||
FlameGraph fg = collapsed ? new CollapsedStacks(args) : new FlameGraph(args);
|
||||
|
||||
try (JfrReader jfr = new JfrReader(args.input)) {
|
||||
new jfr2flame(jfr, args).convert(fg);
|
||||
}
|
||||
|
||||
fg.dump();
|
||||
}
|
||||
}
|
||||
179
src/converter/jfr2nflx.java
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright 2020 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import one.jfr.ClassRef;
|
||||
import one.jfr.JfrReader;
|
||||
import one.jfr.MethodRef;
|
||||
import one.jfr.StackTrace;
|
||||
import one.jfr.event.Event;
|
||||
import one.jfr.event.EventAggregator;
|
||||
import one.jfr.event.ExecutionSample;
|
||||
import one.proto.Proto;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Converts .jfr output produced by async-profiler to nflxprofile format
|
||||
* as described in https://github.com/Netflix/nflxprofile/blob/master/nflxprofile.proto.
|
||||
* The result nflxprofile can be opened and analyzed with FlameScope.
|
||||
*/
|
||||
public class jfr2nflx {
|
||||
|
||||
private static final String[] FRAME_TYPE = {"jit", "jit", "inlined", "user", "user", "kernel", "jit"};
|
||||
private static final byte[] NO_STACK = "[no_stack]".getBytes();
|
||||
private static final byte[] UNKNOWN = "[unknown]".getBytes();
|
||||
|
||||
private final JfrReader jfr;
|
||||
private final List<ExecutionSample> samples;
|
||||
|
||||
public jfr2nflx(JfrReader jfr) throws IOException {
|
||||
this.jfr = jfr;
|
||||
this.samples = jfr.readAllEvents(ExecutionSample.class);
|
||||
}
|
||||
|
||||
public void dump(OutputStream out) throws IOException {
|
||||
long startTime = System.nanoTime();
|
||||
|
||||
int size = samples.size();
|
||||
long durationTicks = size == 0 ? 0 : samples.get(size - 1).time - jfr.startTicks + 1;
|
||||
|
||||
final Proto profile = new Proto(200000)
|
||||
.field(1, 0.0)
|
||||
.field(2, Math.max(jfr.durationNanos() / 1e9, durationTicks / (double) jfr.ticksPerSec))
|
||||
.field(3, packSamples())
|
||||
.field(4, packDeltas())
|
||||
.field(6, "async-profiler")
|
||||
.field(8, new Proto(32).field(1, "has_node_stack").field(2, "true"))
|
||||
.field(8, new Proto(32).field(1, "has_samples_tid").field(2, "true"))
|
||||
.field(11, packTids());
|
||||
|
||||
final Proto nodes = new Proto(10000);
|
||||
final Proto node = new Proto(10000);
|
||||
|
||||
EventAggregator agg = new EventAggregator(false, false);
|
||||
for (ExecutionSample sample : samples) {
|
||||
agg.collect(sample);
|
||||
}
|
||||
|
||||
// Don't use lambda for faster startup
|
||||
agg.forEach(new EventAggregator.Visitor() {
|
||||
@Override
|
||||
public void visit(Event event, long value) {
|
||||
StackTrace stackTrace = jfr.stackTraces.get(event.stackTraceId);
|
||||
if (stackTrace != null) {
|
||||
profile.field(5, nodes
|
||||
.field(1, event.stackTraceId)
|
||||
.field(2, packNode(node, stackTrace)));
|
||||
nodes.reset();
|
||||
node.reset();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
out.write(profile.buffer(), 0, profile.size());
|
||||
|
||||
long endTime = System.nanoTime();
|
||||
System.out.println("Wrote " + profile.size() + " bytes in " + (endTime - startTime) / 1e9 + " s");
|
||||
}
|
||||
|
||||
private Proto packNode(Proto node, StackTrace stackTrace) {
|
||||
long[] methods = stackTrace.methods;
|
||||
byte[] types = stackTrace.types;
|
||||
int top = methods.length - 1;
|
||||
|
||||
node.field(1, top >= 0 ? getMethodName(methods[top], types[top]) : NO_STACK);
|
||||
node.field(2, 1);
|
||||
node.field(4, top >= 0 ? FRAME_TYPE[types[top]] : "user");
|
||||
|
||||
for (Proto frame = new Proto(100); --top >= 0; frame.reset()) {
|
||||
node.field(10, frame
|
||||
.field(1, getMethodName(methods[top], types[top]))
|
||||
.field(2, FRAME_TYPE[types[top]]));
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
private Proto packSamples() {
|
||||
Proto proto = new Proto(10000);
|
||||
for (ExecutionSample sample : samples) {
|
||||
proto.writeInt(sample.stackTraceId);
|
||||
}
|
||||
return proto;
|
||||
}
|
||||
|
||||
private Proto packDeltas() {
|
||||
Proto proto = new Proto(10000);
|
||||
double ticksPerSec = jfr.ticksPerSec;
|
||||
long prevTime = jfr.startTicks;
|
||||
for (ExecutionSample sample : samples) {
|
||||
proto.writeDouble((sample.time - prevTime) / ticksPerSec);
|
||||
prevTime = sample.time;
|
||||
}
|
||||
return proto;
|
||||
}
|
||||
|
||||
private Proto packTids() {
|
||||
Proto proto = new Proto(10000);
|
||||
for (ExecutionSample sample : samples) {
|
||||
proto.writeInt(sample.tid);
|
||||
}
|
||||
return proto;
|
||||
}
|
||||
|
||||
private byte[] getMethodName(long methodId, byte methodType) {
|
||||
MethodRef method = jfr.methods.get(methodId);
|
||||
if (method == null) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
ClassRef cls = jfr.classes.get(method.cls);
|
||||
byte[] className = jfr.symbols.get(cls.name);
|
||||
byte[] methodName = jfr.symbols.get(method.name);
|
||||
|
||||
if ((methodType >= FlameGraph.FRAME_NATIVE && methodType <= FlameGraph.FRAME_KERNEL)
|
||||
|| className == null || className.length == 0) {
|
||||
return methodName;
|
||||
} else {
|
||||
byte[] fullName = Arrays.copyOf(className, className.length + 1 + methodName.length);
|
||||
fullName[className.length] = '.';
|
||||
System.arraycopy(methodName, 0, fullName, className.length + 1, methodName.length);
|
||||
return fullName;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
System.out.println("Usage: java " + jfr2nflx.class.getName() + " input.jfr output.nflx");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
File dst = new File(args[1]);
|
||||
if (dst.isDirectory()) {
|
||||
dst = new File(dst, new File(args[0]).getName().replace(".jfr", ".nflx"));
|
||||
}
|
||||
|
||||
try (JfrReader jfr = new JfrReader(args[0]);
|
||||
FileOutputStream out = new FileOutputStream(dst)) {
|
||||
new jfr2nflx(jfr).dump(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
227
src/converter/jfr2pprof.java
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright 2022 Andrei Pangin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import one.jfr.ClassRef;
|
||||
import one.jfr.Dictionary;
|
||||
import one.jfr.JfrReader;
|
||||
import one.jfr.MethodRef;
|
||||
import one.jfr.StackTrace;
|
||||
import one.jfr.event.ExecutionSample;
|
||||
import one.proto.Proto;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Convert a JFR file to pprof
|
||||
* <p>
|
||||
* Protobuf definition: https://github.com/google/pprof/blob/44fc4e887b6b0cfb196973bcdb1fab95f0b3a75b/proto/profile.proto
|
||||
*/
|
||||
public class jfr2pprof {
|
||||
|
||||
public static class Method {
|
||||
final byte[] name;
|
||||
|
||||
public Method(final byte[] name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
return other instanceof Method && Arrays.equals(name, ((Method) other).name);
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte[] METHOD_UNKNOWN = "[unknown]".getBytes();
|
||||
|
||||
// Profile IDs
|
||||
public static final int PROFILE_SAMPLE_TYPE = 1;
|
||||
public static final int PROFILE_SAMPLE = 2;
|
||||
public static final int PROFILE_LOCATION = 4;
|
||||
public static final int PROFILE_FUNCTION = 5;
|
||||
public static final int PROFILE_STRING_TABLE = 6;
|
||||
public static final int PROFILE_TIME_NANOS = 9;
|
||||
public static final int PROFILE_DURATION_NANOS = 10;
|
||||
public static final int PROFILE_COMMENT = 13;
|
||||
public static final int PROFILE_DEFAULT_SAMPLE_TYPE = 14;
|
||||
|
||||
// ValueType IDs
|
||||
public static final int VALUETYPE_TYPE = 1;
|
||||
public static final int VALUETYPE_UNIT = 2;
|
||||
|
||||
// Sample IDs
|
||||
public static final int SAMPLE_LOCATION_ID = 1;
|
||||
public static final int SAMPLE_VALUE = 2;
|
||||
|
||||
// Location IDs
|
||||
public static final int LOCATION_ID = 1;
|
||||
public static final int LOCATION_LINE = 4;
|
||||
|
||||
// Line IDs
|
||||
public static final int LINE_FUNCTION_ID = 1;
|
||||
public static final int LINE_LINE = 2;
|
||||
|
||||
// Function IDs
|
||||
public static final int FUNCTION_ID = 1;
|
||||
public static final int FUNCTION_NAME = 2;
|
||||
|
||||
private final JfrReader reader;
|
||||
|
||||
public jfr2pprof(final JfrReader reader) {
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
// `Proto` instances are mutable, careful with reordering
|
||||
public void dump(final OutputStream out) throws Exception {
|
||||
// Mutable IDs, need to start at 1
|
||||
int functionId = 1;
|
||||
int locationId = 1;
|
||||
int stringId = 1;
|
||||
|
||||
// Used to de-dupe
|
||||
final Map<Method, Integer> functions = new HashMap<>();
|
||||
final Map<Method, Integer> locations = new HashMap<>();
|
||||
|
||||
final Proto profile = new Proto(200_000)
|
||||
.field(PROFILE_TIME_NANOS, reader.startNanos)
|
||||
.field(PROFILE_DURATION_NANOS, reader.durationNanos())
|
||||
.field(PROFILE_DEFAULT_SAMPLE_TYPE, 0L)
|
||||
.field(PROFILE_STRING_TABLE, "".getBytes(StandardCharsets.UTF_8)) // "" needs to be index 0
|
||||
.field(PROFILE_STRING_TABLE, "async-profiler".getBytes(StandardCharsets.UTF_8))
|
||||
.field(PROFILE_COMMENT, stringId++);
|
||||
|
||||
final Proto sampleType = new Proto(100);
|
||||
|
||||
profile.field(PROFILE_STRING_TABLE, "cpu".getBytes(StandardCharsets.UTF_8));
|
||||
sampleType.field(VALUETYPE_TYPE, stringId++);
|
||||
|
||||
profile.field(PROFILE_STRING_TABLE, "nanoseconds".getBytes(StandardCharsets.UTF_8));
|
||||
sampleType.field(VALUETYPE_UNIT, stringId++);
|
||||
|
||||
profile.field(PROFILE_SAMPLE_TYPE, sampleType);
|
||||
|
||||
final List<ExecutionSample> jfrSamples = reader.readAllEvents(ExecutionSample.class);
|
||||
final Dictionary<StackTrace> stackTraces = reader.stackTraces;
|
||||
long previousTime = reader.startTicks; // Mutate this to keep track of time deltas
|
||||
|
||||
// Iterate over samples
|
||||
for (final ExecutionSample jfrSample : jfrSamples) {
|
||||
final StackTrace stackTrace = stackTraces.get(jfrSample.stackTraceId);
|
||||
final long[] methods = stackTrace.methods;
|
||||
final byte[] types = stackTrace.types;
|
||||
|
||||
final long nanosSinceLastSample = (jfrSample.time - previousTime) * 1_000_000_000 / reader.ticksPerSec;
|
||||
final Proto sample = new Proto(1_000).field(SAMPLE_VALUE, nanosSinceLastSample);
|
||||
|
||||
for (int current = 0; current < methods.length; current++) {
|
||||
final byte methodType = types[current];
|
||||
final long methodIdentifier = methods[current];
|
||||
final byte[] methodName = getMethodName(methodIdentifier, methodType);
|
||||
final Method method = new Method(methodName);
|
||||
final int line = stackTrace.locations[current] >>> 16;
|
||||
|
||||
final Integer methodId = functions.get(method);
|
||||
if (null == methodId) {
|
||||
final int funcId = functionId++;
|
||||
profile.field(PROFILE_STRING_TABLE, methodName);
|
||||
final Proto function = new Proto(16)
|
||||
.field(FUNCTION_ID, funcId)
|
||||
.field(FUNCTION_NAME, stringId++);
|
||||
|
||||
profile.field(PROFILE_FUNCTION, function);
|
||||
|
||||
functions.put(method, funcId);
|
||||
}
|
||||
|
||||
final Integer locaId = locations.get(method);
|
||||
if (null == locaId) {
|
||||
final int locId = locationId++;
|
||||
final Proto locLine = new Proto(16).field(LINE_FUNCTION_ID, functions.get(method));
|
||||
if (line > 0) {
|
||||
locLine.field(LINE_LINE, line);
|
||||
}
|
||||
|
||||
final Proto location = new Proto(16)
|
||||
.field(LOCATION_ID, locId)
|
||||
.field(LOCATION_LINE, locLine);
|
||||
|
||||
profile.field(PROFILE_LOCATION, location);
|
||||
|
||||
locations.put(method, locId);
|
||||
}
|
||||
|
||||
sample.field(SAMPLE_LOCATION_ID, locations.get(method));
|
||||
}
|
||||
|
||||
profile.field(PROFILE_SAMPLE, sample);
|
||||
|
||||
previousTime = jfrSample.time;
|
||||
}
|
||||
|
||||
out.write(profile.buffer(), 0, profile.size());
|
||||
}
|
||||
|
||||
private byte[] getMethodName(final long methodId, final byte methodType) {
|
||||
final MethodRef ref = reader.methods.get(methodId);
|
||||
if (null == ref) {
|
||||
return METHOD_UNKNOWN;
|
||||
}
|
||||
|
||||
final ClassRef classRef = reader.classes.get(ref.cls);
|
||||
final byte[] className = reader.symbols.get(classRef.name);
|
||||
final byte[] methodName = reader.symbols.get(ref.name);
|
||||
|
||||
if ((methodType >= FlameGraph.FRAME_NATIVE && methodType <= FlameGraph.FRAME_KERNEL) || className == null || className.length == 0) {
|
||||
// Native method
|
||||
return methodName;
|
||||
} else {
|
||||
// JVM method
|
||||
final byte[] fullName = new byte[className.length + 1 + methodName.length];
|
||||
System.arraycopy(className, 0, fullName, 0, className.length);
|
||||
fullName[className.length] = '.';
|
||||
System.arraycopy(methodName, 0, fullName, className.length + 1, methodName.length);
|
||||
return fullName;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
System.out.println("Usage: java " + jfr2pprof.class.getName() + " input.jfr output.pprof");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
File dst = new File(args[1]);
|
||||
if (dst.isDirectory()) {
|
||||
dst = new File(dst, new File(args[0]).getName().replace(".jfr", ".pprof"));
|
||||
}
|
||||
|
||||
try (final JfrReader jfr = new JfrReader(args[0]);
|
||||
final FileOutputStream out = new FileOutputStream(dst)) {
|
||||
new jfr2pprof(jfr).dump(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package one.convert;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Arguments {
|
||||
public String title;
|
||||
public String highlight;
|
||||
public String output;
|
||||
public String state;
|
||||
public Pattern include;
|
||||
public Pattern exclude;
|
||||
public double minwidth;
|
||||
public double grain;
|
||||
public double tail = 0.1;
|
||||
public int skip;
|
||||
public boolean help;
|
||||
public boolean reverse;
|
||||
public boolean inverted;
|
||||
public boolean diff;
|
||||
public boolean cpu;
|
||||
public boolean cpuTime;
|
||||
public boolean wall;
|
||||
public boolean alloc;
|
||||
public boolean nativemem;
|
||||
public boolean nativelock;
|
||||
public boolean leak;
|
||||
public boolean live;
|
||||
public boolean lock;
|
||||
public boolean trace;
|
||||
public boolean threads;
|
||||
public boolean classify;
|
||||
public boolean total;
|
||||
public boolean lines;
|
||||
public boolean bci;
|
||||
public boolean simple;
|
||||
public boolean norm;
|
||||
public boolean dot;
|
||||
public long from;
|
||||
public long to;
|
||||
public long latency = -1;
|
||||
public final List<String> files = new ArrayList<>();
|
||||
|
||||
public Arguments(String... args) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
String fieldName;
|
||||
if (arg.startsWith("--")) {
|
||||
fieldName = toCamelCase(arg.substring(2));
|
||||
} else if (arg.startsWith("-") && arg.length() == 2) {
|
||||
fieldName = alias(arg.charAt(1));
|
||||
} else {
|
||||
files.add(arg);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
Field f = Arguments.class.getDeclaredField(fieldName);
|
||||
if ((f.getModifiers() & (Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL)) != 0) {
|
||||
throw new IllegalArgumentException(arg);
|
||||
}
|
||||
|
||||
Class<?> type = f.getType();
|
||||
if (type == String.class) {
|
||||
f.set(this, args[++i]);
|
||||
} else if (type == boolean.class) {
|
||||
f.setBoolean(this, true);
|
||||
} else if (type == int.class) {
|
||||
f.setInt(this, Integer.parseInt(args[++i]));
|
||||
} else if (type == double.class) {
|
||||
f.setDouble(this, parseRatio(args[++i]));
|
||||
} else if (type == long.class) {
|
||||
f.setLong(this, parseTimestamp(args[++i]));
|
||||
} else if (type == Pattern.class) {
|
||||
f.set(this, Pattern.compile(args[++i]));
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new IllegalArgumentException(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String alias(char c) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
return "help";
|
||||
case 'o':
|
||||
return "output";
|
||||
case 'r':
|
||||
return "reverse";
|
||||
case 'i':
|
||||
return "inverted";
|
||||
case 'I':
|
||||
return "include";
|
||||
case 'X':
|
||||
return "exclude";
|
||||
case 't':
|
||||
return "threads";
|
||||
case 's':
|
||||
return "state";
|
||||
default:
|
||||
return String.valueOf(c);
|
||||
}
|
||||
}
|
||||
|
||||
private static String toCamelCase(String name) {
|
||||
for (int i; (i = name.lastIndexOf('-', name.length() - 2)) >= 0; ) {
|
||||
name = name.substring(0, i) + Character.toUpperCase(name.charAt(i + 1)) + name.substring(i + 2);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
// Absolute floating point value or percentage followed by %
|
||||
private static double parseRatio(String value) {
|
||||
if (value.endsWith("%")) {
|
||||
return Double.parseDouble(value.substring(0, value.length() - 1)) / 100;
|
||||
}
|
||||
return Double.parseDouble(value);
|
||||
}
|
||||
|
||||
// Milliseconds or HH:mm:ss.S or yyyy-MM-dd'T'HH:mm:ss.S
|
||||
private static long parseTimestamp(String time) {
|
||||
if (time.indexOf(':') < 0) {
|
||||
return Long.parseLong(time);
|
||||
}
|
||||
|
||||
GregorianCalendar cal = new GregorianCalendar();
|
||||
StringTokenizer st = new StringTokenizer(time, "-:.T");
|
||||
|
||||
if (time.indexOf('T') > 0) {
|
||||
cal.set(Calendar.YEAR, Integer.parseInt(st.nextToken()));
|
||||
cal.set(Calendar.MONTH, Integer.parseInt(st.nextToken()) - 1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
cal.set(Calendar.HOUR_OF_DAY, st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0);
|
||||
cal.set(Calendar.MINUTE, st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0);
|
||||
cal.set(Calendar.SECOND, st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0);
|
||||
cal.set(Calendar.MILLISECOND, st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0);
|
||||
|
||||
return cal.getTimeInMillis();
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package one.convert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BidirectionalIndex<T> extends Index<T> {
|
||||
private final ArrayList<T> reverseIndex;
|
||||
|
||||
public BidirectionalIndex(Class<T> cls, T empty) {
|
||||
this(cls, empty, 256);
|
||||
}
|
||||
|
||||
public BidirectionalIndex(Class<T> cls, T empty, int initialCapacity) {
|
||||
super(cls, empty, initialCapacity);
|
||||
this.reverseIndex = new ArrayList<>(initialCapacity);
|
||||
this.reverseIndex.add(empty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int index(T key) {
|
||||
assert super.size() == reverseIndex.size();
|
||||
int idx = super.index(key);
|
||||
if (idx < reverseIndex.size()) {
|
||||
// Key already exists
|
||||
return idx;
|
||||
}
|
||||
assert idx == reverseIndex.size();
|
||||
reverseIndex.add(key);
|
||||
return idx;
|
||||
}
|
||||
|
||||
public T getKey(int idx) {
|
||||
return reverseIndex.get(idx);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package one.convert;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CallStack {
|
||||
String[] names = new String[16];
|
||||
byte[] types = new byte[16];
|
||||
int size;
|
||||
|
||||
public void push(String name, byte type) {
|
||||
if (size >= names.length) {
|
||||
names = Arrays.copyOf(names, size * 2);
|
||||
types = Arrays.copyOf(types, size * 2);
|
||||
}
|
||||
names[size] = name;
|
||||
types[size] = type;
|
||||
size++;
|
||||
}
|
||||
|
||||
public void pop() {
|
||||
size--;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright The async-profiler authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package one.convert;
|
||||
|
||||
import one.jfr.StackTrace;
|
||||
|
||||
import static one.convert.Frame.*;
|
||||
|
||||
abstract class Classifier {
|
||||
|
||||
enum Category {
|
||||
GC("[gc]", TYPE_CPP),
|
||||
JIT("[jit]", TYPE_CPP),
|
||||
VM("[vm]", TYPE_CPP),
|
||||
VTABLE_STUBS("[vtable_stubs]", TYPE_NATIVE),
|
||||
NATIVE("[native]", TYPE_NATIVE),
|
||||
INTERPRETER("[Interpreter]", TYPE_NATIVE),
|
||||
C1_COMP("[c1_comp]", TYPE_C1_COMPILED),
|
||||
C2_COMP("[c2_comp]", TYPE_INLINED),
|
||||
ADAPTER("[c2i_adapter]", TYPE_INLINED),
|
||||
CLASS_INIT("[class_init]", TYPE_CPP),
|
||||
CLASS_LOAD("[class_load]", TYPE_CPP),
|
||||
CLASS_RESOLVE("[class_resolve]", TYPE_CPP),
|
||||
CLASS_VERIFY("[class_verify]", TYPE_CPP),
|
||||
LAMBDA_INIT("[lambda_init]", TYPE_CPP);
|
||||
|
||||
final String title;
|
||||
final byte type;
|
||||
|
||||
Category(String title, byte type) {
|
||||
this.title = title;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public Category getCategory(StackTrace stackTrace) {
|
||||
long[] methods = stackTrace.methods;
|
||||
byte[] types = stackTrace.types;
|
||||
|
||||
Category category;
|
||||
if ((category = detectGcJit(methods, types)) == null &&
|
||||
(category = detectClassLoading(methods, types)) == null) {
|
||||
category = detectOther(methods, types);
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
private Category detectGcJit(long[] methods, byte[] types) {
|
||||
boolean vmThread = false;
|
||||
for (int i = types.length; --i >= 0; ) {
|
||||
if (types[i] == TYPE_CPP) {
|
||||
switch (getMethodName(methods[i], types[i])) {
|
||||
case "CompileBroker::compiler_thread_loop":
|
||||
return Category.JIT;
|
||||
case "GCTaskThread::run":
|
||||
case "WorkerThread::run":
|
||||
return Category.GC;
|
||||
case "java_start":
|
||||
case "thread_native_entry":
|
||||
vmThread = true;
|
||||
break;
|
||||
}
|
||||
} else if (types[i] != TYPE_NATIVE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return vmThread ? Category.VM : null;
|
||||
}
|
||||
|
||||
private Category detectClassLoading(long[] methods, byte[] types) {
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
String methodName = getMethodName(methods[i], types[i]);
|
||||
if (methodName.equals("Verifier::verify")) {
|
||||
return Category.CLASS_VERIFY;
|
||||
} else if (methodName.startsWith("InstanceKlass::initialize")) {
|
||||
return Category.CLASS_INIT;
|
||||
} else if (methodName.startsWith("LinkResolver::") ||
|
||||
methodName.startsWith("InterpreterRuntime::resolve") ||
|
||||
methodName.startsWith("SystemDictionary::resolve")) {
|
||||
return Category.CLASS_RESOLVE;
|
||||
} else if (methodName.endsWith("ClassLoader.loadClass")) {
|
||||
return Category.CLASS_LOAD;
|
||||
} else if (methodName.endsWith("LambdaMetafactory.metafactory") ||
|
||||
methodName.endsWith("LambdaMetafactory.altMetafactory")) {
|
||||
return Category.LAMBDA_INIT;
|
||||
} else if (methodName.endsWith("table stub")) {
|
||||
return Category.VTABLE_STUBS;
|
||||
} else if (methodName.equals("Interpreter")) {
|
||||
return Category.INTERPRETER;
|
||||
} else if (methodName.startsWith("I2C/C2I")) {
|
||||
return i + 1 < types.length && types[i + 1] == TYPE_INTERPRETED ? Category.INTERPRETER : Category.ADAPTER;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Category detectOther(long[] methods, byte[] types) {
|
||||
boolean inJava = true;
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
switch (types[i]) {
|
||||
case TYPE_INTERPRETED:
|
||||
return inJava ? Category.INTERPRETER : Category.NATIVE;
|
||||
case TYPE_JIT_COMPILED:
|
||||
return inJava ? Category.C2_COMP : Category.NATIVE;
|
||||
case TYPE_INLINED:
|
||||
inJava = true;
|
||||
break;
|
||||
case TYPE_NATIVE: {
|
||||
String methodName = getMethodName(methods[i], types[i]);
|
||||
if (methodName.startsWith("JVM_") || methodName.startsWith("Unsafe_") ||
|
||||
methodName.startsWith("MHN_") || methodName.startsWith("jni_")) {
|
||||
return Category.VM;
|
||||
}
|
||||
switch (methodName) {
|
||||
case "call_stub":
|
||||
case "deoptimization":
|
||||
case "unknown_Java":
|
||||
case "not_walkable_Java":
|
||||
case "InlineCacheBuffer":
|
||||
return Category.VM;
|
||||
}
|
||||
if (methodName.endsWith("_arraycopy") || methodName.contains("pthread_cond")) {
|
||||
break;
|
||||
}
|
||||
inJava = false;
|
||||
break;
|
||||
}
|
||||
case TYPE_CPP: {
|
||||
String methodName = getMethodName(methods[i], types[i]);
|
||||
if (methodName.startsWith("Runtime1::")) {
|
||||
return Category.C1_COMP;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_C1_COMPILED:
|
||||
return inJava ? Category.C1_COMP : Category.NATIVE;
|
||||
}
|
||||
}
|
||||
return Category.NATIVE;
|
||||
}
|
||||
|
||||
protected abstract String getMethodName(long method, byte type);
|
||||
}
|
||||