@parca/profile 0.16.0 → 0.16.22

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 (93) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/Callgraph/Edge/index.d.ts +22 -0
  3. package/dist/Callgraph/Edge/index.js +30 -0
  4. package/dist/Callgraph/Node/index.d.ts +19 -0
  5. package/dist/Callgraph/Node/index.js +37 -0
  6. package/dist/Callgraph/index.d.ts +8 -0
  7. package/dist/Callgraph/index.js +137 -0
  8. package/dist/Callgraph/mockData/index.d.ts +148 -0
  9. package/dist/Callgraph/mockData/index.js +577 -0
  10. package/dist/Callgraph/utils.d.ts +19 -0
  11. package/dist/Callgraph/utils.js +82 -0
  12. package/dist/GraphTooltip/index.d.ts +19 -0
  13. package/dist/GraphTooltip/index.js +119 -0
  14. package/dist/IcicleGraph.d.ts +35 -0
  15. package/dist/IcicleGraph.js +139 -0
  16. package/dist/MatchersInput/index.d.ts +23 -0
  17. package/dist/MatchersInput/index.js +479 -0
  18. package/dist/MetricsCircle/index.d.ts +7 -0
  19. package/dist/MetricsCircle/index.js +18 -0
  20. package/dist/MetricsGraph/index.d.ts +35 -0
  21. package/dist/MetricsGraph/index.js +349 -0
  22. package/dist/MetricsSeries/index.d.ts +11 -0
  23. package/dist/MetricsSeries/index.js +21 -0
  24. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts +19 -0
  25. package/dist/ProfileExplorer/ProfileExplorerCompare.js +38 -0
  26. package/dist/ProfileExplorer/ProfileExplorerSingle.d.ts +15 -0
  27. package/dist/ProfileExplorer/ProfileExplorerSingle.js +19 -0
  28. package/dist/ProfileExplorer/index.d.ts +9 -0
  29. package/dist/ProfileExplorer/index.js +203 -0
  30. package/dist/ProfileIcicleGraph.d.ts +10 -0
  31. package/dist/ProfileIcicleGraph.js +28 -0
  32. package/dist/ProfileMetricsGraph/index.d.ts +22 -0
  33. package/dist/ProfileMetricsGraph/index.js +127 -0
  34. package/dist/ProfileSVG.module.css +3 -0
  35. package/dist/ProfileSelector/CompareButton.d.ts +5 -0
  36. package/dist/ProfileSelector/CompareButton.js +41 -0
  37. package/dist/ProfileSelector/MergeButton.d.ts +5 -0
  38. package/dist/ProfileSelector/MergeButton.js +41 -0
  39. package/dist/ProfileSelector/index.d.ts +29 -0
  40. package/dist/ProfileSelector/index.js +133 -0
  41. package/dist/ProfileSource.d.ts +88 -0
  42. package/dist/ProfileSource.js +239 -0
  43. package/dist/ProfileTypeSelector/index.d.ts +20 -0
  44. package/dist/ProfileTypeSelector/index.js +138 -0
  45. package/dist/ProfileView.d.ts +39 -0
  46. package/dist/ProfileView.js +111 -0
  47. package/dist/ProfileView.styles.css +3 -0
  48. package/dist/ProfileViewWithData.d.ts +11 -0
  49. package/dist/ProfileViewWithData.js +116 -0
  50. package/dist/TopTable.d.ts +9 -0
  51. package/dist/TopTable.js +140 -0
  52. package/dist/TopTable.styles.css +7 -0
  53. package/dist/components/DiffLegend.d.ts +2 -0
  54. package/dist/components/DiffLegend.js +62 -0
  55. package/dist/components/ProfileShareButton/ResultBox.d.ts +6 -0
  56. package/dist/components/ProfileShareButton/ResultBox.js +46 -0
  57. package/dist/components/ProfileShareButton/index.d.ts +7 -0
  58. package/dist/components/ProfileShareButton/index.js +119 -0
  59. package/dist/index.d.ts +13 -0
  60. package/dist/index.js +64 -0
  61. package/dist/styles.css +1 -0
  62. package/dist/useDelayedLoader.d.ts +5 -0
  63. package/dist/useDelayedLoader.js +33 -0
  64. package/dist/useQuery.d.ts +13 -0
  65. package/dist/useQuery.js +41 -0
  66. package/dist/utils.d.ts +4 -0
  67. package/dist/utils.js +83 -0
  68. package/package.json +12 -8
  69. package/src/Callgraph/Edge/index.tsx +59 -0
  70. package/src/Callgraph/Node/index.tsx +66 -0
  71. package/src/Callgraph/index.tsx +169 -0
  72. package/src/Callgraph/mockData/index.ts +605 -0
  73. package/src/Callgraph/utils.ts +116 -0
  74. package/src/GraphTooltip/index.tsx +245 -0
  75. package/src/IcicleGraph.tsx +3 -3
  76. package/src/MatchersInput/index.tsx +698 -0
  77. package/src/MetricsCircle/index.tsx +28 -0
  78. package/src/MetricsGraph/index.tsx +614 -0
  79. package/src/MetricsSeries/index.tsx +38 -0
  80. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +109 -0
  81. package/src/ProfileExplorer/ProfileExplorerSingle.tsx +72 -0
  82. package/src/ProfileExplorer/index.tsx +377 -0
  83. package/src/ProfileMetricsGraph/index.tsx +143 -0
  84. package/src/ProfileSelector/CompareButton.tsx +72 -0
  85. package/src/ProfileSelector/MergeButton.tsx +72 -0
  86. package/src/ProfileSelector/index.tsx +270 -0
  87. package/src/ProfileTypeSelector/index.tsx +180 -0
  88. package/src/ProfileView.tsx +2 -7
  89. package/src/index.tsx +11 -0
  90. package/src/useQuery.tsx +1 -0
  91. package/tailwind.config.js +8 -0
  92. package/tsconfig.json +7 -3
  93. package/typings.d.ts +14 -0
