@parca/profile 0.19.24 → 0.19.25

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 (31) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
  3. package/dist/ProfileView/components/ColorStackLegend.js +0 -1
  4. package/dist/ProfileView/components/DashboardItems/index.d.ts +3 -2
  5. package/dist/ProfileView/components/DashboardItems/index.d.ts.map +1 -1
  6. package/dist/ProfileView/components/DashboardItems/index.js +2 -2
  7. package/dist/ProfileView/index.d.ts +1 -1
  8. package/dist/ProfileView/index.d.ts.map +1 -1
  9. package/dist/ProfileView/index.js +2 -1
  10. package/dist/ProfileView/types/visualization.d.ts +6 -10
  11. package/dist/ProfileView/types/visualization.d.ts.map +1 -1
  12. package/dist/ProfileViewWithData.d.ts.map +1 -1
  13. package/dist/ProfileViewWithData.js +52 -22
  14. package/dist/Sandwich/components/CalleesSection.d.ts +3 -12
  15. package/dist/Sandwich/components/CalleesSection.d.ts.map +1 -1
  16. package/dist/Sandwich/components/CalleesSection.js +2 -4
  17. package/dist/Sandwich/components/CallersSection.d.ts +3 -13
  18. package/dist/Sandwich/components/CallersSection.d.ts.map +1 -1
  19. package/dist/Sandwich/components/CallersSection.js +5 -8
  20. package/dist/Sandwich/index.d.ts +2 -10
  21. package/dist/Sandwich/index.d.ts.map +1 -1
  22. package/dist/Sandwich/index.js +5 -103
  23. package/package.json +6 -6
  24. package/src/ProfileView/components/ColorStackLegend.tsx +0 -2
  25. package/src/ProfileView/components/DashboardItems/index.tsx +4 -12
  26. package/src/ProfileView/index.tsx +2 -0
  27. package/src/ProfileView/types/visualization.ts +7 -18
  28. package/src/ProfileViewWithData.tsx +65 -30
  29. package/src/Sandwich/components/CalleesSection.tsx +10 -28
  30. package/src/Sandwich/components/CallersSection.tsx +13 -34
  31. package/src/Sandwich/index.tsx +8 -170
@@ -50,8 +50,6 @@ const ColorStackLegend = ({mappings, compareMode = false, loading}: Props): Reac
50
50
  .map(f => f.value);
51
51
  }, [appliedFilters]);
52
52
 
53
- console.log('currentBinaryFilters', currentBinaryFilters);
54
-
55
53
  const mappingsList = useMappingList(mappings);
56
54
 
