@parca/profile 0.16.198 → 0.16.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/Callgraph/index.d.ts +0 -1
- package/dist/GraphTooltip/ExpandOnHoverValue.d.ts +0 -1
- package/dist/GraphTooltip/index.d.ts +0 -1
- package/dist/GraphTooltipArrow/ExpandOnHoverValue.d.ts +6 -0
- package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +4 -0
- package/dist/GraphTooltipArrow/index.d.ts +43 -0
- package/dist/GraphTooltipArrow/index.js +244 -0
- package/dist/MatchersInput/SuggestionItem.d.ts +0 -1
- package/dist/MatchersInput/SuggestionsList.d.ts +0 -1
- package/dist/MatchersInput/index.d.ts +0 -1
- package/dist/MetricsCircle/index.d.ts +0 -1
- package/dist/MetricsGraph/MetricsTooltip/index.d.ts +0 -1
- package/dist/MetricsGraph/index.d.ts +0 -1
- package/dist/MetricsSeries/index.d.ts +0 -1
- package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts +0 -1
- package/dist/ProfileExplorer/ProfileExplorerSingle.d.ts +0 -1
- package/dist/ProfileExplorer/index.d.ts +0 -1
- package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.d.ts +0 -1
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/ColorStackLegend.d.ts +10 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/ColorStackLegend.js +64 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts +48 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.js +150 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.d.ts +23 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.js +110 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/useNodeColor.d.ts +14 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/useNodeColor.js +26 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.d.ts +4 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.js +42 -0
- package/dist/ProfileIcicleGraph/index.d.ts +4 -3
- package/dist/ProfileIcicleGraph/index.js +7 -5
- package/dist/ProfileMetricsGraph/index.d.ts +0 -1
- package/dist/ProfileSelector/CompareButton.d.ts +0 -1
- package/dist/ProfileSelector/index.d.ts +0 -1
- package/dist/ProfileSource.d.ts +0 -1
- package/dist/ProfileTypeSelector/index.d.ts +0 -1
- package/dist/ProfileView/FilterByFunctionButton.d.ts +0 -1
- package/dist/ProfileView/ViewSelector.d.ts +0 -1
- package/dist/ProfileView/index.d.ts +2 -1
- package/dist/ProfileView/index.js +2 -2
- package/dist/ProfileViewWithData.d.ts +0 -1
- package/dist/ProfileViewWithData.js +15 -6
- package/dist/components/DiffLegend.d.ts +0 -1
- package/dist/components/ProfileShareButton/ResultBox.d.ts +0 -1
- package/dist/components/ProfileShareButton/index.d.ts +0 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -5
- package/src/GraphTooltipArrow/ExpandOnHoverValue.tsx +30 -0
- package/src/GraphTooltipArrow/index.tsx +564 -0
- package/src/ProfileIcicleGraph/IcicleGraphArrow/ColorStackLegend.tsx +109 -0
- package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.tsx +327 -0
- package/src/ProfileIcicleGraph/IcicleGraphArrow/index.tsx +212 -0
- package/src/ProfileIcicleGraph/IcicleGraphArrow/useNodeColor.ts +52 -0
- package/src/ProfileIcicleGraph/IcicleGraphArrow/utils.ts +51 -0
- package/src/ProfileIcicleGraph/index.tsx +34 -14
- package/src/ProfileView/index.tsx +4 -1
- package/src/ProfileViewWithData.tsx +20 -6
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Copyright 2022 The Parca Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import React, { useMemo } from 'react';
|
|
15
|
+
import cx from 'classnames';
|
|
16
|
+
import { useKeyDown } from '@parca/components';
|
|
17
|
+
import { selectBinaries, setHoveringRow, useAppDispatch, useAppSelector } from '@parca/store';
|
|
18
|
+
import { isSearchMatch, scaleLinear } from '@parca/utilities';
|
|
19
|
+
import { FIELD_CHILDREN, FIELD_CUMULATIVE, FIELD_DIFF, FIELD_FUNCTION_NAME, FIELD_MAPPING_FILE, } from './index';
|
|
20
|
+
import useNodeColor from './useNodeColor';
|
|
21
|
+
import { nodeLabel } from './utils';
|
|
22
|
+
export const RowHeight = 26;
|
|
23
|
+
export const IcicleGraphNodes = React.memo(function IcicleGraphNodesNoMemo({ table, childRows, mappingColors, x, y, xScale, total, totalWidth, level, path, setCurPath, curPath, sortBy, searchString, darkMode, compareMode, }) {
|
|
24
|
+
const cumulatives = table.getChild(FIELD_CUMULATIVE);
|
|
25
|
+
if (childRows === undefined || childRows.length === 0) {
|
|
26
|
+
return _jsx(_Fragment, {});
|
|
27
|
+
}
|
|
28
|
+
childRows =
|
|
29
|
+
curPath.length === 0
|
|
30
|
+
? childRows
|
|
31
|
+
: childRows.filter(c => nodeLabel(table, c, false) === curPath[0]);
|
|
32
|
+
let childrenCumulative = BigInt(0);
|
|
33
|
+
const childrenElements = [];
|
|
34
|
+
childRows.forEach((child, i) => {
|
|
35
|
+
const xStart = Math.floor(xScale(childrenCumulative));
|
|
36
|
+
const c = cumulatives?.get(child);
|
|
37
|
+
childrenCumulative += c;
|
|
38
|
+
childrenElements.push(_jsx(IcicleNode, { table: table, row: child, mappingColors: mappingColors, x: xStart, y: 0, totalWidth: totalWidth, height: RowHeight, path: path, setCurPath: setCurPath, level: level, curPath: curPath, total: total, xScale: xScale, sortBy: sortBy, searchString: searchString, darkMode: darkMode, compareMode: compareMode }, `node-${level}-${i}`));
|
|
39
|
+
});
|
|
40
|
+
return _jsx("g", { transform: `translate(${x}, ${y})`, children: childrenElements });
|
|
41
|
+
});
|
|
42
|
+
const icicleRectStyles = {
|
|
43
|
+
cursor: 'pointer',
|
|
44
|
+
transition: 'opacity .15s linear',
|
|
45
|
+
};
|
|
46
|
+
const fadedIcicleRectStyles = {
|
|
47
|
+
cursor: 'pointer',
|
|
48
|
+
transition: 'opacity .15s linear',
|
|
49
|
+
opacity: '0.5',
|
|
50
|
+
};
|
|
51
|
+
export const IcicleNode = React.memo(function IcicleNodeNoMemo({ table, row, mappingColors, x, y, height, setCurPath, curPath, level, path, total, totalWidth, xScale, isRoot = false, searchString, sortBy, darkMode, compareMode, }) {
|
|
52
|
+
const { isShiftDown } = useKeyDown();
|
|
53
|
+
const dispatch = useAppDispatch();
|
|
54
|
+
// get the columns to read from
|
|
55
|
+
const mappingColumn = table.getChild(FIELD_MAPPING_FILE);
|
|
56
|
+
const functionNameColumn = table.getChild(FIELD_FUNCTION_NAME);
|
|
57
|
+
const cumulativeColumn = table.getChild(FIELD_CUMULATIVE);
|
|
58
|
+
const diffColumn = table.getChild(FIELD_DIFF);
|
|
59
|
+
// get the actual values from the columns
|
|
60
|
+
const mappingFile = mappingColumn?.get(row);
|
|
61
|
+
const functionName = functionNameColumn?.get(row);
|
|
62
|
+
const cumulative = cumulativeColumn?.get(row);
|
|
63
|
+
const diff = diffColumn?.get(row);
|
|
64
|
+
const childRows = Array.from(table.getChild(FIELD_CHILDREN)?.get(row) ?? []);
|
|
65
|
+
// TODO: Maybe it's better to pass down the sorter function as prop instead of figuring this out here.
|
|
66
|
+
switch (sortBy) {
|
|
67
|
+
case FIELD_FUNCTION_NAME:
|
|
68
|
+
childRows.sort((a, b) => {
|
|
69
|
+
// TODO: Support fallthrough to comparing addresses or something
|
|
70
|
+
const afn = functionNameColumn?.get(a);
|
|
71
|
+
const bfn = functionNameColumn?.get(b);
|
|
72
|
+
return afn.localeCompare(bfn);
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
case FIELD_CUMULATIVE:
|
|
76
|
+
childRows.sort((a, b) => {
|
|
77
|
+
const aCumulative = cumulativeColumn?.get(a);
|
|
78
|
+
const bCumulative = cumulativeColumn?.get(b);
|
|
79
|
+
return Number(bCumulative - aCumulative);
|
|
80
|
+
});
|
|
81
|
+
break;
|
|
82
|
+
case FIELD_DIFF:
|
|
83
|
+
childRows.sort((a, b) => {
|
|
84
|
+
const aDiff = diffColumn?.get(a);
|
|
85
|
+
const bDiff = diffColumn?.get(b);
|
|
86
|
+
if (aDiff !== null && bDiff !== null) {
|
|
87
|
+
return Number(bDiff - aDiff);
|
|
88
|
+
}
|
|
89
|
+
if (aDiff === null && bDiff !== null) {
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
if (aDiff !== null && bDiff === null) {
|
|
93
|
+
return -1;
|
|
94
|
+
}
|
|
95
|
+
// both are null
|
|
96
|
+
return 0;
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
const binaries = useAppSelector(selectBinaries);
|
|
101
|
+
const colorResult = useNodeColor({
|
|
102
|
+
isDarkMode: darkMode,
|
|
103
|
+
compareMode,
|
|
104
|
+
cumulative,
|
|
105
|
+
diff,
|
|
106
|
+
mappingColors,
|
|
107
|
+
mappingFile,
|
|
108
|
+
functionName,
|
|
109
|
+
});
|
|
110
|
+
const name = useMemo(() => {
|
|
111
|
+
return isRoot ? 'root' : nodeLabel(table, row, binaries.length > 1);
|
|
112
|
+
}, [table, row, isRoot, binaries]);
|
|
113
|
+
const nextPath = path.concat([name]);
|
|
114
|
+
const isFaded = curPath.length > 0 && name !== curPath[curPath.length - 1];
|
|
115
|
+
const styles = isFaded ? fadedIcicleRectStyles : icicleRectStyles;
|
|
116
|
+
const nextLevel = level + 1;
|
|
117
|
+
const nextCurPath = curPath.length === 0 ? [] : curPath.slice(1);
|
|
118
|
+
const newXScale = nextCurPath.length === 0 && curPath.length === 1
|
|
119
|
+
? scaleLinear([0n, cumulative], [0, totalWidth])
|
|
120
|
+
: xScale;
|
|
121
|
+
const width = nextCurPath.length > 0 || (nextCurPath.length === 0 && curPath.length === 1)
|
|
122
|
+
? totalWidth
|
|
123
|
+
: xScale(cumulative);
|
|
124
|
+
const { isHighlightEnabled = false, isHighlighted = false } = useMemo(() => {
|
|
125
|
+
if (searchString === undefined || searchString === '') {
|
|
126
|
+
return { isHighlightEnabled: false };
|
|
127
|
+
}
|
|
128
|
+
return { isHighlightEnabled: true, isHighlighted: isSearchMatch(searchString, name) };
|
|
129
|
+
}, [searchString, name]);
|
|
130
|
+
if (width <= 1) {
|
|
131
|
+
return _jsx(_Fragment, { children: null });
|
|
132
|
+
}
|
|
133
|
+
const onMouseEnter = () => {
|
|
134
|
+
if (isShiftDown)
|
|
135
|
+
return;
|
|
136
|
+
dispatch(setHoveringRow({ row }));
|
|
137
|
+
};
|
|
138
|
+
const onMouseLeave = () => {
|
|
139
|
+
if (isShiftDown)
|
|
140
|
+
return;
|
|
141
|
+
dispatch(setHoveringRow(undefined));
|
|
142
|
+
};
|
|
143
|
+
return (_jsxs(_Fragment, { children: [_jsxs("g", { transform: `translate(${x + 1}, ${y + 1})`, style: styles, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onClick: () => {
|
|
144
|
+
setCurPath(nextPath);
|
|
145
|
+
}, children: [_jsx("rect", { x: 0, y: 0, width: width, height: height, style: {
|
|
146
|
+
fill: colorResult,
|
|
147
|
+
}, className: cx('stroke-white dark:stroke-gray-700', {
|
|
148
|
+
'opacity-50': isHighlightEnabled && !isHighlighted,
|
|
149
|
+
}) }), width > 5 && (_jsx("svg", { width: width - 5, height: height, children: _jsx("text", { x: 5, y: 15, style: { fontSize: '12px' }, children: name }) }))] }), childRows.length > 0 && (_jsx(IcicleGraphNodes, { table: table, row: row, mappingColors: mappingColors, childRows: childRows, x: x, y: RowHeight, xScale: newXScale, total: total, totalWidth: totalWidth, level: nextLevel, path: nextPath, curPath: nextCurPath, setCurPath: setCurPath, searchString: searchString, sortBy: sortBy, darkMode: darkMode, compareMode: compareMode }))] }));
|
|
150
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table } from 'apache-arrow';
|
|
3
|
+
import { type NavigateFunction } from '@parca/utilities';
|
|
4
|
+
export declare const FIELD_MAPPING_FILE = "mapping_file";
|
|
5
|
+
export declare const FIELD_MAPPING_BUILD_ID = "mapping_build_id";
|
|
6
|
+
export declare const FIELD_LOCATION_ADDRESS = "location_address";
|
|
7
|
+
export declare const FIELD_FUNCTION_NAME = "function_name";
|
|
8
|
+
export declare const FIELD_FUNCTION_FILE_NAME = "function_file_name";
|
|
9
|
+
export declare const FIELD_CHILDREN = "children";
|
|
10
|
+
export declare const FIELD_CUMULATIVE = "cumulative";
|
|
11
|
+
export declare const FIELD_DIFF = "diff";
|
|
12
|
+
interface IcicleGraphArrowProps {
|
|
13
|
+
table: Table<any>;
|
|
14
|
+
total: bigint;
|
|
15
|
+
filtered: bigint;
|
|
16
|
+
sampleUnit: string;
|
|
17
|
+
width?: number;
|
|
18
|
+
curPath: string[];
|
|
19
|
+
setCurPath: (path: string[]) => void;
|
|
20
|
+
navigateTo?: NavigateFunction;
|
|
21
|
+
}
|
|
22
|
+
export declare const IcicleGraphArrow: React.NamedExoticComponent<IcicleGraphArrowProps>;
|
|
23
|
+
export default IcicleGraphArrow;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Copyright 2022 The Parca Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
15
|
+
import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
|
|
16
|
+
import { getColorForFeature, selectDarkMode, setHoveringNode, useAppDispatch, useAppSelector, } from '@parca/store';
|
|
17
|
+
import { getLastItem, scaleLinear, selectQueryParam, } from '@parca/utilities';
|
|
18
|
+
import GraphTooltipArrow from '../../GraphTooltipArrow';
|
|
19
|
+
import ColorStackLegend from './ColorStackLegend';
|
|
20
|
+
import { IcicleNode, RowHeight } from './IcicleGraphNodes';
|
|
21
|
+
import { extractFeature } from './utils';
|
|
22
|
+
export const FIELD_MAPPING_FILE = 'mapping_file';
|
|
23
|
+
export const FIELD_MAPPING_BUILD_ID = 'mapping_build_id';
|
|
24
|
+
export const FIELD_LOCATION_ADDRESS = 'location_address';
|
|
25
|
+
export const FIELD_FUNCTION_NAME = 'function_name';
|
|
26
|
+
export const FIELD_FUNCTION_FILE_NAME = 'function_file_name';
|
|
27
|
+
export const FIELD_CHILDREN = 'children';
|
|
28
|
+
export const FIELD_CUMULATIVE = 'cumulative';
|
|
29
|
+
export const FIELD_DIFF = 'diff';
|
|
30
|
+
export const IcicleGraphArrow = memo(function IcicleGraphArrow({ table, total, filtered, width, setCurPath, curPath, sampleUnit, navigateTo, }) {
|
|
31
|
+
const dispatch = useAppDispatch();
|
|
32
|
+
const [colorProfile] = useUserPreference(USER_PREFERENCES.FLAMEGRAPH_COLOR_PROFILE.key);
|
|
33
|
+
const isDarkMode = useAppSelector(selectDarkMode);
|
|
34
|
+
const [height, setHeight] = useState(0);
|
|
35
|
+
const sortBy = FIELD_FUNCTION_NAME; // TODO: make this configurable via UI
|
|
36
|
+
const svg = useRef(null);
|
|
37
|
+
const ref = useRef(null);
|
|
38
|
+
const currentSearchString = selectQueryParam('search_string') ?? '';
|
|
39
|
+
const compareMode = selectQueryParam('compare_a') === 'true' && selectQueryParam('compare_b') === 'true';
|
|
40
|
+
const mappings = useMemo(() => {
|
|
41
|
+
// Read the mappings from the dictionary that contains all mapping strings.
|
|
42
|
+
// This is great, as might only have a dozen or so mappings,
|
|
43
|
+
// and don't need to read through all the rows (potentially thousands).
|
|
44
|
+
const mappingsDict = table.getChild(FIELD_MAPPING_FILE);
|
|
45
|
+
const mappings = mappingsDict?.data
|
|
46
|
+
.map(mapping => {
|
|
47
|
+
if (mapping.dictionary == null) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const len = mapping.dictionary.length;
|
|
51
|
+
const entries = [];
|
|
52
|
+
for (let i = 0; i < len; i++) {
|
|
53
|
+
entries.push(getLastItem(mapping.dictionary.get(i)) ?? '');
|
|
54
|
+
}
|
|
55
|
+
return entries;
|
|
56
|
+
})
|
|
57
|
+
.flat() ?? [];
|
|
58
|
+
// We add a EVERYTHING ELSE mapping to the list.
|
|
59
|
+
mappings.push('');
|
|
60
|
+
// We look through the function names to find out if there's a runtime function.
|
|
61
|
+
// Again, we only read through the dictionary, which is much faster than reading through all the rows.
|
|
62
|
+
// We stop as soon as we find a runtime function.
|
|
63
|
+
const functionNamesDict = table.getChild(FIELD_FUNCTION_NAME);
|
|
64
|
+
functionNamesDict?.data.forEach(fn => {
|
|
65
|
+
if (fn.dictionary == null) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const len = fn.dictionary.length;
|
|
69
|
+
for (let i = 0; i < len; i++) {
|
|
70
|
+
const fn = functionNamesDict?.get(i);
|
|
71
|
+
if (fn?.startsWith('runtime') === true) {
|
|
72
|
+
mappings.push('runtime');
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// We sort the mappings alphabetically to make sure that the order is always the same.
|
|
78
|
+
mappings.sort((a, b) => a.localeCompare(b));
|
|
79
|
+
return mappings;
|
|
80
|
+
}, [table]);
|
|
81
|
+
// TODO: Somehow figure out how to add runtime to this, if stacks are present.
|
|
82
|
+
// Potentially read the function name dictionary and check if it contains strings starting with runtime.
|
|
83
|
+
const mappingFeatures = useMemo(() => {
|
|
84
|
+
return mappings.map(mapping => extractFeature(mapping));
|
|
85
|
+
}, [mappings]);
|
|
86
|
+
// TODO: Unify with mappingFeatures
|
|
87
|
+
const mappingColors = useMemo(() => {
|
|
88
|
+
const colors = {};
|
|
89
|
+
Object.entries(mappingFeatures).forEach(([_, feature]) => {
|
|
90
|
+
colors[feature.name] = getColorForFeature(feature.name, isDarkMode, colorProfile);
|
|
91
|
+
});
|
|
92
|
+
return colors;
|
|
93
|
+
}, [colorProfile, isDarkMode, mappingFeatures]);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (ref.current != null) {
|
|
96
|
+
setHeight(ref?.current.getBoundingClientRect().height);
|
|
97
|
+
}
|
|
98
|
+
}, [width]);
|
|
99
|
+
const xScale = useMemo(() => {
|
|
100
|
+
if (width === undefined) {
|
|
101
|
+
return () => 0;
|
|
102
|
+
}
|
|
103
|
+
return scaleLinear([0n, total], [0, width]);
|
|
104
|
+
}, [total, width]);
|
|
105
|
+
if (table.numRows === 0 || width === undefined) {
|
|
106
|
+
return _jsx(_Fragment, {});
|
|
107
|
+
}
|
|
108
|
+
return (_jsxs("div", { onMouseLeave: () => dispatch(setHoveringNode(undefined)), children: [_jsx(ColorStackLegend, { mappingColors: mappingColors, navigateTo: navigateTo, compareMode: compareMode }), _jsx(GraphTooltipArrow, { table: table, unit: sampleUnit, total: total, totalUnfiltered: total + filtered, contextElement: svg.current }), _jsx("svg", { className: "font-robotoMono", width: width, height: height, preserveAspectRatio: "xMinYMid", ref: svg, children: _jsx("g", { ref: ref, children: _jsx("g", { transform: 'translate(0, 0)', children: _jsx(IcicleNode, { table: table, row: 0, mappingColors: mappingColors, x: 0, y: 0, totalWidth: width, height: RowHeight, setCurPath: setCurPath, curPath: curPath, total: total, xScale: xScale, path: [], level: 0, isRoot: true, searchString: currentSearchString, sortBy: sortBy, darkMode: isDarkMode, compareMode: compareMode }) }) }) })] }));
|
|
109
|
+
});
|
|
110
|
+
export default IcicleGraphArrow;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface mappingColors {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}
|
|
4
|
+
interface Props {
|
|
5
|
+
isDarkMode: boolean;
|
|
6
|
+
compareMode: boolean;
|
|
7
|
+
cumulative: bigint;
|
|
8
|
+
diff: bigint | null;
|
|
9
|
+
mappingColors: mappingColors;
|
|
10
|
+
functionName: string | null;
|
|
11
|
+
mappingFile: string | null;
|
|
12
|
+
}
|
|
13
|
+
declare const useNodeColor: ({ isDarkMode, compareMode, cumulative, diff, mappingColors, functionName, mappingFile, }: Props) => string;
|
|
14
|
+
export default useNodeColor;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2022 The Parca Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { EVERYTHING_ELSE } from '@parca/store';
|
|
14
|
+
import { diffColor, getLastItem } from '@parca/utilities';
|
|
15
|
+
const useNodeColor = ({ isDarkMode, compareMode, cumulative, diff, mappingColors, functionName, mappingFile, }) => {
|
|
16
|
+
if (compareMode) {
|
|
17
|
+
return diffColor(diff ?? 0n, cumulative, isDarkMode);
|
|
18
|
+
}
|
|
19
|
+
// To get the color we first check if the function name starts with 'runtime'.
|
|
20
|
+
// If it does, we color it as runtime. Otherwise, we check the mapping file.
|
|
21
|
+
// If there is no mapping file, we color it as 'everything else'.
|
|
22
|
+
return functionName?.startsWith('runtime') === true
|
|
23
|
+
? mappingColors.runtime
|
|
24
|
+
: mappingColors[getLastItem(mappingFile ?? '') ?? EVERYTHING_ELSE];
|
|
25
|
+
};
|
|
26
|
+
export default useNodeColor;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright 2022 The Parca Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { EVERYTHING_ELSE, FEATURE_TYPES } from '@parca/store';
|
|
14
|
+
import { getLastItem } from '@parca/utilities';
|
|
15
|
+
import { hexifyAddress } from '../../utils';
|
|
16
|
+
import { FIELD_FUNCTION_NAME, FIELD_LOCATION_ADDRESS, FIELD_MAPPING_FILE } from './index';
|
|
17
|
+
export function nodeLabel(table, row, showBinaryName) {
|
|
18
|
+
const functionName = table.getChild(FIELD_FUNCTION_NAME)?.get(row);
|
|
19
|
+
if (functionName !== null && functionName !== '') {
|
|
20
|
+
return functionName;
|
|
21
|
+
}
|
|
22
|
+
let mappingString = '';
|
|
23
|
+
if (showBinaryName) {
|
|
24
|
+
const mappingFile = table.getChild(FIELD_MAPPING_FILE)?.get(row) ?? '';
|
|
25
|
+
const binary = getLastItem(mappingFile ?? undefined);
|
|
26
|
+
if (binary != null)
|
|
27
|
+
mappingString = `[${binary}]`;
|
|
28
|
+
}
|
|
29
|
+
const addressBigInt = table.getChild(FIELD_LOCATION_ADDRESS)?.get(row);
|
|
30
|
+
const address = hexifyAddress(addressBigInt);
|
|
31
|
+
const fallback = `${mappingString}${address}`;
|
|
32
|
+
return fallback === '' ? '<unknown>' : fallback;
|
|
33
|
+
}
|
|
34
|
+
export const extractFeature = (mapping) => {
|
|
35
|
+
if (mapping.startsWith('runtime') || mapping === 'root') {
|
|
36
|
+
return { name: 'runtime', type: FEATURE_TYPES.Runtime };
|
|
37
|
+
}
|
|
38
|
+
if (mapping != null && mapping !== '') {
|
|
39
|
+
return { name: mapping, type: FEATURE_TYPES.Binary };
|
|
40
|
+
}
|
|
41
|
+
return { name: EVERYTHING_ELSE, type: FEATURE_TYPES.Misc };
|
|
42
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { Table } from 'apache-arrow';
|
|
2
2
|
import { Flamegraph } from '@parca/client';
|
|
3
3
|
import { type NavigateFunction } from '@parca/utilities';
|
|
4
4
|
export type ResizeHandler = (width: number, height: number) => void;
|
|
5
5
|
interface ProfileIcicleGraphProps {
|
|
6
6
|
width?: number;
|
|
7
|
-
graph
|
|
7
|
+
graph?: Flamegraph;
|
|
8
|
+
table?: Table<any>;
|
|
8
9
|
total: bigint;
|
|
9
10
|
filtered: bigint;
|
|
10
11
|
sampleUnit: string;
|
|
@@ -14,5 +15,5 @@ interface ProfileIcicleGraphProps {
|
|
|
14
15
|
loading: boolean;
|
|
15
16
|
setActionButtons?: (buttons: JSX.Element) => void;
|
|
16
17
|
}
|
|
17
|
-
declare const ProfileIcicleGraph: ({ graph, total, filtered, curPath, setNewCurPath, sampleUnit, navigateTo, loading, setActionButtons, }: ProfileIcicleGraphProps) => JSX.Element;
|
|
18
|
+
declare const ProfileIcicleGraph: ({ graph, table, total, filtered, curPath, setNewCurPath, sampleUnit, navigateTo, loading, setActionButtons, }: ProfileIcicleGraphProps) => JSX.Element;
|
|
18
19
|
export default ProfileIcicleGraph;
|
|
@@ -16,16 +16,18 @@ import { Button } from '@parca/components';
|
|
|
16
16
|
import { useContainerDimensions } from '@parca/hooks';
|
|
17
17
|
import { divide, selectQueryParam } from '@parca/utilities';
|
|
18
18
|
import DiffLegend from '../components/DiffLegend';
|
|
19
|
-
import
|
|
19
|
+
import IcicleGraph from './IcicleGraph';
|
|
20
|
+
import IcicleGraphArrow from './IcicleGraphArrow';
|
|
20
21
|
const numberFormatter = new Intl.NumberFormat('en-US');
|
|
21
|
-
const ProfileIcicleGraph = ({ graph, total, filtered, curPath, setNewCurPath, sampleUnit, navigateTo, loading, setActionButtons, }) => {
|
|
22
|
+
const ProfileIcicleGraph = ({ graph, table, total, filtered, curPath, setNewCurPath, sampleUnit, navigateTo, loading, setActionButtons, }) => {
|
|
22
23
|
const compareMode = selectQueryParam('compare_a') === 'true' && selectQueryParam('compare_b') === 'true';
|
|
23
24
|
const { ref, dimensions } = useContainerDimensions();
|
|
24
25
|
const [totalFormatted, totalUnfilteredFormatted, isTrimmed, trimmedFormatted, trimmedPercentage, isFiltered, filteredPercentage,] = useMemo(() => {
|
|
25
26
|
if (graph === undefined) {
|
|
26
27
|
return ['0', '0', false, '0', '0', false, '0', '0'];
|
|
27
28
|
}
|
|
28
|
-
const trimmed = graph.trimmed;
|
|
29
|
+
// const trimmed = graph.trimmed;
|
|
30
|
+
const trimmed = 0n;
|
|
29
31
|
const totalUnfiltered = total + filtered;
|
|
30
32
|
// safeguard against division by zero
|
|
31
33
|
const totalUnfilteredDivisor = totalUnfiltered > 0 ? totalUnfiltered : 1n;
|
|
@@ -45,13 +47,13 @@ const ProfileIcicleGraph = ({ graph, total, filtered, curPath, setNewCurPath, sa
|
|
|
45
47
|
}
|
|
46
48
|
setActionButtons(_jsx(_Fragment, { children: _jsx(Button, { color: "neutral", onClick: () => setNewCurPath([]), disabled: curPath.length === 0, variant: "neutral", children: "Reset View" }) }));
|
|
47
49
|
}, [setNewCurPath, curPath, setActionButtons]);
|
|
48
|
-
if (graph === undefined)
|
|
50
|
+
if (graph === undefined && table === undefined)
|
|
49
51
|
return _jsx("div", { children: "no data..." });
|
|
50
52
|
if (total === 0n && !loading)
|
|
51
53
|
return _jsx(_Fragment, { children: "Profile has no samples" });
|
|
52
54
|
if (isTrimmed) {
|
|
53
55
|
console.info(`Trimmed ${trimmedFormatted} (${trimmedPercentage}%) too small values.`);
|
|
54
56
|
}
|
|
55
|
-
return (_jsxs("div", { className: "relative", children: [compareMode && _jsx(DiffLegend, {}),
|
|
57
|
+
return (_jsxs("div", { className: "relative", children: [compareMode && _jsx(DiffLegend, {}), _jsxs("div", { ref: ref, children: [graph !== undefined && (_jsx(IcicleGraph, { width: dimensions?.width, graph: graph, total: total, filtered: filtered, curPath: curPath, setCurPath: setNewCurPath, sampleUnit: sampleUnit, navigateTo: navigateTo })), table !== undefined && (_jsx(IcicleGraphArrow, { width: dimensions?.width, table: table, total: total, filtered: filtered, curPath: curPath, setCurPath: setNewCurPath, sampleUnit: sampleUnit, navigateTo: navigateTo }))] }), _jsxs("p", { className: "my-2 text-xs", children: ["Showing ", totalFormatted, ' ', isFiltered ? (_jsxs("span", { children: ["(", filteredPercentage, "%) filtered of ", totalUnfilteredFormatted, ' '] })) : (_jsx(_Fragment, {})), "values.", ' '] })] }));
|
|
56
58
|
};
|
|
57
59
|
export default ProfileIcicleGraph;
|
package/dist/ProfileSource.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Table } from 'apache-arrow';
|
|
2
2
|
import { Callgraph as CallgraphType, Flamegraph, QueryServiceClient, Top } from '@parca/client';
|
|
3
3
|
import { ProfileSource } from '../ProfileSource';
|
|
4
4
|
type NavigateFunction = (path: string, queryParams: any, options?: {
|
|
@@ -7,6 +7,7 @@ type NavigateFunction = (path: string, queryParams: any, options?: {
|
|
|
7
7
|
export interface FlamegraphData {
|
|
8
8
|
loading: boolean;
|
|
9
9
|
data?: Flamegraph;
|
|
10
|
+
table?: Table<any>;
|
|
10
11
|
total?: bigint;
|
|
11
12
|
filtered?: bigint;
|
|
12
13
|
error?: any;
|
|
@@ -124,10 +124,10 @@ export const ProfileView = ({ total, filtered, flamegraphData, topTableData, cal
|
|
|
124
124
|
const getDashboardItemByType = ({ type, isHalfScreen, setActionButtons, }) => {
|
|
125
125
|
switch (type) {
|
|
126
126
|
case 'icicle': {
|
|
127
|
-
return flamegraphData?.data
|
|
127
|
+
return flamegraphData?.table !== undefined || flamegraphData.data !== undefined ? (_jsx(ConditionalWrapper, { condition: perf?.onRender != null, WrapperComponent: Profiler, wrapperProps: {
|
|
128
128
|
id: 'icicleGraph',
|
|
129
129
|
onRender: perf?.onRender,
|
|
130
|
-
}, children: _jsx(ProfileIcicleGraph, { curPath: curPath, setNewCurPath: setNewCurPath, graph: flamegraphData.data, total: total, filtered: filtered, sampleUnit: sampleUnit, navigateTo: navigateTo, loading: flamegraphData.loading, setActionButtons: setActionButtons }) })) : (_jsx(_Fragment, { children: " " }));
|
|
130
|
+
}, children: _jsx(ProfileIcicleGraph, { curPath: curPath, setNewCurPath: setNewCurPath, table: flamegraphData.table, graph: flamegraphData.data, total: total, filtered: filtered, sampleUnit: sampleUnit, navigateTo: navigateTo, loading: flamegraphData.loading, setActionButtons: setActionButtons }) })) : (_jsx(_Fragment, { children: " " }));
|
|
131
131
|
}
|
|
132
132
|
case 'callgraph': {
|
|
133
133
|
return callgraphData?.data !== undefined &&
|
|
@@ -12,9 +12,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { useEffect, useMemo, useState } from 'react';
|
|
15
|
+
import { tableFromIPC } from 'apache-arrow';
|
|
15
16
|
import { QueryRequest_ReportType } from '@parca/client';
|
|
16
17
|
import { useGrpcMetadata, useParcaContext, useURLState } from '@parca/components';
|
|
17
|
-
import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
|
|
18
|
+
import { USER_PREFERENCES, useUIFeatureFlag, useUserPreference } from '@parca/hooks';
|
|
18
19
|
import { saveAsBlob } from '@parca/utilities';
|
|
19
20
|
import { ProfileView } from './ProfileView';
|
|
20
21
|
import { useQuery } from './useQuery';
|
|
@@ -23,6 +24,7 @@ export const ProfileViewWithData = ({ queryClient, profileSource, navigateTo, })
|
|
|
23
24
|
const metadata = useGrpcMetadata();
|
|
24
25
|
const [dashboardItems] = useURLState({ param: 'dashboard_items', navigateTo });
|
|
25
26
|
const [enableTrimming] = useUserPreference(USER_PREFERENCES.ENABLE_GRAPH_TRIMMING.key);
|
|
27
|
+
const [arrowFlamegraphEnabled] = useUIFeatureFlag('flamegraph-arrow');
|
|
26
28
|
const [pprofDownloading, setPprofDownloading] = useState(false);
|
|
27
29
|
const nodeTrimThreshold = useMemo(() => {
|
|
28
30
|
if (!enableTrimming) {
|
|
@@ -35,7 +37,10 @@ export const ProfileViewWithData = ({ queryClient, profileSource, navigateTo, })
|
|
|
35
37
|
width = width - 12 - 16 - 12;
|
|
36
38
|
return (1 / width) * 100;
|
|
37
39
|
}, [enableTrimming]);
|
|
38
|
-
const
|
|
40
|
+
const reportType = arrowFlamegraphEnabled
|
|
41
|
+
? QueryRequest_ReportType.FLAMEGRAPH_ARROW
|
|
42
|
+
: QueryRequest_ReportType.FLAMEGRAPH_TABLE;
|
|
43
|
+
const { isLoading: flamegraphLoading, response: flamegraphResponse, error: flamegraphError, } = useQuery(queryClient, profileSource, reportType, {
|
|
39
44
|
skip: !dashboardItems.includes('icicle'),
|
|
40
45
|
nodeTrimThreshold,
|
|
41
46
|
});
|
|
@@ -47,14 +52,15 @@ export const ProfileViewWithData = ({ queryClient, profileSource, navigateTo, })
|
|
|
47
52
|
skip: !dashboardItems.includes('callgraph'),
|
|
48
53
|
});
|
|
49
54
|
useEffect(() => {
|
|
50
|
-
if (!flamegraphLoading && flamegraphResponse?.report.oneofKind === 'flamegraph')
|
|
51
|
-
|
|
55
|
+
if ((!flamegraphLoading && flamegraphResponse?.report.oneofKind === 'flamegraph') ||
|
|
56
|
+
flamegraphResponse?.report.oneofKind === 'flamegraphArrow') {
|
|
57
|
+
perf?.markInteraction('Flamegraph render', flamegraphResponse.total);
|
|
52
58
|
}
|
|
53
59
|
if (!topTableLoading && topTableResponse?.report.oneofKind === 'top') {
|
|
54
|
-
perf?.markInteraction('Top table render', topTableResponse
|
|
60
|
+
perf?.markInteraction('Top table render', topTableResponse.total);
|
|
55
61
|
}
|
|
56
62
|
if (!callgraphLoading && callgraphResponse?.report.oneofKind === 'callgraph') {
|
|
57
|
-
perf?.markInteraction('Callgraph render', callgraphResponse
|
|
63
|
+
perf?.markInteraction('Callgraph render', callgraphResponse.total);
|
|
58
64
|
}
|
|
59
65
|
}, [
|
|
60
66
|
flamegraphLoading,
|
|
@@ -102,6 +108,9 @@ export const ProfileViewWithData = ({ queryClient, profileSource, navigateTo, })
|
|
|
102
108
|
data: flamegraphResponse?.report.oneofKind === 'flamegraph'
|
|
103
109
|
? flamegraphResponse?.report?.flamegraph
|
|
104
110
|
: undefined,
|
|
111
|
+
table: flamegraphResponse?.report.oneofKind === 'flamegraphArrow'
|
|
112
|
+
? tableFromIPC(flamegraphResponse?.report?.flamegraphArrow.record)
|
|
113
|
+
: undefined,
|
|
105
114
|
total: BigInt(flamegraphResponse?.total ?? '0'),
|
|
106
115
|
filtered: BigInt(flamegraphResponse?.filtered ?? '0'),
|
|
107
116
|
error: flamegraphError,
|