@parca/profile 0.19.142 → 0.19.143
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 +4 -0
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +22 -28
- package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
- package/dist/ProfileExplorer/ProfileExplorerCompare.js +72 -73
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/index.js +20 -24
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +13 -14
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +6 -5
- package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/index.js +8 -7
- package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
- package/dist/ProfileMetricsGraph/index.js +6 -8
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.js +48 -55
- package/dist/ProfileSelector/index.d.ts +1 -1
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +216 -210
- package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
- package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
- package/dist/ProfileSelector/useAutoQuerySelector.js +133 -104
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +24 -25
- package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
- package/dist/ProfileView/components/ColorStackLegend.js +3 -5
- package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
- package/dist/ProfileView/components/InvertCallStack/index.js +47 -47
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +1 -2
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +37 -34
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +282 -294
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +7 -8
- package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
- package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/index.js +1 -1
- package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
- package/dist/ProfileView/components/ViewSelector/index.js +53 -75
- package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
- package/dist/ProfileView/context/DashboardContext.js +36 -44
- package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetFlameGraphState.js +8 -7
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +59 -59
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +37 -22
- package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
- package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useVisualizationState.js +116 -147
- package/dist/ProfileViewWithData.d.ts.map +1 -1
- package/dist/ProfileViewWithData.js +35 -45
- package/dist/Sandwich/index.d.ts.map +1 -1
- package/dist/Sandwich/index.js +6 -5
- package/dist/SourceView/index.d.ts.map +1 -1
- package/dist/SourceView/index.js +6 -4
- package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
- package/dist/SourceView/useSelectedLineRange.js +52 -76
- package/dist/Table/MoreDropdown.d.ts.map +1 -1
- package/dist/Table/MoreDropdown.js +42 -53
- package/dist/Table/TableContextMenu.d.ts.map +1 -1
- package/dist/Table/TableContextMenu.js +15 -19
- package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
- package/dist/Table/hooks/useTableConfiguration.js +107 -115
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +16 -16
- package/dist/TopTable/index.d.ts.map +1 -1
- package/dist/TopTable/index.js +112 -127
- package/dist/hooks/urlParsers.d.ts +18 -0
- package/dist/hooks/urlParsers.d.ts.map +1 -0
- package/dist/hooks/urlParsers.js +44 -0
- package/dist/hooks/useColorBy.d.ts +5 -0
- package/dist/hooks/useColorBy.d.ts.map +1 -0
- package/dist/hooks/useColorBy.js +63 -0
- package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
- package/dist/hooks/useCompareModeMeta.js +94 -138
- package/dist/hooks/useDashboardItems.d.ts +5 -0
- package/dist/hooks/useDashboardItems.d.ts.map +1 -0
- package/dist/hooks/useDashboardItems.js +68 -0
- package/dist/hooks/useQueryState.d.ts +4 -4
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +127 -122
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -12
- package/dist/useSumBy.d.ts +1 -1
- package/dist/useSumBy.d.ts.map +1 -1
- package/dist/useSumBy.js +2 -2
- package/package.json +4 -3
- package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +11 -13
- package/src/ProfileExplorer/ProfileExplorerCompare.tsx +11 -9
- package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
- package/src/ProfileFlameChart/index.tsx +21 -28
- package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +10 -9
- package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +5 -3
- package/src/ProfileFlameGraph/index.tsx +6 -9
- package/src/ProfileMetricsGraph/index.tsx +6 -8
- package/src/ProfileSelector/MetricsGraphSection.tsx +5 -10
- package/src/ProfileSelector/index.tsx +33 -33
- package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
- package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +10 -6
- package/src/ProfileView/components/ColorStackLegend.tsx +2 -4
- package/src/ProfileView/components/InvertCallStack/index.tsx +5 -4
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +94 -192
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
- package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +24 -25
- package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +4 -5
- package/src/ProfileView/components/Toolbars/index.tsx +3 -3
- package/src/ProfileView/components/ViewSelector/index.tsx +9 -16
- package/src/ProfileView/context/DashboardContext.tsx +6 -6
- package/src/ProfileView/hooks/useResetFlameGraphState.ts +6 -4
- package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +24 -26
- package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +16 -8
- package/src/ProfileView/hooks/useVisualizationState.ts +61 -69
- package/src/ProfileViewWithData.tsx +29 -35
- package/src/Sandwich/index.tsx +4 -3
- package/src/SourceView/index.tsx +4 -2
- package/src/SourceView/useSelectedLineRange.ts +34 -19
- package/src/Table/MoreDropdown.tsx +9 -11
- package/src/Table/TableContextMenu.tsx +10 -13
- package/src/Table/hooks/useTableConfiguration.tsx +3 -4
- package/src/Table/index.tsx +12 -21
- package/src/TopTable/index.tsx +3 -4
- package/src/hooks/urlParsers.ts +38 -0
- package/src/hooks/useColorBy.ts +42 -0
- package/src/hooks/useCompareModeMeta.ts +61 -91
- package/src/hooks/useDashboardItems.ts +46 -0
- package/src/hooks/useQueryState.test.tsx +275 -345
- package/src/hooks/useQueryState.ts +153 -120
- package/src/index.tsx +16 -15
- package/src/useSumBy.ts +3 -3
|
@@ -11,9 +11,25 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import {useCallback} from 'react';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import {createParser, useQueryState} from 'nuqs';
|
|
17
|
+
|
|
18
|
+
interface SelectedLineRange {
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const lineRangeParser = createParser<SelectedLineRange>({
|
|
24
|
+
parse: (value: string) => {
|
|
25
|
+
const [start, end] = value.split('-');
|
|
26
|
+
const startNum = parseInt(start, 10);
|
|
27
|
+
if (isNaN(startNum)) return null;
|
|
28
|
+
const endNum = end !== undefined ? parseInt(end, 10) : startNum;
|
|
29
|
+
return {start: startNum, end: isNaN(endNum) ? startNum : endNum};
|
|
30
|
+
},
|
|
31
|
+
serialize: (value: SelectedLineRange) => `${value.start}-${value.end}`,
|
|
32
|
+
}).withOptions({history: 'replace'});
|
|
17
33
|
|
|
18
34
|
interface LineRange {
|
|
19
35
|
startLine: number;
|
|
@@ -22,24 +38,23 @@ interface LineRange {
|
|
|
22
38
|
}
|
|
23
39
|
|
|
24
40
|
const useLineRange = (): LineRange => {
|
|
25
|
-
const [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
const [lineRange, setRawLineRange] = useQueryState(
|
|
42
|
+
'source_line',
|
|
43
|
+
lineRangeParser.withDefault({start: -1, end: -1})
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const setLineRange = useCallback(
|
|
47
|
+
(start: number, end: number): void => {
|
|
48
|
+
void setRawLineRange({start, end});
|
|
49
|
+
},
|
|
50
|
+
[setRawLineRange]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
startLine: lineRange.start,
|
|
55
|
+
endLine: lineRange.end,
|
|
56
|
+
setLineRange,
|
|
40
57
|
};
|
|
41
|
-
|
|
42
|
-
return {startLine, endLine, setLineRange};
|
|
43
58
|
};
|
|
44
59
|
|
|
45
60
|
export default useLineRange;
|
|
@@ -13,23 +13,21 @@
|
|
|
13
13
|
|
|
14
14
|
import {Menu} from '@headlessui/react';
|
|
15
15
|
import {Icon} from '@iconify/react';
|
|
16
|
+
import {useQueryState} from 'nuqs';
|
|
16
17
|
|
|
17
|
-
import {useParcaContext
|
|
18
|
+
import {useParcaContext} from '@parca/components';
|
|
19
|
+
|
|
20
|
+
import {stringParam} from '../hooks/urlParsers';
|
|
21
|
+
import {useDashboardItems} from '../hooks/useDashboardItems';
|
|
18
22
|
|
|
19
23
|
const MoreDropdown = ({functionName}: {functionName: string}): React.JSX.Element | null => {
|
|
20
|
-
const [_, setSandwichFunctionName] =
|
|
21
|
-
const
|
|
22
|
-
alwaysReturnArray: true,
|
|
23
|
-
});
|
|
24
|
+
const [_, setSandwichFunctionName] = useQueryState('sandwich_function_name', stringParam);
|
|
25
|
+
const {dashboardItems, setDashboardItems} = useDashboardItems();
|
|
24
26
|
const {enableSandwichView} = useParcaContext();
|
|
25
|
-
const batchUpdates = useURLStateBatch();
|
|
26
27
|
|
|
27
28
|
const onSandwichViewSelect = (): void => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
setSandwichFunctionName(functionName.trim());
|
|
31
|
-
setDashboardItems([...dashboardItems, 'sandwich']);
|
|
32
|
-
});
|
|
29
|
+
void setSandwichFunctionName(functionName.trim());
|
|
30
|
+
setDashboardItems([...dashboardItems, 'sandwich']);
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
const menuItems: Array<{label: string; action: () => void}> = [];
|
|
@@ -13,15 +13,18 @@
|
|
|
13
13
|
|
|
14
14
|
import {Icon} from '@iconify/react';
|
|
15
15
|
import cx from 'classnames';
|
|
16
|
+
import {useQueryState} from 'nuqs';
|
|
16
17
|
import {Item, Menu, Submenu} from 'react-contexify';
|
|
17
18
|
|
|
18
19
|
import 'react-contexify/dist/ReactContexify.css';
|
|
19
20
|
|
|
20
|
-
import {useParcaContext
|
|
21
|
+
import {useParcaContext} from '@parca/components';
|
|
21
22
|
import {valueFormatter} from '@parca/utilities';
|
|
22
23
|
|
|
23
24
|
import {type Row} from '.';
|
|
24
25
|
import {getTextForCumulative} from '../ProfileFlameGraph/FlameGraphArrow/utils';
|
|
26
|
+
import {stringParam} from '../hooks/urlParsers';
|
|
27
|
+
import {useDashboardItems} from '../hooks/useDashboardItems';
|
|
25
28
|
import {truncateString} from '../utils';
|
|
26
29
|
import {type ColumnName} from './utils/functions';
|
|
27
30
|
|
|
@@ -42,22 +45,16 @@ const TableContextMenu = ({
|
|
|
42
45
|
totalUnfiltered,
|
|
43
46
|
columnVisibility,
|
|
44
47
|
}: TableContextMenuProps): React.JSX.Element => {
|
|
45
|
-
const [_, setSandwichFunctionName] =
|
|
46
|
-
const
|
|
47
|
-
alwaysReturnArray: true,
|
|
48
|
-
});
|
|
48
|
+
const [_, setSandwichFunctionName] = useQueryState('sandwich_function_name', stringParam);
|
|
49
|
+
const {dashboardItems, setDashboardItems} = useDashboardItems();
|
|
49
50
|
const {enableSandwichView, isDarkMode} = useParcaContext();
|
|
50
|
-
const batchUpdates = useURLStateBatch();
|
|
51
51
|
|
|
52
52
|
const onSandwichViewSelect = (): void => {
|
|
53
53
|
if (row?.name != null && row.name.length > 0) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
setDashboardItems([...dashboardItems, 'sandwich']);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
54
|
+
void setSandwichFunctionName(row.name.trim());
|
|
55
|
+
if (!dashboardItems.includes('sandwich')) {
|
|
56
|
+
setDashboardItems([...dashboardItems, 'sandwich']);
|
|
57
|
+
}
|
|
61
58
|
}
|
|
62
59
|
};
|
|
63
60
|
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
import {useMemo} from 'react';
|
|
15
15
|
|
|
16
16
|
import {createColumnHelper, type ColumnDef} from '@tanstack/table-core';
|
|
17
|
+
import {useQueryState} from 'nuqs';
|
|
17
18
|
|
|
18
|
-
import {useURLState} from '@parca/components';
|
|
19
19
|
import {valueFormatter} from '@parca/utilities';
|
|
20
20
|
|
|
21
21
|
import {type Row} from '..';
|
|
22
|
+
import {tableColumnsParser} from '../../hooks/urlParsers';
|
|
22
23
|
import {ColorCell} from '../ColorCell';
|
|
23
24
|
import {addPlusSign, ratioString, type ColumnName} from '../utils/functions';
|
|
24
25
|
|
|
@@ -43,9 +44,7 @@ export function useTableConfiguration({
|
|
|
43
44
|
compareMode,
|
|
44
45
|
}: UseTableConfigurationProps): TableConfiguration {
|
|
45
46
|
const columnHelper = createColumnHelper<Row>();
|
|
46
|
-
const [tableColumns] =
|
|
47
|
-
alwaysReturnArray: true,
|
|
48
|
-
});
|
|
47
|
+
const [tableColumns] = useQueryState('table_columns', tableColumnsParser);
|
|
49
48
|
|
|
50
49
|
const columnVisibility = useMemo(() => {
|
|
51
50
|
const defaults: Record<string, boolean> = {
|
package/src/Table/index.tsx
CHANGED
|
@@ -16,14 +16,10 @@ import React, {useCallback, useEffect, useMemo, useRef} from 'react';
|
|
|
16
16
|
import {RpcError} from '@protobuf-ts/runtime-rpc';
|
|
17
17
|
import {tableFromIPC} from '@uwdata/flechette';
|
|
18
18
|
import {AnimatePresence, motion} from 'framer-motion';
|
|
19
|
+
import {useQueryState} from 'nuqs';
|
|
19
20
|
import {useContextMenu} from 'react-contexify';
|
|
20
21
|
|
|
21
|
-
import {
|
|
22
|
-
Table as TableComponent,
|
|
23
|
-
TableSkeleton,
|
|
24
|
-
useParcaContext,
|
|
25
|
-
useURLState,
|
|
26
|
-
} from '@parca/components';
|
|
22
|
+
import {Table as TableComponent, TableSkeleton, useParcaContext} from '@parca/components';
|
|
27
23
|
import {useCurrentColorProfile} from '@parca/hooks';
|
|
28
24
|
import {ProfileType} from '@parca/parser';
|
|
29
25
|
|
|
@@ -31,6 +27,9 @@ import useMappingList, {
|
|
|
31
27
|
useFilenamesList,
|
|
32
28
|
} from '../ProfileFlameGraph/FlameGraphArrow/useMappingList';
|
|
33
29
|
import {useProfileViewContext} from '../ProfileView/context/ProfileViewContext';
|
|
30
|
+
import {stringParam} from '../hooks/urlParsers';
|
|
31
|
+
import {useColorBy} from '../hooks/useColorBy';
|
|
32
|
+
import {useDashboardItems} from '../hooks/useDashboardItems';
|
|
34
33
|
import {alignedUint8Array} from '../utils';
|
|
35
34
|
import TableContextMenuWrapper, {TableContextMenuWrapperRef} from './TableContextMenuWrapper';
|
|
36
35
|
import {useColorManagement} from './hooks/useColorManagement';
|
|
@@ -76,11 +75,9 @@ export const Table = React.memo(function Table({
|
|
|
76
75
|
error,
|
|
77
76
|
}: TableProps): React.JSX.Element {
|
|
78
77
|
const currentColorProfile = useCurrentColorProfile();
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
const [_, setSandwichFunctionName] = useURLState<string | undefined>('sandwich_function_name');
|
|
83
|
-
const [colorBy, setColorBy] = useURLState('color_by');
|
|
78
|
+
const {dashboardItems} = useDashboardItems();
|
|
79
|
+
const [_, setSandwichFunctionName] = useQueryState('sandwich_function_name', stringParam);
|
|
80
|
+
const {colorBy, setColorBy} = useColorBy();
|
|
84
81
|
const {isDarkMode} = useParcaContext();
|
|
85
82
|
const {compareMode} = useProfileViewContext();
|
|
86
83
|
|
|
@@ -108,7 +105,7 @@ export const Table = React.memo(function Table({
|
|
|
108
105
|
// If there is only one mapping file, we want to color by filename by default.
|
|
109
106
|
useEffect(() => {
|
|
110
107
|
if (mappingsListCount === 1 && colorBy !== 'filename') {
|
|
111
|
-
setColorBy('filename');
|
|
108
|
+
void setColorBy('filename');
|
|
112
109
|
}
|
|
113
110
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
114
111
|
}, [mappingsListCount]);
|
|
@@ -118,7 +115,7 @@ export const Table = React.memo(function Table({
|
|
|
118
115
|
currentColorProfile,
|
|
119
116
|
mappingsList,
|
|
120
117
|
filenamesList,
|
|
121
|
-
colorBy
|
|
118
|
+
colorBy,
|
|
122
119
|
});
|
|
123
120
|
|
|
124
121
|
unit = useMemo(() => unit ?? profileType?.sampleUnit ?? '', [unit, profileType?.sampleUnit]);
|
|
@@ -135,7 +132,7 @@ export const Table = React.memo(function Table({
|
|
|
135
132
|
const selectSpan = useCallback(
|
|
136
133
|
(span: string): void => {
|
|
137
134
|
if (!dashboardItems.includes('flamegraph')) {
|
|
138
|
-
setSandwichFunctionName(span.trim());
|
|
135
|
+
void setSandwichFunctionName(span.trim());
|
|
139
136
|
}
|
|
140
137
|
},
|
|
141
138
|
[setSandwichFunctionName, dashboardItems]
|
|
@@ -191,13 +188,7 @@ export const Table = React.memo(function Table({
|
|
|
191
188
|
return {
|
|
192
189
|
id: i,
|
|
193
190
|
colorProperty: {
|
|
194
|
-
color: getRowColor(
|
|
195
|
-
colorByColors,
|
|
196
|
-
mappingFileColumn,
|
|
197
|
-
i,
|
|
198
|
-
functionFileNameColumn,
|
|
199
|
-
colorBy as string
|
|
200
|
-
),
|
|
191
|
+
color: getRowColor(colorByColors, mappingFileColumn, i, functionFileNameColumn, colorBy),
|
|
201
192
|
mappingFile,
|
|
202
193
|
},
|
|
203
194
|
name: RowName(mappingFileColumn, locationAddressColumn, functionNameColumn, i),
|
package/src/TopTable/index.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import React, {useCallback, useEffect, useMemo} from 'react';
|
|
|
16
16
|
import {createColumnHelper, type ColumnDef} from '@tanstack/react-table';
|
|
17
17
|
|
|
18
18
|
import {Top, TopNode, TopNodeMeta} from '@parca/client';
|
|
19
|
-
import {Button, Table
|
|
19
|
+
import {Button, Table} from '@parca/components';
|
|
20
20
|
import {
|
|
21
21
|
getLastItem,
|
|
22
22
|
isSearchMatch,
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
} from '@parca/utilities';
|
|
27
27
|
|
|
28
28
|
import {useProfileViewContext} from '../ProfileView/context/ProfileViewContext';
|
|
29
|
+
import {useDashboardItems} from '../hooks/useDashboardItems';
|
|
29
30
|
import {hexifyAddress} from '../utils';
|
|
30
31
|
|
|
31
32
|
interface TopTableProps {
|
|
@@ -72,9 +73,7 @@ export const TopTable = React.memo(function TopTable({
|
|
|
72
73
|
setActionButtons,
|
|
73
74
|
}: TopTableProps): JSX.Element {
|
|
74
75
|
const router = parseParams(window?.location.search);
|
|
75
|
-
const
|
|
76
|
-
alwaysReturnArray: true,
|
|
77
|
-
});
|
|
76
|
+
const {dashboardItems} = useDashboardItems();
|
|
78
77
|
|
|
79
78
|
const {compareMode} = useProfileViewContext();
|
|
80
79
|
|
|
@@ -0,0 +1,38 @@
|
|
|
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 {createParser, parseAsArrayOf, parseAsBoolean, parseAsInteger, parseAsString} from 'nuqs';
|
|
15
|
+
|
|
16
|
+
const opts = {history: 'replace' as const};
|
|
17
|
+
|
|
18
|
+
// === Base parsers with common options ===
|
|
19
|
+
export const stringParam = parseAsString.withOptions(opts);
|
|
20
|
+
export const boolParam = parseAsBoolean.withOptions(opts);
|
|
21
|
+
export const intParam = parseAsInteger.withOptions(opts);
|
|
22
|
+
export const commaArrayParam = parseAsArrayOf(parseAsString, ',').withOptions(opts);
|
|
23
|
+
|
|
24
|
+
// === Param-specific parsers with defaults ===
|
|
25
|
+
export const invertCallStackParser = boolParam.withDefault(false);
|
|
26
|
+
export const groupByParser = commaArrayParam;
|
|
27
|
+
export const flamechartDimensionParser = commaArrayParam;
|
|
28
|
+
export const tableColumnsParser = commaArrayParam;
|
|
29
|
+
export const hiddenBinariesParser = commaArrayParam.withDefault([]);
|
|
30
|
+
|
|
31
|
+
// === JSON parser with BigInt support ===
|
|
32
|
+
export function jsonParser<T>(): ReturnType<typeof createParser<T>> {
|
|
33
|
+
return createParser<T>({
|
|
34
|
+
parse: (value: string) => JSON.parse(value) as T,
|
|
35
|
+
serialize: (value: T) =>
|
|
36
|
+
JSON.stringify(value, (_, v) => (typeof v === 'bigint' ? v.toString() : v)),
|
|
37
|
+
}).withOptions(opts);
|
|
38
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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} from 'react';
|
|
15
|
+
|
|
16
|
+
import {useQueryState} from 'nuqs';
|
|
17
|
+
|
|
18
|
+
import {USER_PREFERENCES, useUserPreference} from '@parca/hooks';
|
|
19
|
+
|
|
20
|
+
import {stringParam} from './urlParsers';
|
|
21
|
+
|
|
22
|
+
export const useColorBy = (): {
|
|
23
|
+
colorBy: string;
|
|
24
|
+
setColorBy: (value: string) => void;
|
|
25
|
+
} => {
|
|
26
|
+
const [colorByPreference, setColorByPreference] = useUserPreference<string>(
|
|
27
|
+
USER_PREFERENCES.COLOR_BY.key
|
|
28
|
+
);
|
|
29
|
+
const [colorByRaw, setRawColorBy] = useQueryState('color_by', stringParam);
|
|
30
|
+
|
|
31
|
+
const colorBy = colorByRaw ?? colorByPreference ?? 'binary';
|
|
32
|
+
|
|
33
|
+
const setColorBy = useCallback(
|
|
34
|
+
(value: string) => {
|
|
35
|
+
void setRawColorBy(value);
|
|
36
|
+
setColorByPreference(value);
|
|
37
|
+
},
|
|
38
|
+
[setRawColorBy, setColorByPreference]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return {colorBy, setColorBy};
|
|
42
|
+
};
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
import {useCallback} from 'react';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import {useQueryStates} from 'nuqs';
|
|
17
|
+
|
|
18
|
+
import {boolParam, stringParam} from './urlParsers';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Hook to manage compare mode state and operations
|
|
@@ -24,104 +26,72 @@ export const useCompareModeMeta = (): {
|
|
|
24
26
|
isCompareAbsolute: boolean;
|
|
25
27
|
closeCompareMode: (card: 'A' | 'B') => void;
|
|
26
28
|
} => {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
const [state, setState] = useQueryStates(
|
|
30
|
+
{
|
|
31
|
+
// Side A
|
|
32
|
+
expression_a: stringParam,
|
|
33
|
+
from_a: stringParam,
|
|
34
|
+
to_a: stringParam,
|
|
35
|
+
time_selection_a: stringParam,
|
|
36
|
+
sum_by_a: stringParam,
|
|
37
|
+
merge_from_a: stringParam,
|
|
38
|
+
merge_to_a: stringParam,
|
|
39
|
+
selection_a: stringParam,
|
|
40
|
+
// Side B
|
|
41
|
+
expression_b: stringParam,
|
|
42
|
+
from_b: stringParam,
|
|
43
|
+
to_b: stringParam,
|
|
44
|
+
time_selection_b: stringParam,
|
|
45
|
+
sum_by_b: stringParam,
|
|
46
|
+
merge_from_b: stringParam,
|
|
47
|
+
merge_to_b: stringParam,
|
|
48
|
+
selection_b: stringParam,
|
|
49
|
+
// Compare flags
|
|
50
|
+
compare_a: boolParam,
|
|
51
|
+
compare_b: boolParam,
|
|
52
|
+
compare_absolute: boolParam,
|
|
53
|
+
},
|
|
54
|
+
{history: 'replace'}
|
|
55
|
+
);
|
|
53
56
|
|
|
54
57
|
const closeCompareMode = useCallback(
|
|
55
58
|
(side: 'A' | 'B') => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
// If closing side A, swap B → A first (keep B's data as the single view)
|
|
60
|
+
const swapAFromB =
|
|
61
|
+
side === 'A'
|
|
62
|
+
? {
|
|
63
|
+
expression_a: state.expression_b,
|
|
64
|
+
from_a: state.from_b,
|
|
65
|
+
to_a: state.to_b,
|
|
66
|
+
time_selection_a: state.time_selection_b,
|
|
67
|
+
sum_by_a: state.sum_by_b,
|
|
68
|
+
merge_from_a: state.merge_from_b,
|
|
69
|
+
merge_to_a: state.merge_to_b,
|
|
70
|
+
selection_a: state.selection_b,
|
|
71
|
+
}
|
|
72
|
+
: {};
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
// Atomic update: swap A (if needed), clear all B params and compare flags
|
|
75
|
+
void setState({
|
|
76
|
+
...swapAFromB,
|
|
77
|
+
expression_b: null,
|
|
78
|
+
from_b: null,
|
|
79
|
+
to_b: null,
|
|
80
|
+
time_selection_b: null,
|
|
81
|
+
sum_by_b: null,
|
|
82
|
+
merge_from_b: null,
|
|
83
|
+
merge_to_b: null,
|
|
84
|
+
selection_b: null,
|
|
85
|
+
compare_a: null,
|
|
86
|
+
compare_b: null,
|
|
87
|
+
compare_absolute: null,
|
|
84
88
|
});
|
|
85
89
|
},
|
|
86
|
-
[
|
|
87
|
-
batchUpdates,
|
|
88
|
-
// Side A setters
|
|
89
|
-
setExpressionA,
|
|
90
|
-
setFromA,
|
|
91
|
-
setToA,
|
|
92
|
-
setTimeSelectionA,
|
|
93
|
-
setSumByA,
|
|
94
|
-
setMergeFromA,
|
|
95
|
-
setMergeToA,
|
|
96
|
-
setSelectionA,
|
|
97
|
-
// Side B values (for swapping)
|
|
98
|
-
expressionB,
|
|
99
|
-
fromB,
|
|
100
|
-
toB,
|
|
101
|
-
timeSelectionB,
|
|
102
|
-
sumByB,
|
|
103
|
-
mergeFromB,
|
|
104
|
-
mergeToB,
|
|
105
|
-
selectionB,
|
|
106
|
-
// Side B setters
|
|
107
|
-
setExpressionB,
|
|
108
|
-
setFromB,
|
|
109
|
-
setToB,
|
|
110
|
-
setTimeSelectionB,
|
|
111
|
-
setSumByB,
|
|
112
|
-
setMergeFromB,
|
|
113
|
-
setMergeToB,
|
|
114
|
-
setSelectionB,
|
|
115
|
-
// Compare flags
|
|
116
|
-
setCompareA,
|
|
117
|
-
setCompareB,
|
|
118
|
-
setCompareAbsolute,
|
|
119
|
-
]
|
|
90
|
+
[state, setState]
|
|
120
91
|
);
|
|
121
92
|
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
const isCompareAbsolute = compareAbsolute === 'true';
|
|
93
|
+
const isCompareMode = state.compare_a === true || state.compare_b === true;
|
|
94
|
+
const isCompareAbsolute = state.compare_absolute === true;
|
|
125
95
|
|
|
126
96
|
return {
|
|
127
97
|
isCompareMode,
|
|
@@ -0,0 +1,46 @@
|
|
|
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, useMemo} from 'react';
|
|
15
|
+
|
|
16
|
+
import {parseAsArrayOf, parseAsString, useQueryState} from 'nuqs';
|
|
17
|
+
|
|
18
|
+
import {useParcaContext} from '@parca/components';
|
|
19
|
+
|
|
20
|
+
const opts = {history: 'replace' as const};
|
|
21
|
+
|
|
22
|
+
export const useDashboardItems = (): {
|
|
23
|
+
dashboardItems: string[];
|
|
24
|
+
setDashboardItems: (items: string[]) => void;
|
|
25
|
+
} => {
|
|
26
|
+
const {defaultDashboardItems} = useParcaContext();
|
|
27
|
+
|
|
28
|
+
const parser = useMemo(
|
|
29
|
+
() =>
|
|
30
|
+
parseAsArrayOf(parseAsString, ',')
|
|
31
|
+
.withDefault(defaultDashboardItems ?? ['flamegraph'])
|
|
32
|
+
.withOptions(opts),
|
|
33
|
+
[defaultDashboardItems]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const [dashboardItems, setRawDashboardItems] = useQueryState('dashboard_items', parser);
|
|
37
|
+
|
|
38
|
+
const setDashboardItems = useCallback(
|
|
39
|
+
(items: string[]) => {
|
|
40
|
+
void setRawDashboardItems(items);
|
|
41
|
+
},
|
|
42
|
+
[setRawDashboardItems]
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return {dashboardItems, setDashboardItems};
|
|
46
|
+
};
|