57
55
  const mappingColors = useMemo(() => {
@@ -24,6 +24,7 @@ import {SourceView} from '../../../SourceView';
24
24
  import {Table} from '../../../Table';
25
25
  import type {
26
26
  FlamegraphData,
27
+ SandwichData,
27
28
  SourceData,
28
29
  TopTableData,
29
30
  VisualizationType,
@@ -36,6 +37,7 @@ interface GetDashboardItemProps {
36
37
  flamegraphData: FlamegraphData;
37
38
  flamechartData: FlamegraphData;
38
39
  topTableData?: TopTableData;
40
+ sandwichData: SandwichData;
39
41
  sourceData?: SourceData;
40
42
  profileSource: ProfileSource;
41
43
  total: bigint;
@@ -58,13 +60,13 @@ export const getDashboardItem = ({
58
60
  flamechartData,
59
61
  topTableData,
60
62
  sourceData,
63
+ sandwichData,
61
64
  profileSource,
62
65
  total,
63
66
  filtered,
64
67
  curPathArrow,
65
68
  setNewCurPathArrow,
66
69
  perf,
67
- queryClient,
68
70
  }: GetDashboardItemProps): JSX.Element => {
69
71
  switch (type) {
70
72
  case 'flamegraph':
@@ -142,17 +144,7 @@ export const getDashboardItem = ({
142
144
  );
143
145
  case 'sandwich':
144
146
  return topTableData != null ? (
145
- <Sandwich
146
- total={total}
147
- filtered={filtered}
148
- loading={topTableData.loading}
149
- data={topTableData.arrow?.record}
150
- unit={topTableData.unit}
151
- profileType={profileSource?.ProfileType()}
152
- metadataMappingFiles={flamegraphData.metadataMappingFiles}
153
- profileSource={profileSource}
154
- queryClient={queryClient}
155
- />
147
+ <Sandwich profileSource={profileSource} sandwichData={sandwichData} />
156
148
  ) : (
157
149
  <></>
158
150
  );
@@ -44,6 +44,7 @@ export const ProfileView = ({
44
44
  pprofDownloading,
45
45
  compare,
46
46
  showVisualizationSelector,
47
+ sandwichData,
47
48
  }: ProfileViewProps): JSX.Element => {
48
49
  const {
49
50
  timezone,
@@ -88,6 +89,7 @@ export const ProfileView = ({
88
89
  isHalfScreen: boolean;
89
90
  }): JSX.Element => {
90
91
  return getDashboardItem({
92
+ sandwichData,
91
93
  type,
92
94
  isHalfScreen,
93
95
  dimensions,
@@ -11,20 +11,12 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
 
14
- import {
15
- Callgraph as CallgraphType,
16
- Flamegraph,
17
- FlamegraphArrow,
18
- QueryServiceClient,
19
- Source,
20
- TableArrow,
21
- } from '@parca/client';
14
+ import {FlamegraphArrow, QueryServiceClient, Source, TableArrow} from '@parca/client';
22
15
 
23
16
  import {ProfileSource} from '../../ProfileSource';
24
17
 
25
18
  export interface FlamegraphData {
26
19
  loading: boolean;
27
- data?: Flamegraph;
28
20
  arrow?: FlamegraphArrow;
29
21
  total?: bigint;
30
22
  filtered?: bigint;
@@ -43,20 +35,17 @@ export interface TopTableData {
43
35
  unit?: string;
44
36
  }
45
37
 
46
- export interface CallgraphData {
47
- loading: boolean;
48
- data?: CallgraphType;
49
- total?: bigint;
50
- filtered?: bigint;
51
- error?: any;
52
- }
53
-
54
38
  export interface SourceData {
55
39
  loading: boolean;
56
40
  data?: Source;
57
41
  error?: any;
58
42
  }
59
43
 
44
+ export interface SandwichData {
45
+ callees: FlamegraphData;
46
+ callers: FlamegraphData;
47
+ }
48
+
60
49
  export type VisualizationType =
61
50
  | 'flamegraph'
62
51
  | 'callgraph'
@@ -70,8 +59,8 @@ export interface ProfileViewProps {
70
59
  filtered: bigint;
71
60
  flamegraphData: FlamegraphData;
72
61
  flamechartData: FlamegraphData;
62
+ sandwichData: SandwichData;
73
63
  topTableData?: TopTableData;
74
- callgraphData?: CallgraphData;
75
64
  sourceData?: SourceData;
76
65
  profileSource: ProfileSource;
77
66
  queryClient?: QueryServiceClient;
@@ -47,6 +47,7 @@ export const ProfileViewWithData = ({
47
47
  defaultValue: [FIELD_FUNCTION_NAME],
48
48
  alwaysReturnArray: true,
49
49
  });
50
+ const [sandwichFunctionName] = useURLState<string | undefined>('sandwich_function_name');
50
51
 
51
52
  const [invertStack] = useURLState('invert_call_stack');
52
53
  const invertCallStack = invertStack === 'true';
@@ -131,15 +132,6 @@ export const ProfileViewWithData = ({
131
132
  protoFilters,
132
133
  });
133
134
 
134
- const {
135
- isLoading: callgraphLoading,
136
- response: callgraphResponse,
137
- error: callgraphError,
138
- } = useQuery(queryClient, profileSource, QueryRequest_ReportType.CALLGRAPH, {
139
- skip: !dashboardItems.includes('callgraph'),
140
- protoFilters,
141
- });
142
-
143
135
  const {
144
136
  isLoading: sourceLoading,
145
137
  response: sourceResponse,
@@ -151,6 +143,32 @@ export const ProfileViewWithData = ({
151
143
  protoFilters,
152
144
  });
153
145
 
146
+ const {
147
+ isLoading: callersFlamegraphLoading,
148
+ response: callersFlamegraphResponse,
149
+ error: callersFlamegraphError,
150
+ } = useQuery(queryClient, profileSource, QueryRequest_ReportType.FLAMEGRAPH_ARROW, {
151
+ nodeTrimThreshold,
152
+ groupBy: [FIELD_FUNCTION_NAME],
153
+ invertCallStack: true,
154
+ sandwichByFunction: sandwichFunctionName,
155
+ skip: sandwichFunctionName === undefined && !dashboardItems.includes('sandwich'),
156
+ protoFilters,
157
+ });
158
+
159
+ const {
160
+ isLoading: calleesFlamegraphLoading,
161
+ response: calleesFlamegraphResponse,
162
+ error: calleesFlamegraphError,
163
+ } = useQuery(queryClient, profileSource, QueryRequest_ReportType.FLAMEGRAPH_ARROW, {
164
+ nodeTrimThreshold,
165
+ groupBy: [FIELD_FUNCTION_NAME],
166
+ invertCallStack: false,
167
+ sandwichByFunction: sandwichFunctionName,
168
+ skip: sandwichFunctionName === undefined && !dashboardItems.includes('sandwich'),
169
+ protoFilters,
170
+ });
171
+
154
172
  useEffect(() => {
155
173
  if (
156
174
  (!flamegraphLoading && flamegraphResponse?.report.oneofKind === 'flamegraph') ||
@@ -163,18 +181,12 @@ export const ProfileViewWithData = ({
163
181
  perf?.markInteraction('table render', tableResponse.total);
164
182
  }
165
183
 
166
- if (!callgraphLoading && callgraphResponse?.report.oneofKind === 'callgraph') {
167
- perf?.markInteraction('Callgraph render', callgraphResponse.total);
168
- }
169
-
170
184
  if (!sourceLoading && sourceResponse?.report.oneofKind === 'source') {
171
185
  perf?.markInteraction('Source render', sourceResponse.total);
172
186
  }
173
187
  }, [
174
188
  flamegraphLoading,
175
189
  flamegraphResponse,
176
- callgraphResponse,
177
- callgraphLoading,
178
190
  tableLoading,
179
191
  tableResponse,
180
192
  sourceLoading,
@@ -210,15 +222,18 @@ export const ProfileViewWithData = ({
210
222
  } else if (tableResponse !== null) {
211
223
  total = BigInt(tableResponse.total);
212
224
  filtered = BigInt(tableResponse.filtered);
213
- } else if (callgraphResponse !== null) {
214
- total = BigInt(callgraphResponse.total);
215
- filtered = BigInt(callgraphResponse.filtered);
216
225
  } else if (sourceResponse !== null) {
217
226
  total = BigInt(sourceResponse.total);
218
227
  filtered = BigInt(sourceResponse.filtered);
219
228
  } else if (flamechartResponse !== null) {
220
229
  total = BigInt(flamechartResponse.total);
221
230
  filtered = BigInt(flamechartResponse.filtered);
231
+ } else if (callersFlamegraphResponse !== null) {
232
+ total = BigInt(callersFlamegraphResponse.total);
233
+ filtered = BigInt(callersFlamegraphResponse.filtered);
234
+ } else if (calleesFlamegraphResponse !== null) {
235
+ total = BigInt(calleesFlamegraphResponse.total);
236
+ filtered = BigInt(calleesFlamegraphResponse.filtered);
222
237
  }
223
238
 
224
239
  return (
@@ -227,10 +242,6 @@ export const ProfileViewWithData = ({
227
242
  filtered={filtered}
228
243
  flamegraphData={{
229
244
  loading: flamegraphLoading && profileMetadataLoading,
230
- data:
231
- flamegraphResponse?.report.oneofKind === 'flamegraph'
232
- ? flamegraphResponse?.report?.flamegraph
233
- : undefined,
234
245
  arrow:
235
246
  flamegraphResponse?.report.oneofKind === 'flamegraphArrow'
236
247
  ? flamegraphResponse?.report?.flamegraphArrow
@@ -279,14 +290,6 @@ export const ProfileViewWithData = ({
279
290
  ? tableResponse.report.tableArrow.unit
280
291
  : '',
281
292
  }}
282
- callgraphData={{
283
- loading: callgraphLoading,
284
- data:
285
- callgraphResponse?.report.oneofKind === 'callgraph'
286
- ? callgraphResponse?.report?.callgraph
287
- : undefined,
288
- error: callgraphError,
289
- }}
290
293
  sourceData={{
291
294
  loading: sourceLoading,
292
295
  data:
@@ -295,6 +298,38 @@ export const ProfileViewWithData = ({
295
298
  : undefined,
296
299
  error: sourceError,
297
300
  }}
301
+ sandwichData={{
302
+ callees: {
303
+ arrow:
304
+ calleesFlamegraphResponse?.report.oneofKind === 'flamegraphArrow'
305
+ ? calleesFlamegraphResponse?.report?.flamegraphArrow
306
+ : undefined,
307
+ loading: calleesFlamegraphLoading,
308
+ error: calleesFlamegraphError,
309
+ total: BigInt(calleesFlamegraphResponse?.total ?? '0'),
310
+ filtered: BigInt(calleesFlamegraphResponse?.filtered ?? '0'),
311
+ metadataMappingFiles:
312
+ profileMetadataResponse?.report.oneofKind === 'profileMetadata'
313
+ ? profileMetadataResponse?.report?.profileMetadata?.mappingFiles
314
+ : undefined,
315
+ metadataLoading: profileMetadataLoading,
316
+ },
317
+ callers: {
318
+ arrow:
319
+ callersFlamegraphResponse?.report.oneofKind === 'flamegraphArrow'
320
+ ? callersFlamegraphResponse?.report?.flamegraphArrow
321
+ : undefined,
322
+ loading: callersFlamegraphLoading,
323
+ error: callersFlamegraphError,
324
+ total: BigInt(callersFlamegraphResponse?.total ?? '0'),
325
+ filtered: BigInt(callersFlamegraphResponse?.filtered ?? '0'),
326
+ metadataMappingFiles:
327
+ profileMetadataResponse?.report.oneofKind === 'profileMetadata'
328
+ ? profileMetadataResponse?.report?.profileMetadata?.mappingFiles
329
+ : undefined,
330
+ metadataLoading: profileMetadataLoading,
331
+ },
332
+ }}
298
333
  profileSource={profileSource}
299
334
  queryClient={queryClient}
300
335
  onDownloadPProf={() => void downloadPProfClick()}
@@ -13,24 +13,14 @@
13
13
 
14
14
  import React from 'react';
15
15
 
16
- import {type FlamegraphArrow} from '@parca/client';
17
-
18
16
  import ProfileFlameGraph from '../../ProfileFlameGraph';
19
17
  import {type CurrentPathFrame} from '../../ProfileFlameGraph/FlameGraphArrow/utils';
20
18
  import {type ProfileSource} from '../../ProfileSource';
19
+ import {FlamegraphData} from '../../ProfileView/types/visualization';
21
20
 
22
21
  interface CalleesSectionProps {
23
22
  calleesRef: React.RefObject<HTMLDivElement>;
24
- calleesFlamegraphResponse?: {
25
- report: {
26
- oneofKind: string;
27
- flamegraphArrow?: FlamegraphArrow;
28
- };
29
- total?: string;
30
- };
31
- calleesFlamegraphLoading: boolean;
32
- calleesFlamegraphError: any;
33
- filtered: bigint;
23
+ calleesFlamegraphData: FlamegraphData;
34
24
  profileSource: ProfileSource;
35
25
  curPathArrow: CurrentPathFrame[];
36
26
  setCurPathArrow: (path: CurrentPathFrame[]) => void;
@@ -39,14 +29,10 @@ interface CalleesSectionProps {
39
29
 
40
30
  export function CalleesSection({
41
31
  calleesRef,
42
- calleesFlamegraphResponse,
43
- calleesFlamegraphLoading,
44
- calleesFlamegraphError,
45
- filtered,
32
+ calleesFlamegraphData,
46
33
  profileSource,
47
34
  curPathArrow,
48
35
  setCurPathArrow,
49
- metadataMappingFiles,
50
36
  }: CalleesSectionProps): JSX.Element {
51
37
  return (
52
38
  <div className="flex relative items-start flex-row" ref={calleesRef}>
@@ -54,22 +40,18 @@ export function CalleesSection({
54
40
  {'<-'} Callees
55
41
  </div>
56
42
  <ProfileFlameGraph
57
- arrow={
58
- calleesFlamegraphResponse?.report.oneofKind === 'flamegraphArrow'
59
- ? calleesFlamegraphResponse?.report?.flamegraphArrow
60
- : undefined
61
- }
62
- total={BigInt(calleesFlamegraphResponse?.total ?? '0')}
63
- filtered={filtered}
43
+ arrow={calleesFlamegraphData?.arrow}
44
+ total={calleesFlamegraphData.total ?? BigInt(0)}
45
+ filtered={calleesFlamegraphData.filtered ?? BigInt(0)}
64
46
  profileType={profileSource?.ProfileType()}
65
- loading={calleesFlamegraphLoading}
66
- error={calleesFlamegraphError}
47
+ loading={calleesFlamegraphData.loading}
48
+ error={calleesFlamegraphData.error}
67
49
  isHalfScreen={true}
68
50
  width={
69
51
  calleesRef.current != null ? calleesRef.current.getBoundingClientRect().width - 25 : 0
70
52
  }
71
- metadataMappingFiles={metadataMappingFiles}
72
- metadataLoading={false}
53
+ metadataMappingFiles={calleesFlamegraphData.metadataMappingFiles}
54
+ metadataLoading={calleesFlamegraphData.metadataLoading}
73
55
  isInSandwichView={true}
74
56
  curPathArrow={curPathArrow}
75
57
  setNewCurPathArrow={setCurPathArrow}
@@ -16,12 +16,12 @@ import React, {useMemo} from 'react';
16
16
  import {Vector, tableFromIPC} from 'apache-arrow';
17
17
  import {Tooltip} from 'react-tooltip';
18
18
 
19
- import {type FlamegraphArrow} from '@parca/client';
20
19
  import {Button} from '@parca/components';
21
20
 
22
21
  import ProfileFlameGraph from '../../ProfileFlameGraph';
23
22
  import {type CurrentPathFrame} from '../../ProfileFlameGraph/FlameGraphArrow/utils';
24
23
  import {type ProfileSource} from '../../ProfileSource';
24
+ import {FlamegraphData} from '../../ProfileView/types/visualization';
25
25
 
26
26
  const FIELD_DEPTH = 'depth';
27
27
 
@@ -38,20 +38,10 @@ function getMaxDepth(depthColumn: Vector<any> | null): number {
38
38
 
39
39
  interface CallersSectionProps {
40
40
  callersRef: React.RefObject<HTMLDivElement>;
41
- callersFlamegraphResponse?: {
42
- report: {
43
- oneofKind: string;
44
- flamegraphArrow?: FlamegraphArrow;
45
- };
46
- total?: string;
47
- };
48
- callersFlamegraphLoading: boolean;
49
- callersFlamegraphError: any;
50
- filtered: bigint;
41
+ callersFlamegraphData: FlamegraphData;
51
42
  profileSource: ProfileSource;
52
43
  curPathArrow: CurrentPathFrame[];
53
44
  setCurPathArrow: (path: CurrentPathFrame[]) => void;
54
- metadataMappingFiles?: string[];
55
45
  isExpanded: boolean;
56
46
  setIsExpanded: (isExpanded: boolean) => void;
57
47
  defaultMaxFrames: number;
@@ -59,29 +49,22 @@ interface CallersSectionProps {
59
49
 
60
50
  export function CallersSection({
61
51
  callersRef,
62
- callersFlamegraphResponse,
63
- callersFlamegraphLoading,
64
- callersFlamegraphError,
65
- filtered,
52
+ callersFlamegraphData,
66
53
  profileSource,
67
54
  curPathArrow,
68
55
  setCurPathArrow,
69
- metadataMappingFiles,
70
56
  isExpanded,
71
57
  setIsExpanded,
72
58
  defaultMaxFrames,
73
59
  }: CallersSectionProps): JSX.Element {
74
60
  const maxDepth = useMemo(() => {
75
- if (
76
- callersFlamegraphResponse?.report.oneofKind === 'flamegraphArrow' &&
77
- callersFlamegraphResponse?.report?.flamegraphArrow != null
78
- ) {
79
- const table = tableFromIPC(callersFlamegraphResponse.report.flamegraphArrow.record);
61
+ if (callersFlamegraphData?.arrow != null) {
62
+ const table = tableFromIPC(callersFlamegraphData.arrow.record);
80
63
  const depthColumn = table.getChild(FIELD_DEPTH);
81
64
  return getMaxDepth(depthColumn);
82
65
  }
83
66
  return 0;
84
- }, [callersFlamegraphResponse]);
67
+ }, [callersFlamegraphData]);
85
68
 
86
69
  const shouldShowButton = maxDepth > defaultMaxFrames;
87
70
 
@@ -113,22 +96,18 @@ export function CallersSection({
113
96
  </div>
114
97
  <div className="flex-1 overflow-hidden relative">
115
98
  <ProfileFlameGraph
116
- arrow={
117
- callersFlamegraphResponse?.report.oneofKind === 'flamegraphArrow'
118
- ? callersFlamegraphResponse?.report?.flamegraphArrow
119
- : undefined
120
- }
121
- total={BigInt(callersFlamegraphResponse?.total ?? '0')}
122
- filtered={filtered}
99
+ arrow={callersFlamegraphData?.arrow}
100
+ total={callersFlamegraphData.total ?? BigInt(0)}
101
+ filtered={callersFlamegraphData.filtered ?? BigInt(0)}
123
102
  profileType={profileSource?.ProfileType()}
124
- loading={callersFlamegraphLoading}
125
- error={callersFlamegraphError}
103
+ loading={callersFlamegraphData.loading}
104
+ error={callersFlamegraphData.error}
126
105
  isHalfScreen={true}
127
106
  width={
128
107
  callersRef.current != null ? callersRef.current.getBoundingClientRect().width - 25 : 0
129
108
  }
130
- metadataMappingFiles={metadataMappingFiles}
131
- metadataLoading={false}
109
+ metadataMappingFiles={callersFlamegraphData.metadataMappingFiles}
110
+ metadataLoading={callersFlamegraphData.metadataLoading}
132
111
  isInSandwichView={true}
133
112
  curPathArrow={curPathArrow}
134
113
  setNewCurPathArrow={setCurPathArrow}