@parca/profile 0.17.1 → 0.17.3

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.
Files changed (120) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/GraphTooltipArrow/Content.d.ts +1 -2
  3. package/dist/GraphTooltipArrow/Content.d.ts.map +1 -1
  4. package/dist/GraphTooltipArrow/Content.js +1 -2
  5. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.d.ts +1 -2
  6. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.d.ts.map +1 -1
  7. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +1 -2
  8. package/dist/GraphTooltipArrow/useGraphTooltip/index.d.ts +1 -2
  9. package/dist/GraphTooltipArrow/useGraphTooltip/index.d.ts.map +1 -1
  10. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +2 -2
  11. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.d.ts +2 -6
  12. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.d.ts.map +1 -1
  13. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.js +4 -5
  14. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.d.ts +20 -0
  15. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.d.ts.map +1 -0
  16. package/{src/Callgraph/constants.ts → dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.js} +12 -3
  17. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts +8 -51
  18. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts.map +1 -1
  19. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.js +59 -136
  20. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.d.ts +8 -0
  21. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.d.ts.map +1 -0
  22. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.js +40 -0
  23. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.d.ts +32 -0
  24. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.d.ts.map +1 -0
  25. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.js +40 -0
  26. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.d.ts +4 -5
  27. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.d.ts.map +1 -1
  28. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.js +62 -76
  29. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.d.ts +3 -3
  30. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.d.ts.map +1 -1
  31. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.js +9 -7
  32. package/dist/ProfileIcicleGraph/index.d.ts +3 -6
  33. package/dist/ProfileIcicleGraph/index.d.ts.map +1 -1
  34. package/dist/ProfileIcicleGraph/index.js +8 -17
  35. package/dist/ProfileView/components/DashboardItems/index.d.ts +3 -5
  36. package/dist/ProfileView/components/DashboardItems/index.d.ts.map +1 -1
  37. package/dist/ProfileView/components/DashboardItems/index.js +4 -9
  38. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  39. package/dist/ProfileView/components/Toolbars/index.js +1 -2
  40. package/dist/ProfileView/index.d.ts +1 -1
  41. package/dist/ProfileView/index.d.ts.map +1 -1
  42. package/dist/ProfileView/index.js +1 -13
  43. package/dist/ProfileView/types/visualization.d.ts +1 -1
  44. package/dist/ProfileView/types/visualization.d.ts.map +1 -1
  45. package/dist/index.d.ts +0 -4
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +0 -2
  48. package/dist/styles.css +1 -1
  49. package/package.json +5 -5
  50. package/src/GraphTooltipArrow/Content.tsx +0 -3
  51. package/src/GraphTooltipArrow/DockedGraphTooltip/index.tsx +0 -3
  52. package/src/GraphTooltipArrow/useGraphTooltip/index.ts +1 -3
  53. package/src/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.tsx +5 -13
  54. package/src/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.tsx +53 -0
  55. package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.tsx +96 -310
  56. package/src/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.tsx +78 -0
  57. package/src/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.tsx +93 -0
  58. package/src/ProfileIcicleGraph/IcicleGraphArrow/index.tsx +108 -216
  59. package/src/ProfileIcicleGraph/IcicleGraphArrow/utils.ts +8 -15
  60. package/src/ProfileIcicleGraph/index.tsx +7 -38
  61. package/src/ProfileView/components/DashboardItems/index.tsx +2 -27
  62. package/src/ProfileView/components/Toolbars/index.tsx +0 -2
  63. package/src/ProfileView/index.tsx +0 -14
  64. package/src/ProfileView/types/visualization.ts +1 -1
  65. package/src/index.tsx +0 -5
  66. package/dist/Callgraph/constants.d.ts +0 -3
  67. package/dist/Callgraph/constants.d.ts.map +0 -1
  68. package/dist/Callgraph/constants.js +0 -14
  69. package/dist/Callgraph/index.d.ts +0 -11
  70. package/dist/Callgraph/index.d.ts.map +0 -1
  71. package/dist/Callgraph/index.js +0 -104
  72. package/dist/Callgraph/mockData/index.d.ts +0 -149
  73. package/dist/Callgraph/mockData/index.d.ts.map +0 -1
  74. package/dist/Callgraph/mockData/index.js +0 -594
  75. package/dist/Callgraph/utils.d.ts +0 -20
  76. package/dist/Callgraph/utils.d.ts.map +0 -1
  77. package/dist/Callgraph/utils.js +0 -97
  78. package/dist/GraphTooltip/ExpandOnHoverValue.d.ts +0 -7
  79. package/dist/GraphTooltip/ExpandOnHoverValue.d.ts.map +0 -1
  80. package/dist/GraphTooltip/ExpandOnHoverValue.js +0 -4
  81. package/dist/GraphTooltip/index.d.ts +0 -41
  82. package/dist/GraphTooltip/index.d.ts.map +0 -1
  83. package/dist/GraphTooltip/index.js +0 -201
  84. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.d.ts +0 -6
  85. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.d.ts.map +0 -1
  86. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.js +0 -59
  87. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.d.ts +0 -47
  88. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.d.ts.map +0 -1
  89. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.js +0 -93
  90. package/dist/ProfileIcicleGraph/IcicleGraph/index.d.ts +0 -14
  91. package/dist/ProfileIcicleGraph/IcicleGraph/index.d.ts.map +0 -1
  92. package/dist/ProfileIcicleGraph/IcicleGraph/index.js +0 -48
  93. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.d.ts +0 -15
  94. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.d.ts.map +0 -1
  95. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.js +0 -57
  96. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.d.ts +0 -8
  97. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.d.ts.map +0 -1
  98. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.js +0 -32
  99. package/dist/ProfileIcicleGraph/IcicleGraph/utils.d.ts +0 -7
  100. package/dist/ProfileIcicleGraph/IcicleGraph/utils.d.ts.map +0 -1
  101. package/dist/ProfileIcicleGraph/IcicleGraph/utils.js +0 -66
  102. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.d.ts +0 -9
  103. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.d.ts.map +0 -1
  104. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.js +0 -45
  105. package/dist/ProfileView/hooks/useGraphviz.d.ts +0 -12
  106. package/dist/ProfileView/hooks/useGraphviz.d.ts.map +0 -1
  107. package/dist/ProfileView/hooks/useGraphviz.js +0 -42
  108. package/src/Callgraph/index.tsx +0 -177
  109. package/src/Callgraph/mockData/index.ts +0 -605
  110. package/src/Callgraph/utils.ts +0 -141
  111. package/src/GraphTooltip/ExpandOnHoverValue.tsx +0 -30
  112. package/src/GraphTooltip/index.tsx +0 -509
  113. package/src/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.tsx +0 -96
  114. package/src/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.tsx +0 -266
  115. package/src/ProfileIcicleGraph/IcicleGraph/index.tsx +0 -123
  116. package/src/ProfileIcicleGraph/IcicleGraph/useColoredGraph.ts +0 -117
  117. package/src/ProfileIcicleGraph/IcicleGraph/useNodeColor.ts +0 -54
  118. package/src/ProfileIcicleGraph/IcicleGraph/utils.ts +0 -102
  119. package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.tsx +0 -130
  120. package/src/ProfileView/hooks/useGraphviz.ts +0 -69