@@ -0,0 +1,245 @@
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 {CallgraphNode, FlamegraphNode, FlamegraphRootNode} from '@parca/client';
15
+ import {getLastItem, valueFormatter} from '@parca/functions';
16
+ import {hexifyAddress} from '../';
17
+ import {useState, useEffect} from 'react';
18
+ import {usePopper} from 'react-popper';
19
+
20
+ interface GraphTooltipProps {
21
+ x: number;
22
+ y: number;
23
+ unit: string;
24
+ total: number;
25
+ hoveringNode: HoveringNode;
26
+ contextElement: Element | null;
27
+ isFixed?: boolean;
28
+ virtualContextElement?: boolean;
29
+ }
30
+
31
+ const virtualElement = {
32
+ getBoundingClientRect: () =>
33
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
34
+ ({
35
+ width: 0,
36
+ height: 0,
37
+ top: 0,
38
+ left: 0,
39
+ right: 0,
40
+ bottom: 0,
41
+ } as DOMRect),
42
+ };
43
+
44
+ function generateGetBoundingClientRect(contextElement: Element, x = 0, y = 0): () => DOMRect {
45
+ const domRect = contextElement.getBoundingClientRect();
46
+ return () =>
47
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
48
+ ({
49
+ width: 0,
50
+ height: 0,
51
+ top: domRect.y + y,
52
+ left: domRect.x + x,
53
+ right: domRect.x + x,
54
+ bottom: domRect.y + y,
55
+ } as DOMRect);
56
+ }
57
+
58
+ const TooltipMetaInfo = ({hoveringNode}: {hoveringNode: FlamegraphNode}): JSX.Element => {
59
+ if (hoveringNode.meta === undefined) return <></>;
60
+
61
+ return (
62
+ <>
63
+ {hoveringNode.meta.function?.filename !== undefined &&
64
+ hoveringNode.meta.function?.filename !== '' && (
65
+ <tr>
66
+ <td className="w-1/5">File</td>
67
+ <td className="w-4/5 break-all">
68
+ {hoveringNode.meta.function.filename}
69
+ {hoveringNode.meta.line?.line !== undefined && hoveringNode.meta.line?.line !== '0'
70
+ ? ` +${hoveringNode.meta.line.line.toString()}`
71
+ : `${
72
+ hoveringNode.meta.function?.startLine !== undefined &&
73
+ hoveringNode.meta.function?.startLine !== '0'
74
+ ? ` +${hoveringNode.meta.function.startLine}`
75
+ : ''
76
+ }`}
77
+ </td>
78
+ </tr>
79
+ )}
80
+ {hoveringNode.meta.location?.address !== undefined &&
81
+ hoveringNode.meta.location?.address !== '0' && (
82
+ <tr>
83
+ <td className="w-1/5">Address</td>
84
+ <td className="w-4/5 break-all">
85
+ {' 0x' + hoveringNode.meta.location.address.toString()}
86
+ </td>
87
+ </tr>
88
+ )}
89
+ {hoveringNode.meta.mapping !== undefined && hoveringNode.meta.mapping.file !== '' && (
90
+ <tr>
91
+ <td className="w-1/5">Binary</td>
92
+ <td className="w-4/5 break-all">{getLastItem(hoveringNode.meta.mapping.file)}</td>
93
+ </tr>
94
+ )}
95
+ </>
96
+ );
97
+ };
98
+
99
+ export interface HoveringNode extends CallgraphNode, FlamegraphRootNode {
100
+ diff: string;
101
+ meta?: {[key: string]: any};
102
+ }
103
+
104
+ const GraphTooltipContent = ({
105
+ hoveringNode,
106
+ unit,
107
+ total,
108
+ isFixed,
109
+ }: {
110
+ hoveringNode: HoveringNode;
111
+ unit: string;
112
+ total: number;
113
+ isFixed: boolean;
114
+ }): JSX.Element => {
115
+ const hoveringNodeCumulative = parseFloat(hoveringNode.cumulative);
116
+ const diff = hoveringNode.diff === undefined ? 0 : parseFloat(hoveringNode.diff);
117
+ const prevValue = hoveringNodeCumulative - diff;
118
+ const diffRatio = Math.abs(diff) > 0 ? diff / prevValue : 0;
119
+ const diffSign = diff > 0 ? '+' : '';
120
+ const diffValueText = diffSign + valueFormatter(diff, unit, 1);
121
+ const diffPercentageText = diffSign + (diffRatio * 100).toFixed(2) + '%';
122
+ const diffText = `${diffValueText} (${diffPercentageText})`;
123
+ const metaRows =
124
+ hoveringNode.meta === undefined ? <></> : <TooltipMetaInfo hoveringNode={hoveringNode} />;
125
+
126
+ return (
127
+ <div className={`flex ${isFixed ? 'w-full h-36' : ''}`}>
128
+ <div className={`m-auto w-full ${isFixed ? 'w-full h-36' : ''}`}>
129
+ <div
130
+ className="border-gray-300 dark:border-gray-500 bg-gray-50 dark:bg-gray-900 rounded-lg p-3 shadow-lg opacity-90"
131
+ style={{borderWidth: 1}}
132
+ >
133
+ <div className="flex flex-row">
134
+ <div className="ml-2 mr-6">
135
+ <span className="font-semibold break-all">
136
+ {hoveringNode.meta === undefined ? (
137
+ <p>root</p>
138
+ ) : (
139
+ <>
140
+ {hoveringNode.meta.function !== undefined &&
141
+ hoveringNode.meta.function.name !== '' ? (
142
+ <p>{hoveringNode.meta.function.name}</p>
143
+ ) : (
144
+ <>
145
+ {hoveringNode.meta.location !== undefined &&
146
+ parseInt(hoveringNode.meta.location.address, 10) !== 0 ? (
147
+ <p>{hexifyAddress(hoveringNode.meta.location.address)}</p>
148
+ ) : (
149
+ <p>unknown</p>
150
+ )}
151
+ </>
152
+ )}
153
+ </>
154
+ )}
155
+ </span>
156
+ <span className="text-gray-700 dark:text-gray-300 my-2">
157
+ <table className="table-fixed">
158
+ <tbody>
159
+ <tr>
160
+ <td className="w-1/5">Cumulative</td>
161
+ <td className="w-4/5">
162
+ {valueFormatter(hoveringNodeCumulative, unit, 2)} (
163
+ {((hoveringNodeCumulative * 100) / total).toFixed(2)}%)
164
+ </td>
165
+ </tr>
166
+ {hoveringNode.diff !== undefined && diff !== 0 && (
167
+ <tr>
168
+ <td className="w-1/5">Diff</td>
169
+ <td className="w-4/5">{diffText}</td>
170
+ </tr>
171
+ )}
172
+ {metaRows}
173
+ </tbody>
174
+ </table>
175
+ </span>
176
+ </div>
177
+ </div>
178
+ </div>
179
+ </div>
180
+ </div>
181
+ );
182
+ };
183
+
184
+ const GraphTooltip = ({
185
+ x,
186
+ y,
187
+ unit,
188
+ total,
189
+ hoveringNode,
190
+ contextElement,
191
+ isFixed = false,
192
+ virtualContextElement = true,
193
+ }: GraphTooltipProps): JSX.Element => {
194
+ const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);
195
+
196
+ const {styles, attributes, ...popperProps} = usePopper(
197
+ virtualContextElement ? virtualElement : contextElement,
198
+ popperElement,
199
+ {
200
+ placement: 'auto-start',
201
+ strategy: 'absolute',
202
+ modifiers: [
203
+ {
204
+ name: 'preventOverflow',
205
+ options: {
206
+ tether: false,
207
+ altAxis: true,
208
+ },
209
+ },
210
+ {
211
+ name: 'offset',
212
+ options: {
213
+ offset: [30, 30],
214
+ },
215
+ },
216
+ ],
217
+ }
218
+ );
219
+
220
+ const update = popperProps.update;
221
+
222
+ useEffect(() => {
223
+ if (contextElement != null) {
224
+ virtualElement.getBoundingClientRect = generateGetBoundingClientRect(contextElement, x, y);
225
+ void update?.();
226
+ }
227
+ }, [x, y, contextElement, update]);
228
+
229
+ if (hoveringNode === undefined || hoveringNode == null) return <></>;
230
+
231
+ return isFixed ? (
232
+ <GraphTooltipContent hoveringNode={hoveringNode} unit={unit} total={total} isFixed={isFixed} />
233
+ ) : (
234
+ <div ref={setPopperElement} style={styles.popper} {...attributes.popper}>
235
+ <GraphTooltipContent
236
+ hoveringNode={hoveringNode}
237
+ unit={unit}
238
+ total={total}
239
+ isFixed={isFixed}
240
+ />
241
+ </div>
242
+ );
243
+ };
244
+
245
+ export default GraphTooltip;
@@ -17,12 +17,12 @@ import {throttle} from 'lodash';
17
17
  import {pointer} from 'd3-selection';
18
18
  import {scaleLinear} from 'd3-scale';
19
19
  import {Flamegraph, FlamegraphNode, FlamegraphRootNode} from '@parca/client';
20
- import {GraphTooltip} from '@parca/components';
20
+ import GraphTooltip from './GraphTooltip';
21
21
  import {getLastItem, diffColor, isSearchMatch} from '@parca/functions';
22
22
  import {useAppSelector, selectDarkMode, selectSearchNodeString} from '@parca/store';
23
23
 
24
24
  import {hexifyAddress} from './utils';
25
- import {HoveringNode} from '@parca/components/src/GraphTooltip';
25
+ import type {HoveringNode} from './GraphTooltip';
26
26
 
27
27
  interface IcicleGraphProps {
28
28
  graph: Flamegraph;
@@ -181,7 +181,7 @@ export function IcicleGraphNodes({
181
181
  : xScale(cumulative);
182
182
 
183
183
  if (width <= 1) {
184
- return <></>;
184
+ return null;
185
185
  }
186
186
 
187
187
  const name = nodeLabel(d);