@parca/profile 0.16.197 → 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 +8 -0
- 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/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 -2
- package/dist/ProfileIcicleGraph/index.js +7 -5
- package/dist/ProfileView/index.d.ts +2 -0
- package/dist/ProfileView/index.js +2 -2
- package/dist/ProfileViewWithData.js +15 -6
- 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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.16.199](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.198...@parca/profile@0.16.199) (2023-07-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
10
|
+
## [0.16.198](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.188...@parca/profile@0.16.198) (2023-07-03)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @parca/profile
|
|
13
|
+
|
|
6
14
|
## [0.16.197](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.196...@parca/profile@0.16.197) (2023-06-30)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const ExpandOnHover = ({ value, displayValue }) => {
|
|
3
|
+
return (_jsxs("div", { className: "group relative w-full", children: [_jsx("div", { className: "w-full overflow-hidden text-ellipsis whitespace-nowrap", children: displayValue ?? value }), _jsx("div", { className: "absolute -inset-2 hidden h-fit max-w-[500px] whitespace-normal break-all rounded bg-gray-50 p-2 shadow-[0_0_10px_2px_rgba(0,0,0,0.3)] group-hover:flex dark:bg-gray-900", children: value })] }));
|
|
4
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table } from 'apache-arrow';
|
|
3
|
+
import { CallgraphNode, CallgraphNodeMeta, FlamegraphNode, FlamegraphNodeMeta, FlamegraphRootNode } from '@parca/client';
|
|
4
|
+
import { Location, Mapping, Function as ParcaFunction } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
|
|
5
|
+
interface ExtendedCallgraphNodeMeta extends CallgraphNodeMeta {
|
|
6
|
+
lineIndex: number;
|
|
7
|
+
locationIndex: number;
|
|
8
|
+
}
|
|
9
|
+
interface HoveringNode extends FlamegraphRootNode, FlamegraphNode, CallgraphNode {
|
|
10
|
+
diff: bigint;
|
|
11
|
+
meta?: FlamegraphNodeMeta | ExtendedCallgraphNodeMeta;
|
|
12
|
+
}
|
|
13
|
+
interface GraphTooltipProps {
|
|
14
|
+
table: Table<any>;
|
|
15
|
+
x?: number;
|
|
16
|
+
y?: number;
|
|
17
|
+
unit: string;
|
|
18
|
+
total: bigint;
|
|
19
|
+
totalUnfiltered: bigint;
|
|
20
|
+
hoveringNode?: HoveringNode;
|
|
21
|
+
contextElement: Element | null;
|
|
22
|
+
isFixed?: boolean;
|
|
23
|
+
virtualContextElement?: boolean;
|
|
24
|
+
strings?: string[];
|
|
25
|
+
mappings?: Mapping[];
|
|
26
|
+
locations?: Location[];
|
|
27
|
+
functions?: ParcaFunction[];
|
|
28
|
+
type?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const GraphTooltipContent: ({ hoveringNode, unit, total, totalUnfiltered, isFixed, strings, mappings, locations, functions, type, }: {
|
|
31
|
+
hoveringNode: HoveringNode;
|
|
32
|
+
unit: string;
|
|
33
|
+
total: bigint;
|
|
34
|
+
totalUnfiltered: bigint;
|
|
35
|
+
isFixed: boolean;
|
|
36
|
+
strings?: string[] | undefined;
|
|
37
|
+
mappings?: Mapping[] | undefined;
|
|
38
|
+
locations?: Location[] | undefined;
|
|
39
|
+
functions?: ParcaFunction[] | undefined;
|
|
40
|
+
type?: string | undefined;
|
|
41
|
+
}) => React.JSX.Element;
|
|
42
|
+
declare const GraphTooltip: ({ table, x, y, unit, total, totalUnfiltered, contextElement, isFixed, virtualContextElement, strings, mappings, locations, functions, type, }: GraphTooltipProps) => React.JSX.Element;
|
|
43
|
+
export default GraphTooltip;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { useEffect, useMemo, useState } from 'react';
|
|
15
|
+
import { pointer } from 'd3-selection';
|
|
16
|
+
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
17
|
+
import { usePopper } from 'react-popper';
|
|
18
|
+
import { useKeyDown } from '@parca/components';
|
|
19
|
+
import { selectHoveringRow, useAppSelector } from '@parca/store';
|
|
20
|
+
import { divide, getLastItem, valueFormatter } from '@parca/utilities';
|
|
21
|
+
import { hexifyAddress, truncateString, truncateStringReverse } from '../';
|
|
22
|
+
import { FIELD_CUMULATIVE, FIELD_DIFF, FIELD_FUNCTION_FILE_NAME, FIELD_FUNCTION_NAME, FIELD_LOCATION_ADDRESS, FIELD_MAPPING_BUILD_ID, FIELD_MAPPING_FILE, } from '../ProfileIcicleGraph/IcicleGraphArrow';
|
|
23
|
+
import { ExpandOnHover } from './ExpandOnHoverValue';
|
|
24
|
+
const NoData = () => {
|
|
25
|
+
return _jsx("span", { className: "rounded bg-gray-200 px-2 dark:bg-gray-800", children: "Not available" });
|
|
26
|
+
};
|
|
27
|
+
const virtualElement = {
|
|
28
|
+
getBoundingClientRect: () =>
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
30
|
+
({
|
|
31
|
+
width: 0,
|
|
32
|
+
height: 0,
|
|
33
|
+
top: 0,
|
|
34
|
+
left: 0,
|
|
35
|
+
right: 0,
|
|
36
|
+
bottom: 0,
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
function generateGetBoundingClientRect(contextElement, x = 0, y = 0) {
|
|
40
|
+
const domRect = contextElement.getBoundingClientRect();
|
|
41
|
+
return () =>
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
43
|
+
({
|
|
44
|
+
width: 0,
|
|
45
|
+
height: 0,
|
|
46
|
+
top: domRect.y + y,
|
|
47
|
+
left: domRect.x + x,
|
|
48
|
+
right: domRect.x + x,
|
|
49
|
+
bottom: domRect.y + y,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const TooltipMetaInfo = ({ hoveringNode, onCopy, strings, mappings, locations, functions, type = 'flamegraph', }) => {
|
|
53
|
+
// populate meta from the flamegraph metadata tables
|
|
54
|
+
if (type === 'flamegraph' &&
|
|
55
|
+
locations !== undefined &&
|
|
56
|
+
hoveringNode.meta?.locationIndex !== undefined &&
|
|
57
|
+
hoveringNode.meta.locationIndex !== 0) {
|
|
58
|
+
const location = locations[hoveringNode.meta.locationIndex - 1];
|
|
59
|
+
hoveringNode.meta.location = location;
|
|
60
|
+
if (location !== undefined) {
|
|
61
|
+
if (mappings !== undefined &&
|
|
62
|
+
location.mappingIndex !== undefined &&
|
|
63
|
+
location.mappingIndex !== 0) {
|
|
64
|
+
const mapping = mappings[location.mappingIndex - 1];
|
|
65
|
+
if (strings !== undefined && mapping !== undefined) {
|
|
66
|
+
mapping.file =
|
|
67
|
+
mapping?.fileStringIndex !== undefined ? strings[mapping.fileStringIndex] : '';
|
|
68
|
+
mapping.buildId =
|
|
69
|
+
mapping?.buildIdStringIndex !== undefined ? strings[mapping.buildIdStringIndex] : '';
|
|
70
|
+
}
|
|
71
|
+
hoveringNode.meta.mapping = mapping;
|
|
72
|
+
}
|
|
73
|
+
if (functions !== undefined &&
|
|
74
|
+
location.lines !== undefined &&
|
|
75
|
+
hoveringNode.meta.lineIndex !== undefined &&
|
|
76
|
+
hoveringNode.meta.lineIndex < location.lines.length) {
|
|
77
|
+
const func = functions[location.lines[hoveringNode.meta.lineIndex].functionIndex - 1];
|
|
78
|
+
if (strings !== undefined) {
|
|
79
|
+
func.name = strings[func.nameStringIndex];
|
|
80
|
+
func.systemName = strings[func.systemNameStringIndex];
|
|
81
|
+
func.filename = strings[func.filenameStringIndex];
|
|
82
|
+
}
|
|
83
|
+
hoveringNode.meta.function = func;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const getTextForFile = (hoveringNode) => {
|
|
88
|
+
if (hoveringNode.meta?.function == null)
|
|
89
|
+
return '<unknown>';
|
|
90
|
+
return `${hoveringNode.meta.function.filename} ${hoveringNode.meta.line?.line !== undefined && hoveringNode.meta.line?.line !== 0n
|
|
91
|
+
? ` +${hoveringNode.meta.line.line.toString()}`
|
|
92
|
+
: `${hoveringNode.meta.function?.startLine !== undefined &&
|
|
93
|
+
hoveringNode.meta.function?.startLine !== 0n
|
|
94
|
+
? ` +${hoveringNode.meta.function.startLine}`
|
|
95
|
+
: ''}`}`;
|
|
96
|
+
};
|
|
97
|
+
const file = getTextForFile(hoveringNode);
|
|
98
|
+
return (_jsxs(_Fragment, { children: [_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "File" }), _jsx("td", { className: "w-3/4 break-all", children: hoveringNode.meta?.function?.filename == null ||
|
|
99
|
+
hoveringNode.meta?.function.filename === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, { onCopy: onCopy, text: file, children: _jsx("button", { className: "cursor-pointer whitespace-nowrap text-left", children: _jsx(ExpandOnHover, { value: file, displayValue: truncateStringReverse(file, 40) }) }) })) })] }), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Address" }), _jsx("td", { className: "w-3/4 break-all", children: hoveringNode.meta?.location?.address == null ||
|
|
100
|
+
hoveringNode.meta?.location.address === 0n ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, { onCopy: onCopy, text: hexifyAddress(hoveringNode.meta.location.address), children: _jsx("button", { className: "cursor-pointer", children: hexifyAddress(hoveringNode.meta.location.address) }) })) })] }), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Binary" }), _jsx("td", { className: "w-3/4 break-all", children: hoveringNode.meta?.mapping == null || hoveringNode.meta.mapping.file === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, { onCopy: onCopy, text: hoveringNode.meta.mapping.file, children: _jsx("button", { className: "cursor-pointer", children: getLastItem(hoveringNode.meta.mapping.file) }) })) })] }), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Build Id" }), _jsx("td", { className: "w-3/4 break-all", children: hoveringNode.meta?.mapping == null || hoveringNode.meta?.mapping.buildId === '' ? (_jsx(NoData, {})) : (_jsx(CopyToClipboard, { onCopy: onCopy, text: hoveringNode.meta.mapping.buildId, children: _jsx("button", { className: "cursor-pointer", children: truncateString(getLastItem(hoveringNode.meta.mapping.buildId), 28) }) })) })] })] }));
|
|
101
|
+
};
|
|
102
|
+
let timeoutHandle = null;
|
|
103
|
+
export const GraphTooltipContent = ({ hoveringNode, unit, total, totalUnfiltered, isFixed, strings, mappings, locations, functions, type = 'flamegraph', }) => {
|
|
104
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
105
|
+
const onCopy = () => {
|
|
106
|
+
setIsCopied(true);
|
|
107
|
+
if (timeoutHandle !== null) {
|
|
108
|
+
clearTimeout(timeoutHandle);
|
|
109
|
+
}
|
|
110
|
+
timeoutHandle = setTimeout(() => setIsCopied(false), 3000);
|
|
111
|
+
};
|
|
112
|
+
const hoveringNodeCumulative = hoveringNode.cumulative;
|
|
113
|
+
const diff = hoveringNode.diff;
|
|
114
|
+
const prevValue = hoveringNodeCumulative - diff;
|
|
115
|
+
const diffRatio = diff !== 0n ? divide(diff, prevValue) : 0;
|
|
116
|
+
const diffSign = diff > 0 ? '+' : '';
|
|
117
|
+
const diffValueText = diffSign + valueFormatter(diff, unit, 1);
|
|
118
|
+
const diffPercentageText = diffSign + (diffRatio * 100).toFixed(2) + '%';
|
|
119
|
+
const diffText = `${diffValueText} (${diffPercentageText})`;
|
|
120
|
+
const getTextForCumulative = (hoveringNodeCumulative) => {
|
|
121
|
+
const filtered = totalUnfiltered > total
|
|
122
|
+
? ` / ${(100 * divide(hoveringNodeCumulative, total)).toFixed(2)}% of filtered`
|
|
123
|
+
: '';
|
|
124
|
+
return `${valueFormatter(hoveringNodeCumulative, unit, 2)}
|
|
125
|
+
(${(100 * divide(hoveringNodeCumulative, totalUnfiltered)).toFixed(2)}%${filtered})`;
|
|
126
|
+
};
|
|
127
|
+
return (_jsx("div", { className: `flex text-sm ${isFixed ? 'w-full' : ''}`, children: _jsx("div", { className: `m-auto w-full ${isFixed ? 'w-full' : ''}`, children: _jsxs("div", { className: "min-h-52 flex w-[500px] flex-col justify-between rounded-lg border border-gray-300 bg-gray-50 p-3 shadow-lg dark:border-gray-500 dark:bg-gray-900", children: [_jsx("div", { className: "flex flex-row", children: _jsxs("div", { className: "mx-2", children: [_jsx("div", { className: "flex h-10 items-center break-all font-semibold", children: hoveringNode.meta === undefined ? (_jsx("p", { children: "root" })) : (_jsx(_Fragment, { children: hoveringNode.meta.function !== undefined &&
|
|
128
|
+
hoveringNode.meta.function.name !== '' ? (_jsx(CopyToClipboard, { onCopy: onCopy, text: hoveringNode.meta.function.name, children: _jsx("button", { className: "cursor-pointer text-left", children: hoveringNode.meta.function.name }) })) : (_jsx(_Fragment, { children: hoveringNode.meta.location !== undefined &&
|
|
129
|
+
hoveringNode.meta.location.address !== 0n ? (_jsx(CopyToClipboard, { onCopy: onCopy, text: hexifyAddress(hoveringNode.meta.location.address), children: _jsx("button", { className: "cursor-pointer text-left", children: hexifyAddress(hoveringNode.meta.location.address) }) })) : (_jsx("p", { children: "unknown" })) })) })) }), _jsx("table", { className: "my-2 w-full table-fixed pr-0 text-gray-700 dark:text-gray-300", children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Cumulative" }), _jsx("td", { className: "w-3/4", children: _jsx(CopyToClipboard, { onCopy: onCopy, text: getTextForCumulative(hoveringNodeCumulative), children: _jsx("button", { className: "cursor-pointer", children: getTextForCumulative(hoveringNodeCumulative) }) }) })] }), hoveringNode.diff !== undefined && diff !== 0n && (_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Diff" }), _jsx("td", { className: "w-3/4", children: _jsx(CopyToClipboard, { onCopy: onCopy, text: diffText, children: _jsx("button", { className: "cursor-pointer", children: diffText }) }) })] })), _jsx(TooltipMetaInfo, { onCopy: onCopy, hoveringNode: hoveringNode, strings: strings, mappings: mappings, locations: locations, functions: functions, type: type })] }) })] }) }), _jsx("span", { className: "mx-2 block text-xs text-gray-500", children: isCopied ? 'Copied!' : 'Hold shift and click on a value to copy.' })] }) }) }));
|
|
130
|
+
};
|
|
131
|
+
const GraphTooltip = ({ table, x, y, unit, total, totalUnfiltered, contextElement, isFixed = false, virtualContextElement = true, strings, mappings, locations, functions, type = 'flamegraph', }) => {
|
|
132
|
+
const hoveringNodeState = useAppSelector(selectHoveringRow);
|
|
133
|
+
const hoveringNode = useMemo(() => {
|
|
134
|
+
const s = hoveringNodeState;
|
|
135
|
+
if (s === undefined) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const mappingFile = table.getChild(FIELD_MAPPING_FILE)?.get(s.row) ?? '';
|
|
139
|
+
const mappingBuildID = table.getChild(FIELD_MAPPING_BUILD_ID)?.get(s.row) ?? '';
|
|
140
|
+
const locationAddress = table.getChild(FIELD_LOCATION_ADDRESS)?.get(s.row) ?? 0n;
|
|
141
|
+
const functionName = table.getChild(FIELD_FUNCTION_NAME)?.get(s.row) ?? '';
|
|
142
|
+
const functionFileName = table.getChild(FIELD_FUNCTION_FILE_NAME)?.get(s.row) ?? '';
|
|
143
|
+
const cumulative = table.getChild(FIELD_CUMULATIVE)?.get(s.row) ?? 0n;
|
|
144
|
+
const diff = table.getChild(FIELD_DIFF)?.get(s.row) ?? 0n;
|
|
145
|
+
const fhn = {
|
|
146
|
+
id: '',
|
|
147
|
+
flat: 0n,
|
|
148
|
+
children: [],
|
|
149
|
+
cumulative,
|
|
150
|
+
diff: diff === null ? 0n : diff,
|
|
151
|
+
meta: {
|
|
152
|
+
locationIndex: 0,
|
|
153
|
+
lineIndex: 0,
|
|
154
|
+
mapping: {
|
|
155
|
+
id: '',
|
|
156
|
+
start: 0n,
|
|
157
|
+
limit: 0n,
|
|
158
|
+
offset: 0n,
|
|
159
|
+
file: mappingFile,
|
|
160
|
+
buildId: mappingBuildID,
|
|
161
|
+
hasFunctions: false,
|
|
162
|
+
hasFilenames: false,
|
|
163
|
+
hasLineNumbers: false,
|
|
164
|
+
hasInlineFrames: false,
|
|
165
|
+
fileStringIndex: 0,
|
|
166
|
+
buildIdStringIndex: 0,
|
|
167
|
+
},
|
|
168
|
+
location: {
|
|
169
|
+
id: '',
|
|
170
|
+
address: locationAddress,
|
|
171
|
+
mappingId: '',
|
|
172
|
+
isFolded: false,
|
|
173
|
+
lines: [],
|
|
174
|
+
mappingIndex: 0,
|
|
175
|
+
},
|
|
176
|
+
function: {
|
|
177
|
+
id: '',
|
|
178
|
+
startLine: 0n,
|
|
179
|
+
name: functionName,
|
|
180
|
+
systemName: '',
|
|
181
|
+
filename: functionFileName,
|
|
182
|
+
nameStringIndex: 0,
|
|
183
|
+
systemNameStringIndex: 0,
|
|
184
|
+
filenameStringIndex: 0,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
return fhn;
|
|
189
|
+
}, [table, hoveringNodeState]);
|
|
190
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
191
|
+
const { styles, attributes, ...popperProps } = usePopper(virtualContextElement ? virtualElement : contextElement, popperElement, {
|
|
192
|
+
placement: 'bottom-start',
|
|
193
|
+
strategy: 'absolute',
|
|
194
|
+
modifiers: [
|
|
195
|
+
{
|
|
196
|
+
name: 'preventOverflow',
|
|
197
|
+
options: {
|
|
198
|
+
tether: false,
|
|
199
|
+
altAxis: true,
|
|
200
|
+
boundary: contextElement ?? undefined,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'offset',
|
|
205
|
+
options: {
|
|
206
|
+
offset: [30, 30],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'flip',
|
|
211
|
+
options: {
|
|
212
|
+
boundary: contextElement ?? undefined,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
});
|
|
217
|
+
const { isShiftDown } = useKeyDown();
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
if (contextElement === null)
|
|
220
|
+
return;
|
|
221
|
+
const onMouseMove = (e) => {
|
|
222
|
+
if (isShiftDown) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
let tooltipX = x;
|
|
226
|
+
let tooltipY = y;
|
|
227
|
+
if (tooltipX == null || tooltipY == null) {
|
|
228
|
+
const rel = pointer(e);
|
|
229
|
+
tooltipX = rel[0];
|
|
230
|
+
tooltipY = rel[1];
|
|
231
|
+
}
|
|
232
|
+
virtualElement.getBoundingClientRect = generateGetBoundingClientRect(contextElement, tooltipX, tooltipY);
|
|
233
|
+
void popperProps.update?.();
|
|
234
|
+
};
|
|
235
|
+
contextElement.addEventListener('mousemove', onMouseMove);
|
|
236
|
+
return () => {
|
|
237
|
+
contextElement.removeEventListener('mousemove', onMouseMove);
|
|
238
|
+
};
|
|
239
|
+
}, [contextElement, popperProps, isShiftDown, x, y]);
|
|
240
|
+
if (hoveringNode === undefined || hoveringNode == null)
|
|
241
|
+
return _jsx(_Fragment, {});
|
|
242
|
+
return isFixed ? (_jsx(GraphTooltipContent, { hoveringNode: hoveringNode, unit: unit, total: total, totalUnfiltered: totalUnfiltered, isFixed: isFixed, type: type })) : (_jsx("div", { ref: setPopperElement, style: styles.popper, ...attributes.popper, children: _jsx(GraphTooltipContent, { hoveringNode: hoveringNode, unit: unit, total: total, totalUnfiltered: totalUnfiltered, isFixed: isFixed, strings: strings, mappings: mappings, locations: locations, functions: functions, type: type }) }));
|
|
243
|
+
};
|
|
244
|
+
export default GraphTooltip;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NavigateFunction } from '@parca/utilities';
|
|
3
|
+
import { mappingColors } from './IcicleGraphNodes';
|
|
4
|
+
interface Props {
|
|
5
|
+
mappingColors: mappingColors;
|
|
6
|
+
navigateTo?: NavigateFunction;
|
|
7
|
+
compareMode?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const ColorStackLegend: ({ mappingColors, navigateTo, compareMode, }: Props) => React.JSX.Element;
|
|
10
|
+
export default ColorStackLegend;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { useMemo } from 'react';
|
|
15
|
+
import { Icon } from '@iconify/react';
|
|
16
|
+
import cx from 'classnames';
|
|
17
|
+
import { useURLState } from '@parca/components';
|
|
18
|
+
import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
|
|
19
|
+
import { EVERYTHING_ELSE } from '@parca/store';
|
|
20
|
+
const ColorStackLegend = ({ mappingColors, navigateTo, compareMode = false, }) => {
|
|
21
|
+
const [colorProfileName] = useUserPreference(USER_PREFERENCES.FLAMEGRAPH_COLOR_PROFILE.key);
|
|
22
|
+
const [currentSearchString, setSearchString] = useURLState({ param: 'search_string', navigateTo });
|
|
23
|
+
const stackColorArray = useMemo(() => {
|
|
24
|
+
return Object.entries(mappingColors).sort(([featureA], [featureB]) => {
|
|
25
|
+
if (featureA === EVERYTHING_ELSE) {
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
if (featureB === EVERYTHING_ELSE) {
|
|
29
|
+
return -1;
|
|
30
|
+
}
|
|
31
|
+
return featureA?.localeCompare(featureB ?? '') ?? 0;
|
|
32
|
+
});
|
|
33
|
+
}, [mappingColors]);
|
|
34
|
+
if (mappingColors === undefined) {
|
|
35
|
+
return _jsx(_Fragment, {});
|
|
36
|
+
}
|
|
37
|
+
if (Object.entries(mappingColors).length === 0) {
|
|
38
|
+
return _jsx(_Fragment, {});
|
|
39
|
+
}
|
|
40
|
+
if (colorProfileName === 'default' || compareMode) {
|
|
41
|
+
return _jsx(_Fragment, {});
|
|
42
|
+
}
|
|
43
|
+
return (_jsx("div", { className: "my-6 flex flex-wrap justify-center gap-2", children: stackColorArray.map(([feature, color]) => {
|
|
44
|
+
const filteringAllowed = feature !== EVERYTHING_ELSE;
|
|
45
|
+
const isHighlighted = currentSearchString === feature;
|
|
46
|
+
return (_jsxs("div", { className: cx('flex items-center justify-between gap-1 text-ellipsis p-1 pr-2', {
|
|
47
|
+
'cursor-pointer': filteringAllowed,
|
|
48
|
+
'bg-gray-200 dark:bg-gray-800': isHighlighted,
|
|
49
|
+
}), onClick: () => {
|
|
50
|
+
if (!filteringAllowed) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (isHighlighted) {
|
|
54
|
+
setSearchString('');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setSearchString(feature);
|
|
58
|
+
}, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("div", { className: "mr-1 inline-block h-4 w-4", style: { backgroundColor: color } }), _jsx("span", { className: "text-sm", children: feature })] }), isHighlighted ? (_jsx(Icon, { icon: "radix-icons:cross-circled", onClick: e => {
|
|
59
|
+
setSearchString('');
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
} })) : null] }, feature));
|
|
62
|
+
}) }));
|
|
63
|
+
};
|
|
64
|
+
export default ColorStackLegend;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table } from 'apache-arrow';
|
|
3
|
+
export declare const RowHeight = 26;
|
|
4
|
+
interface IcicleGraphNodesProps {
|
|
5
|
+
table: Table<any>;
|
|
6
|
+
row: number;
|
|
7
|
+
mappingColors: mappingColors;
|
|
8
|
+
childRows: number[];
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
total: bigint;
|
|
12
|
+
totalWidth: number;
|
|
13
|
+
level: number;
|
|
14
|
+
curPath: string[];
|
|
15
|
+
setCurPath: (path: string[]) => void;
|
|
16
|
+
path: string[];
|
|
17
|
+
xScale: (value: bigint) => number;
|
|
18
|
+
searchString?: string;
|
|
19
|
+
sortBy: string;
|
|
20
|
+
darkMode: boolean;
|
|
21
|
+
compareMode: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const IcicleGraphNodes: React.NamedExoticComponent<IcicleGraphNodesProps>;
|
|
24
|
+
export interface mappingColors {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
}
|
|
27
|
+
interface IcicleNodeProps {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
height: number;
|
|
31
|
+
totalWidth: number;
|
|
32
|
+
curPath: string[];
|
|
33
|
+
level: number;
|
|
34
|
+
table: Table<any>;
|
|
35
|
+
row: number;
|
|
36
|
+
mappingColors: mappingColors;
|
|
37
|
+
path: string[];
|
|
38
|
+
total: bigint;
|
|
39
|
+
setCurPath: (path: string[]) => void;
|
|
40
|
+
xScale: (value: bigint) => number;
|
|
41
|
+
isRoot?: boolean;
|
|
42
|
+
searchString?: string;
|
|
43
|
+
sortBy: string;
|
|
44
|
+
darkMode: boolean;
|
|
45
|
+
compareMode: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare const IcicleNode: React.NamedExoticComponent<IcicleNodeProps>;
|
|
48
|
+
export {};
|
|
@@ -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;
|