@@ -1,8 +0,0 @@
1
- import type { ColoredFlamegraphNode } from './useColoredGraph';
2
- interface Props {
3
- data: ColoredFlamegraphNode;
4
- compareMode: boolean;
5
- }
6
- declare const useNodeColor: ({ data, compareMode }: Props) => string;
7
- export default useNodeColor;
8
- //# sourceMappingURL=useNodeColor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useNodeColor.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraph/useNodeColor.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAE7D,UAAU,KAAK;IACb,IAAI,EAAE,qBAAqB,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,QAAA,MAAM,YAAY,0BAAyB,KAAK,KAAG,MAoBlD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,32 +0,0 @@
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 { useMemo } from 'react';
14
- import { EVERYTHING_ELSE, selectColorProfiles, selectDarkMode, selectStackColors, useAppSelector, } from '@parca/store';
15
- import { diffColor } from '@parca/utilities';
16
- const useNodeColor = ({ data, compareMode }) => {
17
- const colors = useAppSelector(selectStackColors);
18
- const isDarkMode = useAppSelector(selectDarkMode);
19
- const colorProfiles = useAppSelector(selectColorProfiles);
20
- const color = useMemo(() => {
21
- if (compareMode) {
22
- const diff = data.diff;
23
- const cumulative = data.cumulative;
24
- return diffColor(diff, cumulative, isDarkMode);
25
- }
26
- const color = colors[data.feature ?? EVERYTHING_ELSE] ??
27
- (!isDarkMode ? colorProfiles.default.colors[0][0] : colorProfiles.default.colors[0][1]);
28
- return color;
29
- }, [data, colors, isDarkMode, compareMode, colorProfiles]);
30
- return color;
31
- };
32
- export default useNodeColor;
@@ -1,7 +0,0 @@
1
- import { FlamegraphNode } from '@parca/client';
2
- import { Location, Mapping, Function as ParcaFunction } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
3
- import { type BinaryFeature } from '@parca/store';
4
- export declare const getBinaryName: (node: FlamegraphNode, mappings: Mapping[], locations: Location[], strings: string[]) => string | undefined;
5
- export declare function nodeLabel(node: FlamegraphNode, strings: string[], mappings: Mapping[], locations: Location[], functions: ParcaFunction[], showBinaryName: boolean): string;
6
- export declare const extractFeature: (data: FlamegraphNode, mappings: Mapping[], locations: Location[], strings: string[]) => BinaryFeature;
7
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraph/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,IAAI,aAAa,EAC1B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAwC,KAAK,aAAa,EAAC,MAAM,cAAc,CAAC;AAKvF,eAAO,MAAM,aAAa,SAClB,cAAc,YACV,OAAO,EAAE,aACR,QAAQ,EAAE,WACZ,MAAM,EAAE,KAChB,MAAM,GAAG,SAoBX,CAAC;AAEF,wBAAgB,SAAS,CACvB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,OAAO,EAAE,EACnB,SAAS,EAAE,QAAQ,EAAE,EACrB,SAAS,EAAE,aAAa,EAAE,EAC1B,cAAc,EAAE,OAAO,GACtB,MAAM,CA6BR;AAED,eAAO,MAAM,cAAc,SACnB,cAAc,YACV,OAAO,EAAE,aACR,QAAQ,EAAE,WACZ,MAAM,EAAE,KAChB,aAOF,CAAC"}
@@ -1,66 +0,0 @@
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 { BINARY_FEATURE_TYPES, EVERYTHING_ELSE } from '@parca/store';
14
- import { getLastItem } from '@parca/utilities';
15
- import { hexifyAddress } from '../../utils';
16
- export const getBinaryName = (node, mappings, locations, strings) => {
17
- if (node.meta?.locationIndex === undefined || node.meta?.locationIndex === 0) {
18
- return undefined;
19
- }
20
- if (node.meta.locationIndex > locations.length) {
21
- return undefined;
22
- }
23
- const location = locations[node.meta.locationIndex - 1];
24
- if (location.mappingIndex === undefined || location.mappingIndex === 0) {
25
- return undefined;
26
- }
27
- const mapping = mappings[location.mappingIndex - 1];
28
- if (mapping == null || mapping.fileStringIndex == null) {
29
- return undefined;
30
- }
31
- const mappingFile = strings[mapping.fileStringIndex];
32
- return getLastItem(mappingFile);
33
- };
34
- export function nodeLabel(node, strings, mappings, locations, functions, showBinaryName) {
35
- if (node.meta?.locationIndex === undefined)
36
- return '<unknown>';
37
- if (node.meta?.locationIndex === 0)
38
- return '<unknown>';
39
- if (node.meta.locationIndex > locations.length) {
40
- console.info('location index out of bounds', node.meta.locationIndex, locations.length);
41
- return '<unknown>';
42
- }
43
- const location = locations[node.meta.locationIndex - 1];
44
- if (location === undefined)
45
- return '<unknown>';
46
- let mappingString = '';
47
- if (showBinaryName) {
48
- const binary = getBinaryName(node, mappings, locations, strings);
49
- if (binary != null)
50
- mappingString = `[${binary}]`;
51
- }
52
- if (location.lines.length > 0) {
53
- const funcName = strings[functions[location.lines[node.meta.lineIndex].functionIndex - 1].nameStringIndex];
54
- return `${mappingString.length > 0 ? `${mappingString} ` : ''}${funcName}`;
55
- }
56
- const address = hexifyAddress(location.address);
57
- const fallback = `${mappingString}${address}`;
58
- return fallback === '' ? '<unknown>' : fallback;
59
- }
60
- export const extractFeature = (data, mappings, locations, strings) => {
61
- const binaryName = getBinaryName(data, mappings, locations, strings);
62
- if (binaryName != null) {
63
- return { name: binaryName, type: BINARY_FEATURE_TYPES.Binary };
64
- }
65
- return { name: EVERYTHING_ELSE, type: BINARY_FEATURE_TYPES.Misc };
66
- };
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { ProfileSource } from '../../ProfileSource';
3
- import { IcicleNodeProps } from './IcicleGraphNodes';
4
- interface IcicleChartRootNodeSpecificProps {
5
- profileSource?: ProfileSource;
6
- }
7
- export declare const IcicleChartRootNode: React.NamedExoticComponent<IcicleNodeProps & IcicleChartRootNodeSpecificProps>;
8
- export {};
9
- //# sourceMappingURL=IcicleChartRootNode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IcicleChartRootNode.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAKtC,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAa,eAAe,EAAY,MAAM,oBAAoB,CAAC;AAG1E,UAAU,gCAAgC;IACxC,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,eAAO,MAAM,mBAAmB,gFAuG9B,CAAC"}
@@ -1,45 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx } 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, { Fragment } from 'react';
15
- import { scaleLinear } from '@parca/utilities';
16
- import { FIELD_CHILDREN, FIELD_CUMULATIVE, FIELD_DURATION, FIELD_TIMESTAMP } from '.';
17
- import { IcicleNode, RowHeight } from './IcicleGraphNodes';
18
- import { boundsFromProfileSource } from './utils';
19
- export const IcicleChartRootNode = React.memo(function IcicleChartRootNodeNonMemo({ table, row, colors, colorBy, y, setCurPath, curPath, level, path, total, totalWidth, xScale, searchString, setHoveringRow, setHoveringLevel, sortBy, darkMode, compareMode, profileType, isContextMenuOpen, hoveringName, setHoveringName, hoveringRow, colorForSimilarNodes, highlightSimilarStacksPreference, profileSource, }) {
20
- // get the columns to read from
21
- const durationColumn = table.getChild(FIELD_DURATION);
22
- const timestampColumn = table.getChild(FIELD_TIMESTAMP);
23
- const cumulativeColumn = table.getChild(FIELD_CUMULATIVE);
24
- const cumulative = cumulativeColumn?.get(row) !== null ? BigInt(cumulativeColumn?.get(row)) : 0n;
25
- const childRows = Array.from(table.getChild(FIELD_CHILDREN)?.get(row) ?? []).sort((a, b) => a - b);
26
- const tsBounds = boundsFromProfileSource(profileSource);
27
- const nextLevel = level + 1;
28
- const nextCurPath = curPath.length === 0 ? [] : curPath.slice(1);
29
- const tsXScale = scaleLinear([tsBounds[0], tsBounds[1]], [0, totalWidth]);
30
- const width = nextCurPath.length > 0 || (nextCurPath.length === 0 && curPath.length === 1)
31
- ? totalWidth
32
- : xScale(BigInt(cumulative));
33
- if (width <= 1) {
34
- return _jsx(_Fragment, { children: null });
35
- }
36
- return (_jsx(_Fragment, { children: childRows.map(row => {
37
- const duration = durationColumn?.get(row) !== null ? BigInt(durationColumn?.get(row)) : 0n;
38
- const timestamp = timestampColumn?.get(row) !== null ? BigInt(timestampColumn?.get(row)) : 0n;
39
- const x = tsXScale(timestamp);
40
- const width = tsXScale(timestamp + BigInt(Math.round(Number(duration)))) - x;
41
- const cumulative = cumulativeColumn?.get(row) !== null ? BigInt(cumulativeColumn?.get(row)) : 0n;
42
- const newXScale = scaleLinear([0n, BigInt(cumulative)], [0, width]);
43
- return (_jsx(Fragment, { children: _jsx(IcicleNode, { table: table, row: row, colors: colors, colorBy: colorBy, x: x, y: y, totalWidth: width ?? 1, height: RowHeight, setCurPath: setCurPath, curPath: curPath, total: total, xScale: newXScale, path: path, level: nextLevel, searchString: searchString ?? '', setHoveringRow: setHoveringRow, setHoveringLevel: setHoveringLevel, sortBy: sortBy, darkMode: darkMode, compareMode: compareMode, profileType: profileType, isContextMenuOpen: isContextMenuOpen, hoveringName: hoveringName, setHoveringName: setHoveringName, hoveringRow: hoveringRow, colorForSimilarNodes: colorForSimilarNodes, highlightSimilarStacksPreference: highlightSimilarStacksPreference }, row) }, row));
44
- }) }));
45
- });
@@ -1,12 +0,0 @@
1
- import { Callgraph as CallgraphType } from '@parca/client';
2
- interface UseGraphvizProps {
3
- callgraphData?: CallgraphType;
4
- width?: number;
5
- colorRange: [string, string];
6
- }
7
- export declare const useGraphviz: ({ callgraphData, width, colorRange, }: UseGraphvizProps) => {
8
- graphvizLoaded: boolean;
9
- callgraphSVG: string | undefined;
10
- };
11
- export {};
12
- //# sourceMappingURL=useGraphviz.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGraphviz.d.ts","sourceRoot":"","sources":["../../../src/ProfileView/hooks/useGraphviz.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,SAAS,IAAI,aAAa,EAAC,MAAM,eAAe,CAAC;AAIzD,UAAU,gBAAgB;IACxB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,0CAIrB,gBAAgB,KAAG;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAmClC,CAAC"}
@@ -1,42 +0,0 @@
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 { useEffect, useState } from 'react';
14
- import graphviz from 'graphviz-wasm';
15
- import { jsonToDot } from '../../Callgraph/utils';
16
- export const useGraphviz = ({ callgraphData, width, colorRange, }) => {
17
- const [graphvizLoaded, setGraphvizLoaded] = useState(false);
18
- const [callgraphSVG, setCallgraphSVG] = useState(undefined);
19
- useEffect(() => {
20
- async function loadGraphviz() {
21
- await graphviz.loadWASM();
22
- setGraphvizLoaded(true);
23
- }
24
- void loadGraphviz();
25
- }, []);
26
- useEffect(() => {
27
- async function loadCallgraphSVG(graph, width, colorRange) {
28
- await setCallgraphSVG(undefined);
29
- const dataAsDot = await jsonToDot({
30
- graph,
31
- width,
32
- colorRange,
33
- });
34
- const svgGraph = await graphviz.layout(dataAsDot, 'svg', 'dot');
35
- await setCallgraphSVG(svgGraph);
36
- }
37
- if (graphvizLoaded && callgraphData != null && width != null) {
38
- void loadCallgraphSVG(callgraphData, width, colorRange);
39
- }
40
- }, [graphvizLoaded, callgraphData, width, colorRange]);
41
- return { graphvizLoaded, callgraphSVG };
42
- };
@@ -1,177 +0,0 @@
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
-
14
- import {useEffect, useRef, useState} from 'react';
15
-
16
- import cx from 'classnames';
17
- import * as d3 from 'd3';
18
- import SVG from 'react-inlinesvg';
19
- import {MapInteractionCSS} from 'react-map-interaction';
20
-
21
- import {CallgraphEdge, Callgraph as CallgraphType} from '@parca/client';
22
- import {Button, useKeyDown, useURLState} from '@parca/components';
23
- import {ProfileType} from '@parca/parser';
24
- import {selectDarkMode, setHoveringNode, useAppDispatch, useAppSelector} from '@parca/store';
25
- import {getNewSpanColor} from '@parca/utilities';
26
-
27
- import GraphTooltip from '../GraphTooltip';
28
-
29
- export interface Props {
30
- data: CallgraphType;
31
- svgString: string;
32
- profileType: ProfileType | undefined;
33
- width: number;
34
- }
35
-
36
- interface View {
37
- scale: number;
38
- translation: {x: number; y: number};
39
- }
40
-
41
- const Callgraph = ({data, svgString, profileType, width}: Props): JSX.Element => {
42
- const originalView = {
43
- scale: 1,
44
- translation: {x: 0, y: 0},
45
- };
46
- const [view, setView] = useState<View>(originalView);
47
- const containerRef = useRef(null);
48
- const svgRef = useRef(null);
49
- const svgWrapper = useRef(null);
50
- const [svgWrapperLoaded, setSvgWrapperLoaded] = useState(false);
51
- const dispatch = useAppDispatch();
52
- const {isShiftDown} = useKeyDown();
53
- // TODO: implement highlighting nodes on user search
54
- // const currentSearchString = (selectQueryParam('search_string') as string) ?? '';
55
- // const isSearchEmpty = currentSearchString === undefined || currentSearchString === '';
56
- // const isCurrentSearchMatch = isSearchEmpty
57
- // ? true
58
- // : isSearchMatch(currentSearchString, sourceNode.functionName) &&
59
- // isSearchMatch(currentSearchString, targetNode.functionName);
60
- const [dashboardItems] = useURLState<string[]>('dashboard_items', {
61
- alwaysReturnArray: true,
62
- });
63
-
64
- const isDarkMode = useAppSelector(selectDarkMode);
65
- const maxColor: string = getNewSpanColor(isDarkMode);
66
- const minColor: string = d3.scaleLinear([isDarkMode ? 'black' : 'white', maxColor])(0.3);
67
- const colorRange: [string, string] = [minColor, maxColor];
68
- const cumulatives = data.edges.map((edge: CallgraphEdge) => edge.cumulative.toString());
69
- const cumulativesRange = d3.extent(cumulatives);
70
- const colorScale = d3
71
- .scaleSequentialLog(d3.interpolateBlues)
72
- .domain([Number(cumulativesRange[0]), Number(cumulativesRange[1])])
73
- .range(colorRange);
74
-
75
- useEffect(() => {
76
- setSvgWrapperLoaded(true);
77
- }, []);
78
-
79
- useEffect(() => {
80
- if (svgWrapperLoaded && svgRef.current !== null) {
81
- const addInteraction = (): void => {
82
- const svg = d3.select(svgRef.current);
83
- const nodes = svg.selectAll('.node');
84
-
85
- nodes.each(function () {
86
- const nodeData = data.nodes.find((n): boolean => {
87
- return n.id === (this as Element).id;
88
- });
89
- const defaultColor = colorScale(Number(nodeData?.cumulative));
90
- const node = d3.select(this);
91
- const path = node.select('path');
92
-
93
- node
94
- .style('cursor', 'pointer')
95
- .on('mouseenter', function () {
96
- if (isShiftDown) return;
97
- d3.select(this).select('path').style('fill', 'white');
98
- const hoveringNode = {
99
- ...nodeData,
100
- meta: {...nodeData?.meta, lineIndex: 0, locationIndex: 0},
101
- };
102
- // @ts-expect-error
103
- dispatch(setHoveringNode(hoveringNode));
104
- })
105
- .on('mouseleave', function () {
106
- if (isShiftDown) return;
107
- d3.select(this).select('path').style('fill', defaultColor);
108
- dispatch(setHoveringNode(undefined));
109
- });
110
- path.style('fill', defaultColor);
111
- });
112
- };
113
-
114
- setTimeout(addInteraction, 1000);
115
- }
116
- // eslint-disable-next-line react-hooks/exhaustive-deps
117
- }, [svgWrapper.current, svgWrapperLoaded]);
118
-
119
- if (data.nodes.length < 1)
120
- return <div className="mx-auto text-center">Profile has no samples</div>;
121
-
122
- const resetView = (): void => setView(originalView);
123
-
124
- const isResetViewButtonEnabled =
125
- view.scale !== originalView.scale ||
126
- view.translation.x !== originalView.translation.x ||
127
- view.translation.y !== originalView.translation.y;
128
-
129
- return (
130
- <div className="relative w-full">
131
- <div ref={containerRef} className="w-full overflow-hidden">
132
- <MapInteractionCSS
133
- showControls
134
- minScale={1}
135
- maxScale={5}
136
- value={view}
137
- onChange={(value: View) => setView(value)}
138
- >
139
- <SVG
140
- ref={svgWrapper}
141
- src={svgString}
142
- width={width}
143
- height="auto"
144
- title="Callgraph"
145
- innerRef={svgRef}
146
- />
147
- </MapInteractionCSS>
148
- {svgRef.current !== null && (
149
- <GraphTooltip
150
- type="callgraph"
151
- unit={profileType?.sampleUnit ?? ''}
152
- total={data.cumulative}
153
- totalUnfiltered={data.cumulative}
154
- contextElement={containerRef.current}
155
- />
156
- )}
157
- </div>
158
- <div
159
- className={cx(
160
- dashboardItems.length > 1 ? 'left-[25px]' : 'left-0',
161
- 'absolute top-[-46px] w-auto'
162
- )}
163
- >
164
- <Button
165
- variant="neutral"
166
- onClick={resetView}
167
- className="z-50"
168
- disabled={!isResetViewButtonEnabled}
169
- >
170
- Reset View
171
- </Button>
172
- </div>
173
- </div>
174
- );
175
- };
176
-
177
- export default Callgraph;