@parca/profile 0.19.24 → 0.19.26
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/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +8 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/index.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +33 -40
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.d.ts +8 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.d.ts.map +1 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +70 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.d.ts +24 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.d.ts.map +1 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +111 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.d.ts +2 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +11 -0
- package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
- package/dist/ProfileView/components/ColorStackLegend.js +0 -1
- package/dist/ProfileView/components/DashboardItems/index.d.ts +3 -2
- package/dist/ProfileView/components/DashboardItems/index.d.ts.map +1 -1
- package/dist/ProfileView/components/DashboardItems/index.js +2 -2
- package/dist/ProfileView/index.d.ts +1 -1
- package/dist/ProfileView/index.d.ts.map +1 -1
- package/dist/ProfileView/index.js +2 -1
- package/dist/ProfileView/types/visualization.d.ts +6 -10
- package/dist/ProfileView/types/visualization.d.ts.map +1 -1
- package/dist/ProfileViewWithData.d.ts.map +1 -1
- package/dist/ProfileViewWithData.js +52 -22
- package/dist/Sandwich/components/CalleesSection.d.ts +3 -12
- package/dist/Sandwich/components/CalleesSection.d.ts.map +1 -1
- package/dist/Sandwich/components/CalleesSection.js +2 -4
- package/dist/Sandwich/components/CallersSection.d.ts +3 -13
- package/dist/Sandwich/components/CallersSection.d.ts.map +1 -1
- package/dist/Sandwich/components/CallersSection.js +5 -8
- package/dist/Sandwich/index.d.ts +2 -10
- package/dist/Sandwich/index.d.ts.map +1 -1
- package/dist/Sandwich/index.js +5 -103
- package/dist/styles.css +1 -1
- package/package.json +6 -6
- package/src/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.tsx +214 -200
- package/src/ProfileFlameGraph/FlameGraphArrow/index.tsx +75 -76
- package/src/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.ts +89 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.ts +167 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/utils.ts +12 -1
- package/src/ProfileView/components/ColorStackLegend.tsx +0 -2
- package/src/ProfileView/components/DashboardItems/index.tsx +4 -12
- package/src/ProfileView/index.tsx +2 -0
- package/src/ProfileView/types/visualization.ts +7 -18
- package/src/ProfileViewWithData.tsx +65 -30
- package/src/Sandwich/components/CalleesSection.tsx +10 -28
- package/src/Sandwich/components/CallersSection.tsx +13 -34
- package/src/Sandwich/index.tsx +8 -170
|
@@ -0,0 +1,89 @@
|
|
|
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 {useCallback, useEffect, useRef, useState} from 'react';
|
|
15
|
+
|
|
16
|
+
export interface ViewportState {
|
|
17
|
+
scrollTop: number;
|
|
18
|
+
scrollLeft: number;
|
|
19
|
+
containerHeight: number;
|
|
20
|
+
containerWidth: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const useScrollViewport = (containerRef: React.RefObject<HTMLDivElement>): ViewportState => {
|
|
24
|
+
const [viewport, setViewport] = useState<ViewportState>({
|
|
25
|
+
scrollTop: 0,
|
|
26
|
+
scrollLeft: 0,
|
|
27
|
+
containerHeight: 0,
|
|
28
|
+
containerWidth: 0,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const throttleRef = useRef<number | null>(null);
|
|
32
|
+
|
|
33
|
+
const updateViewport = useCallback(() => {
|
|
34
|
+
if (containerRef.current !== null) {
|
|
35
|
+
const container = containerRef.current;
|
|
36
|
+
|
|
37
|
+
const newViewport = {
|
|
38
|
+
scrollTop: container.scrollTop,
|
|
39
|
+
scrollLeft: container.scrollLeft,
|
|
40
|
+
containerHeight: container.clientHeight,
|
|
41
|
+
containerWidth: container.clientWidth,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
setViewport(newViewport);
|
|
45
|
+
}
|
|
46
|
+
}, [containerRef]);
|
|
47
|
+
|
|
48
|
+
// Throttling Strategy:
|
|
49
|
+
// Use requestAnimationFrame to throttle scroll events to 60fps max
|
|
50
|
+
// This ensures smooth performance while preventing excessive re-renders
|
|
51
|
+
const throttledUpdateViewport = useCallback(() => {
|
|
52
|
+
if (throttleRef.current !== null) {
|
|
53
|
+
cancelAnimationFrame(throttleRef.current);
|
|
54
|
+
}
|
|
55
|
+
throttleRef.current = requestAnimationFrame(updateViewport);
|
|
56
|
+
}, [updateViewport]);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const container = containerRef.current;
|
|
60
|
+
if (container === null) return;
|
|
61
|
+
|
|
62
|
+
// ResizeObserver Strategy:
|
|
63
|
+
// Monitor container size changes (window resize, layout shifts)
|
|
64
|
+
// to update viewport dimensions for accurate culling calculations
|
|
65
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
66
|
+
throttledUpdateViewport();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Container Scroll Event Strategy:
|
|
70
|
+
// Use passive event listeners for better scroll performance
|
|
71
|
+
// Throttle with requestAnimationFrame to maintain 60fps target
|
|
72
|
+
container.addEventListener('scroll', throttledUpdateViewport, {passive: true});
|
|
73
|
+
resizeObserver.observe(container);
|
|
74
|
+
|
|
75
|
+
// Initialize viewport state on mount
|
|
76
|
+
updateViewport();
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
// Cleanup: Remove event listeners and cancel pending animations
|
|
80
|
+
container.removeEventListener('scroll', throttledUpdateViewport);
|
|
81
|
+
resizeObserver.disconnect();
|
|
82
|
+
if (throttleRef.current !== null) {
|
|
83
|
+
cancelAnimationFrame(throttleRef.current);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}, [containerRef, throttledUpdateViewport, updateViewport]);
|
|
87
|
+
|
|
88
|
+
return viewport;
|
|
89
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
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 {useMemo, useRef} from 'react';
|
|
15
|
+
|
|
16
|
+
import {Table} from 'apache-arrow';
|
|
17
|
+
|
|
18
|
+
import {RowHeight} from './FlameGraphNodes';
|
|
19
|
+
import {FIELD_CUMULATIVE, FIELD_DEPTH, FIELD_VALUE_OFFSET} from './index';
|
|
20
|
+
import {ViewportState} from './useScrollViewport';
|
|
21
|
+
import {getMaxDepth} from './utils';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This function groups rows by their depth level.
|
|
25
|
+
* Instead of scanning all rows to find depth matches, we pre-compute
|
|
26
|
+
* buckets so viewport rendering only examines depth ranges that are relevant.
|
|
27
|
+
*/
|
|
28
|
+
const useDepthBuckets = <TRow extends Record<string, any>>(
|
|
29
|
+
table: Table<TRow> | undefined
|
|
30
|
+
): number[][] => {
|
|
31
|
+
return useMemo(() => {
|
|
32
|
+
if (table === undefined) return [];
|
|
33
|
+
|
|
34
|
+
const depthColumn = table.getChild(FIELD_DEPTH);
|
|
35
|
+
if (depthColumn === null) return [];
|
|
36
|
+
|
|
37
|
+
// Find max depth
|
|
38
|
+
const maxDepth = getMaxDepth(depthColumn);
|
|
39
|
+
|
|
40
|
+
// Create buckets for each depth level
|
|
41
|
+
const buckets: number[][] = Array.from({length: maxDepth + 1}, () => []);
|
|
42
|
+
|
|
43
|
+
// Populate buckets with row indices
|
|
44
|
+
for (let row = 0; row < table.numRows; row++) {
|
|
45
|
+
const depth = depthColumn.get(row) ?? 0;
|
|
46
|
+
buckets[depth].push(row);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return buckets;
|
|
50
|
+
}, [table]);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export interface UseVisibleNodesParams {
|
|
54
|
+
table: Table<any>;
|
|
55
|
+
viewport: ViewportState;
|
|
56
|
+
total: bigint;
|
|
57
|
+
width: number;
|
|
58
|
+
selectedRow: number;
|
|
59
|
+
effectiveDepth: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* useVisibleNodes returns row indices visible in the current viewport through multi-stage culling.
|
|
64
|
+
* Combines depth buckets, horizontal bounds checking, and size filtering to
|
|
65
|
+
* minimize rendered nodes from potentially 100K+ rows to ~hundreds.
|
|
66
|
+
*
|
|
67
|
+
* We use depth buckets to only iterate through the rows that are visible in the viewport vertically.
|
|
68
|
+
* After that we use horizontal bounds checking to only iterate through the rows that are visible in the viewport horizontally.
|
|
69
|
+
* Finally we use size filtering to only iterate through the rows that are visible in the viewport by size.
|
|
70
|
+
*
|
|
71
|
+
* Critical for maintaining 60fps performance on large flamegraphs where
|
|
72
|
+
* rendering all nodes would freeze the browser.
|
|
73
|
+
*/
|
|
74
|
+
export const useVisibleNodes = ({
|
|
75
|
+
table,
|
|
76
|
+
viewport,
|
|
77
|
+
total,
|
|
78
|
+
width,
|
|
79
|
+
selectedRow,
|
|
80
|
+
effectiveDepth,
|
|
81
|
+
}: UseVisibleNodesParams): number[] => {
|
|
82
|
+
const depthBuckets = useDepthBuckets(table);
|
|
83
|
+
const lastResultRef = useRef<{
|
|
84
|
+
key: string;
|
|
85
|
+
result: number[];
|
|
86
|
+
}>({key: '', result: []});
|
|
87
|
+
|
|
88
|
+
return useMemo(() => {
|
|
89
|
+
// Create a stable key for memoization to prevent unnecessary recalculations
|
|
90
|
+
const memoKey = `${viewport.scrollTop}-${viewport.containerHeight}-${selectedRow}-${effectiveDepth}-${width}`;
|
|
91
|
+
|
|
92
|
+
// Return cached result if viewport hasn't meaningfully changed
|
|
93
|
+
if (lastResultRef.current.key === memoKey) {
|
|
94
|
+
return lastResultRef.current.result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (table === null || viewport.containerHeight === 0) return [];
|
|
98
|
+
|
|
99
|
+
const visibleRows: number[] = [];
|
|
100
|
+
const {scrollTop, containerHeight} = viewport;
|
|
101
|
+
|
|
102
|
+
// Viewport Culling Algorithm:
|
|
103
|
+
// 1. Calculate visible depth range based on scroll position and container height
|
|
104
|
+
// 2. Add 5-row buffer above/below for smooth scrolling experience
|
|
105
|
+
const startDepth = Math.max(0, Math.floor(scrollTop / RowHeight) - 5);
|
|
106
|
+
const endDepth = Math.min(
|
|
107
|
+
effectiveDepth,
|
|
108
|
+
Math.ceil((scrollTop + containerHeight) / RowHeight) + 5
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const cumulativeColumn = table.getChild(FIELD_CUMULATIVE);
|
|
112
|
+
const valueOffsetColumn = table.getChild(FIELD_VALUE_OFFSET);
|
|
113
|
+
|
|
114
|
+
const selectionOffset =
|
|
115
|
+
valueOffsetColumn?.get(selectedRow) !== null &&
|
|
116
|
+
valueOffsetColumn?.get(selectedRow) !== undefined
|
|
117
|
+
? BigInt(valueOffsetColumn?.get(selectedRow))
|
|
118
|
+
: 0n;
|
|
119
|
+
const selectionCumulative =
|
|
120
|
+
cumulativeColumn?.get(selectedRow) !== null ? BigInt(cumulativeColumn?.get(selectedRow)) : 0n;
|
|
121
|
+
|
|
122
|
+
const totalNumber = Number(total);
|
|
123
|
+
const selectionOffsetNumber = Number(selectionOffset);
|
|
124
|
+
const selectionCumulativeNumber = Number(selectionCumulative);
|
|
125
|
+
|
|
126
|
+
// Iterate only through visible depth range instead of all rows
|
|
127
|
+
for (let depth = startDepth; depth <= endDepth && depth < depthBuckets.length; depth++) {
|
|
128
|
+
// Skip if depth is beyond effective depth limit
|
|
129
|
+
if (effectiveDepth !== undefined && depth > effectiveDepth) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const rowsAtDepth = depthBuckets[depth];
|
|
134
|
+
|
|
135
|
+
for (const row of rowsAtDepth) {
|
|
136
|
+
const cumulative =
|
|
137
|
+
cumulativeColumn?.get(row) !== null ? Number(cumulativeColumn?.get(row)) : 0;
|
|
138
|
+
|
|
139
|
+
const valueOffset =
|
|
140
|
+
valueOffsetColumn?.get(row) !== null && valueOffsetColumn?.get(row) !== undefined
|
|
141
|
+
? Number(valueOffsetColumn?.get(row))
|
|
142
|
+
: 0;
|
|
143
|
+
|
|
144
|
+
// Horizontal culling: Skip nodes outside selection bounds
|
|
145
|
+
if (
|
|
146
|
+
valueOffset + cumulative <= selectionOffsetNumber ||
|
|
147
|
+
valueOffset >= selectionOffsetNumber + selectionCumulativeNumber
|
|
148
|
+
) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Size culling: Skip nodes too small to be visible (< 1px width)
|
|
153
|
+
const computedWidth = (cumulative / totalNumber) * width;
|
|
154
|
+
if (computedWidth <= 1) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
visibleRows.push(row);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Cache the result with the current key
|
|
163
|
+
lastResultRef.current = {key: memoKey, result: visibleRows};
|
|
164
|
+
|
|
165
|
+
return visibleRows;
|
|
166
|
+
}, [depthBuckets, viewport, total, width, selectedRow, effectiveDepth, table]);
|
|
167
|
+
};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
|
|
14
|
-
import {Table} from 'apache-arrow';
|
|
14
|
+
import {Table, Vector} from 'apache-arrow';
|
|
15
15
|
|
|
16
16
|
import {
|
|
17
17
|
BINARY_FEATURE_TYPES,
|
|
@@ -203,3 +203,14 @@ export function isCurrentPathFrameMatch(
|
|
|
203
203
|
a.labels === b.labels
|
|
204
204
|
);
|
|
205
205
|
}
|
|
206
|
+
|
|
207
|
+
export function getMaxDepth(depthColumn: Vector<any> | null): number {
|
|
208
|
+
if (depthColumn === null) return 0;
|
|
209
|
+
|
|
210
|
+
let max = 0;
|
|
211
|
+
for (const val of depthColumn) {
|
|
212
|
+
const numVal = Number(val);
|
|
213
|
+
if (numVal > max) max = numVal;
|
|
214
|
+
}
|
|
215
|
+
return max;
|
|
216
|
+
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
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={
|
|
66
|
-
error={
|
|
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={
|
|
53
|
+
metadataMappingFiles={calleesFlamegraphData.metadataMappingFiles}
|
|
54
|
+
metadataLoading={calleesFlamegraphData.metadataLoading}
|
|
73
55
|
isInSandwichView={true}
|
|
74
56
|
curPathArrow={curPathArrow}
|
|
75
57
|
setNewCurPathArrow={setCurPathArrow}
|