@parca/profile 0.16.391 → 0.16.392

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 CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.16.392](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.391...@parca/profile@0.16.392) (2024-06-27)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
6
10
  ## 0.16.391 (2024-06-24)
7
11
 
8
12
  **Note:** Version bump only for package @parca/profile
@@ -10,6 +10,6 @@ const ProfileExplorerCompare = ({ queryClient, queryA, queryB, profileA, profile
10
10
  const closeProfileB = () => {
11
11
  closeProfile('B');
12
12
  };
13
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(Card, { className: "mt-2 p-2", children: _jsx(ProfileSelector, { queryClient: queryClient, querySelection: queryA, profileSelection: profileA, selectProfile: selectProfileA, selectQuery: selectQueryA, closeProfile: closeProfileA, enforcedProfileName: '', comparing: true }) }), _jsx(Card, { className: "mt-2 p-2", children: _jsx(ProfileSelector, { queryClient: queryClient, querySelection: queryB, profileSelection: profileB, selectProfile: selectProfileB, selectQuery: selectQueryB, closeProfile: closeProfileB, enforcedProfileName: Query.parse(queryA.expression).profileName(), comparing: true }) })] }), _jsx("div", { className: "grid grid-cols-1", children: profileA != null && profileB != null ? (_jsx("div", { children: _jsx(Card, { className: "mt-2 px-6 py-4", children: _jsx(ProfileViewWithData, { navigateTo: navigateTo, queryClient: queryClient, profileSource: new ProfileDiffSource(profileA.ProfileSource(), profileB.ProfileSource()) }) }) })) : (_jsx("div", { children: _jsx("div", { className: "my-20 text-center", children: _jsx("p", { children: "Select a profile on both sides." }) }) })) })] }));
13
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(Card, { className: "mt-2 p-2", children: _jsx(ProfileSelector, { queryClient: queryClient, querySelection: queryA, profileSelection: profileA, selectProfile: selectProfileA, selectQuery: selectQueryA, closeProfile: closeProfileA, enforcedProfileName: '', comparing: true, navigateTo: navigateTo }) }), _jsx(Card, { className: "mt-2 p-2", children: _jsx(ProfileSelector, { queryClient: queryClient, querySelection: queryB, profileSelection: profileB, selectProfile: selectProfileB, selectQuery: selectQueryB, closeProfile: closeProfileB, enforcedProfileName: Query.parse(queryA.expression).profileName(), comparing: true, navigateTo: navigateTo }) })] }), _jsx("div", { className: "grid grid-cols-1", children: profileA != null && profileB != null ? (_jsx("div", { children: _jsx(Card, { className: "mt-2 px-6 py-4", children: _jsx(ProfileViewWithData, { navigateTo: navigateTo, queryClient: queryClient, profileSource: new ProfileDiffSource(profileA.ProfileSource(), profileB.ProfileSource()) }) }) })) : (_jsx("div", { children: _jsx("div", { className: "my-20 text-center", children: _jsx("p", { children: "Select a profile on both sides." }) }) })) })] }));
14
14
  };
15
15
  export default ProfileExplorerCompare;
@@ -3,6 +3,6 @@ import { Card } from '@parca/components';
3
3
  import { ProfileViewWithData } from '..';
4
4
  import ProfileSelector from '../ProfileSelector';
5
5
  const ProfileExplorerSingle = ({ queryClient, query, selectQuery, selectProfile, profile, navigateTo, }) => {
6
- return (_jsxs(_Fragment, { children: [_jsx(Card, { className: "mt-2 px-6 py-4", children: _jsx(ProfileSelector, { queryClient: queryClient, querySelection: query, selectQuery: selectQuery, selectProfile: selectProfile, closeProfile: () => { }, profileSelection: profile, comparing: false, enforcedProfileName: '' }) }), profile != null ? (_jsx(Card, { className: "mt-2 px-6 py-4", children: _jsx(ProfileViewWithData, { queryClient: queryClient, profileSource: profile.ProfileSource(), navigateTo: navigateTo }) })) : (_jsx(_Fragment, {}))] }));
6
+ return (_jsxs(_Fragment, { children: [_jsx(Card, { className: "mt-2 px-6 py-4", children: _jsx(ProfileSelector, { queryClient: queryClient, querySelection: query, selectQuery: selectQuery, selectProfile: selectProfile, closeProfile: () => { }, profileSelection: profile, comparing: false, enforcedProfileName: '', navigateTo: navigateTo }) }), profile != null ? (_jsx(Card, { className: "mt-2 px-6 py-4", children: _jsx(ProfileViewWithData, { queryClient: queryClient, profileSource: profile.ProfileSource(), navigateTo: navigateTo }) })) : (_jsx(_Fragment, {}))] }));
7
7
  };
8
8
  export default ProfileExplorerSingle;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { RpcError } from '@protobuf-ts/runtime-rpc';
3
3
  import { ProfileTypesResponse, QueryServiceClient } from '@parca/client';
4
+ import { type NavigateFunction } from '@parca/utilities';
4
5
  import { ProfileSelection } from '..';
5
6
  export interface QuerySelection {
6
7
  expression: string;
@@ -19,6 +20,7 @@ interface ProfileSelectorProps {
19
20
  enforcedProfileName: string;
20
21
  profileSelection: ProfileSelection | null;
21
22
  comparing: boolean;
23
+ navigateTo: NavigateFunction;
22
24
  }
23
25
  export interface IProfileTypesResult {
24
26
  loading: boolean;
@@ -26,5 +28,5 @@ export interface IProfileTypesResult {
26
28
  error?: RpcError;
27
29
  }
28
30
  export declare const useProfileTypes: (client: QueryServiceClient) => IProfileTypesResult;
29
- declare const ProfileSelector: ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, }: ProfileSelectorProps) => JSX.Element;
31
+ declare const ProfileSelector: ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, navigateTo, }: ProfileSelectorProps) => JSX.Element;
30
32
  export default ProfileSelector;
@@ -38,7 +38,7 @@ export const useProfileTypes = (client) => {
38
38
  }, [client, metadata, loading]);
39
39
  return { loading, data: result, error };
40
40
  };
41
- const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, }) => {
41
+ const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, navigateTo, }) => {
42
42
  const { loading: profileTypesLoading, data: profileTypesData, error, } = useProfileTypes(queryClient);
43
43
  const { heightStyle } = useMetricsGraphDimensions(comparing);
44
44
  const { viewComponent } = useParcaContext();
@@ -136,6 +136,8 @@ const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQue
136
136
  profileTypesData,
137
137
  setProfileName,
138
138
  setQueryExpression,
139
+ querySelection,
140
+ navigateTo,
139
141
  });
140
142
  const searchDisabled = queryExpressionString === undefined ||
141
143
  queryExpressionString === '' ||
@@ -1,9 +1,13 @@
1
1
  import { ProfileTypesResponse } from '@parca/client';
2
+ import { type NavigateFunction } from '@parca/utilities';
3
+ import { QuerySelection } from '../ProfileSelector';
2
4
  interface Props {
3
5
  selectedProfileName: string;
4
6
  profileTypesData: ProfileTypesResponse | undefined;
5
7
  setProfileName: (name: string) => void;
6
8
  setQueryExpression: () => void;
9
+ querySelection: QuerySelection;
10
+ navigateTo: NavigateFunction;
7
11
  }
8
- export declare const useAutoQuerySelector: ({ selectedProfileName, profileTypesData, setProfileName, setQueryExpression, }: Props) => void;
12
+ export declare const useAutoQuerySelector: ({ selectedProfileName, profileTypesData, setProfileName, setQueryExpression, querySelection, navigateTo, }: Props) => void;
9
13
  export {};
@@ -12,10 +12,51 @@
12
12
  // limitations under the License.
13
13
  import { useEffect } from 'react';
14
14
  import { selectAutoQuery, setAutoQuery, useAppDispatch, useAppSelector } from '@parca/store';
15
+ import { ProfileSelectionFromParams, SuffixParams } from '..';
15
16
  import { constructProfileName } from '../ProfileTypeSelector';
16
- export const useAutoQuerySelector = ({ selectedProfileName, profileTypesData, setProfileName, setQueryExpression, }) => {
17
+ export const useAutoQuerySelector = ({ selectedProfileName, profileTypesData, setProfileName, setQueryExpression, querySelection, navigateTo, }) => {
17
18
  const autoQuery = useAppSelector(selectAutoQuery);
18
19
  const dispatch = useAppDispatch();
20
+ const queryParams = new URLSearchParams(location.search);
21
+ const comparing = queryParams.get('comparing') === 'true';
22
+ const expressionA = queryParams.get('expression_a');
23
+ useEffect(() => {
24
+ if (comparing && expressionA !== null && expressionA !== undefined) {
25
+ if (querySelection.expression === undefined) {
26
+ return;
27
+ }
28
+ const profileA = ProfileSelectionFromParams(querySelection.mergeFrom?.toString(), querySelection.mergeTo?.toString(), querySelection.expression, '');
29
+ const queryA = {
30
+ expression: querySelection.expression,
31
+ from: querySelection.from,
32
+ to: querySelection.to,
33
+ timeSelection: querySelection.timeSelection,
34
+ };
35
+ let compareQuery = {
36
+ compare_a: 'true',
37
+ expression_a: encodeURIComponent(queryA.expression),
38
+ from_a: queryA.from.toString(),
39
+ to_a: queryA.to.toString(),
40
+ time_selection_a: queryA.timeSelection,
41
+ compare_b: 'true',
42
+ expression_b: encodeURIComponent(queryA.expression),
43
+ from_b: queryA.from.toString(),
44
+ to_b: queryA.to.toString(),
45
+ time_selection_b: queryA.timeSelection,
46
+ };
47
+ if (profileA != null) {
48
+ compareQuery = {
49
+ ...SuffixParams(profileA.HistoryParams(), '_a'),
50
+ ...compareQuery,
51
+ };
52
+ }
53
+ void navigateTo('/', {
54
+ ...compareQuery,
55
+ search_string: '',
56
+ dashboard_items: ['icicle'],
57
+ });
58
+ }
59
+ }, [comparing, querySelection, navigateTo, expressionA, dispatch]);
19
60
  // Effect to load some initial data on load when is no selection
20
61
  useEffect(() => {
21
62
  void (async () => {
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import type { RpcMetadata } from '@protobuf-ts/runtime-rpc';
2
2
  import { QueryRequest, QueryServiceClient } from '@parca/client';
3
- import { type NavigateFunction } from '@parca/utilities';
4
3
  export declare const hexifyAddress: (address?: bigint) => string;
5
4
  export declare const downloadPprof: (request: QueryRequest, queryClient: QueryServiceClient, metadata: RpcMetadata) => Promise<Blob>;
6
5
  export declare const truncateString: (str: string, num: number) => string;
7
6
  export declare const truncateStringReverse: (str: string, num: number) => string;
8
- export declare const compareProfile: (navigateTo: NavigateFunction, defaultDashboardItems?: string[]) => void;
package/dist/utils.js CHANGED
@@ -11,8 +11,6 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { QueryRequest_ReportType } from '@parca/client';
14
- import { parseParams } from '@parca/utilities';
15
- import { ProfileSelectionFromParams, SuffixParams, getExpressionAsAString } from '.';
16
14
  export const hexifyAddress = (address) => {
17
15
  if (address == null) {
18
16
  return '';
@@ -43,47 +41,3 @@ export const truncateStringReverse = (str, num) => {
43
41
  }
44
42
  return '...' + str.slice(str.length - num);
45
43
  };
46
- export const compareProfile = (navigateTo, defaultDashboardItems = ['icicle']) => {
47
- const queryParams = parseParams(window.location.search);
48
- /* eslint-disable @typescript-eslint/naming-convention */
49
- const { from_a, to_a, merge_from_a, merge_to_a, time_selection_a, filter_by_function, dashboard_items, } = queryParams;
50
- // eslint-disable-next-line @typescript-eslint/naming-convention
51
- const selection_a = getExpressionAsAString(queryParams.selection_a);
52
- // eslint-disable-next-line @typescript-eslint/naming-convention
53
- const expression_a = getExpressionAsAString(queryParams.expression_a);
54
- if (expression_a === undefined || selection_a === undefined) {
55
- return;
56
- }
57
- const mergeFrom = merge_from_a ?? undefined;
58
- const mergeTo = merge_to_a ?? undefined;
59
- const profileA = ProfileSelectionFromParams(mergeFrom, mergeTo, selection_a, filter_by_function);
60
- const queryA = {
61
- expression: expression_a,
62
- from: parseInt(from_a),
63
- to: parseInt(to_a),
64
- timeSelection: time_selection_a,
65
- };
66
- let compareQuery = {
67
- compare_a: 'true',
68
- expression_a: encodeURIComponent(queryA.expression),
69
- from_a: queryA.from.toString(),
70
- to_a: queryA.to.toString(),
71
- time_selection_a: queryA.timeSelection,
72
- compare_b: 'true',
73
- expression_b: encodeURIComponent(queryA.expression),
74
- from_b: queryA.from.toString(),
75
- to_b: queryA.to.toString(),
76
- time_selection_b: queryA.timeSelection,
77
- };
78
- if (profileA != null) {
79
- compareQuery = {
80
- ...SuffixParams(profileA.HistoryParams(), '_a'),
81
- ...compareQuery,
82
- };
83
- }
84
- void navigateTo('/', {
85
- ...compareQuery,
86
- search_string: '',
87
- dashboard_items: dashboard_items ?? defaultDashboardItems,
88
- });
89
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.391",
3
+ "version": "0.16.392",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@headlessui/react": "^1.7.19",
@@ -71,5 +71,5 @@
71
71
  "access": "public",
72
72
  "registry": "https://registry.npmjs.org/"
73
73
  },
74
- "gitHead": "db964de537aebc04da1d2741dcf14f691d78a6a0"
74
+ "gitHead": "5355cd41303f7388e15c70b63c26b22d0cf82830"
75
75
  }
@@ -69,6 +69,7 @@ const ProfileExplorerCompare = ({
69
69
  closeProfile={closeProfileA}
70
70
  enforcedProfileName={''}
71
71
  comparing={true}
72
+ navigateTo={navigateTo}
72
73
  />
73
74
  </Card>
74
75
  <Card className="mt-2 p-2">
@@ -81,6 +82,7 @@ const ProfileExplorerCompare = ({
81
82
  closeProfile={closeProfileB}
82
83
  enforcedProfileName={Query.parse(queryA.expression).profileName()}
83
84
  comparing={true}
85
+ navigateTo={navigateTo}
84
86
  />
85
87
  </Card>
86
88
  </div>
@@ -47,6 +47,7 @@ const ProfileExplorerSingle = ({
47
47
  profileSelection={profile}
48
48
  comparing={false}
49
49
  enforcedProfileName={''} // TODO
50
+ navigateTo={navigateTo}
50
51
  />
51
52
  </Card>
52
53
  {profile != null ? (
@@ -27,6 +27,7 @@ import {
27
27
  } from '@parca/components';
28
28
  import {CloseIcon} from '@parca/icons';
29
29
  import {Query} from '@parca/parser';
30
+ import {type NavigateFunction} from '@parca/utilities';
30
31
 
31
32
  import {MergedProfileSelection, ProfileSelection} from '..';
32
33
  import MatchersInput from '../MatchersInput/index';
@@ -53,6 +54,7 @@ interface ProfileSelectorProps {
53
54
  enforcedProfileName: string;
54
55
  profileSelection: ProfileSelection | null;
55
56
  comparing: boolean;
57
+ navigateTo: NavigateFunction;
56
58
  }
57
59
 
58
60
  export interface IProfileTypesResult {
@@ -90,6 +92,7 @@ const ProfileSelector = ({
90
92
  enforcedProfileName,
91
93
  profileSelection,
92
94
  comparing,
95
+ navigateTo,
93
96
  }: ProfileSelectorProps): JSX.Element => {
94
97
  const {
95
98
  loading: profileTypesLoading,
@@ -214,6 +217,8 @@ const ProfileSelector = ({
214
217
  profileTypesData,
215
218
  setProfileName,
216
219
  setQueryExpression,
220
+ querySelection,
221
+ navigateTo,
217
222
  });
218
223
 
219
224
  const searchDisabled =
@@ -15,7 +15,10 @@ import {useEffect} from 'react';
15
15
 
16
16
  import {ProfileTypesResponse} from '@parca/client';
17
17
  import {selectAutoQuery, setAutoQuery, useAppDispatch, useAppSelector} from '@parca/store';
18
+ import {type NavigateFunction} from '@parca/utilities';
18
19
 
20
+ import {ProfileSelectionFromParams, SuffixParams} from '..';
21
+ import {QuerySelection} from '../ProfileSelector';
19
22
  import {constructProfileName} from '../ProfileTypeSelector';
20
23
 
21
24
  interface Props {
@@ -23,6 +26,8 @@ interface Props {
23
26
  profileTypesData: ProfileTypesResponse | undefined;
24
27
  setProfileName: (name: string) => void;
25
28
  setQueryExpression: () => void;
29
+ querySelection: QuerySelection;
30
+ navigateTo: NavigateFunction;
26
31
  }
27
32
 
28
33
  export const useAutoQuerySelector = ({
@@ -30,9 +35,62 @@ export const useAutoQuerySelector = ({
30
35
  profileTypesData,
31
36
  setProfileName,
32
37
  setQueryExpression,
38
+ querySelection,
39
+ navigateTo,
33
40
  }: Props): void => {
34
41
  const autoQuery = useAppSelector(selectAutoQuery);
35
42
  const dispatch = useAppDispatch();
43
+ const queryParams = new URLSearchParams(location.search);
44
+
45
+ const comparing = queryParams.get('comparing') === 'true';
46
+ const expressionA = queryParams.get('expression_a');
47
+
48
+ useEffect(() => {
49
+ if (comparing && expressionA !== null && expressionA !== undefined) {
50
+ if (querySelection.expression === undefined) {
51
+ return;
52
+ }
53
+ const profileA = ProfileSelectionFromParams(
54
+ querySelection.mergeFrom?.toString(),
55
+ querySelection.mergeTo?.toString(),
56
+ querySelection.expression,
57
+ ''
58
+ );
59
+ const queryA = {
60
+ expression: querySelection.expression,
61
+ from: querySelection.from,
62
+ to: querySelection.to,
63
+ timeSelection: querySelection.timeSelection,
64
+ };
65
+
66
+ let compareQuery = {
67
+ compare_a: 'true',
68
+ expression_a: encodeURIComponent(queryA.expression),
69
+ from_a: queryA.from.toString(),
70
+ to_a: queryA.to.toString(),
71
+ time_selection_a: queryA.timeSelection,
72
+
73
+ compare_b: 'true',
74
+ expression_b: encodeURIComponent(queryA.expression),
75
+ from_b: queryA.from.toString(),
76
+ to_b: queryA.to.toString(),
77
+ time_selection_b: queryA.timeSelection,
78
+ };
79
+
80
+ if (profileA != null) {
81
+ compareQuery = {
82
+ ...SuffixParams(profileA.HistoryParams(), '_a'),
83
+ ...compareQuery,
84
+ };
85
+ }
86
+
87
+ void navigateTo('/', {
88
+ ...compareQuery,
89
+ search_string: '',
90
+ dashboard_items: ['icicle'],
91
+ });
92
+ }
93
+ }, [comparing, querySelection, navigateTo, expressionA, dispatch]);
36
94
 
37
95
  // Effect to load some initial data on load when is no selection
38
96
  useEffect(() => {
package/src/utils.ts CHANGED
@@ -14,9 +14,6 @@
14
14
  import type {RpcMetadata} from '@protobuf-ts/runtime-rpc';
15
15
 
16
16
  import {QueryRequest, QueryRequest_ReportType, QueryServiceClient} from '@parca/client';
17
- import {parseParams, type NavigateFunction} from '@parca/utilities';
18
-
19
- import {ProfileSelectionFromParams, SuffixParams, getExpressionAsAString} from '.';
20
17
 
21
18
  export const hexifyAddress = (address?: bigint): string => {
22
19
  if (address == null) {
@@ -62,73 +59,3 @@ export const truncateStringReverse = (str: string, num: number): string => {
62
59
 
63
60
  return '...' + str.slice(str.length - num);
64
61
  };
65
-
66
- export const compareProfile = (
67
- navigateTo: NavigateFunction,
68
- defaultDashboardItems: string[] = ['icicle']
69
- ): void => {
70
- const queryParams = parseParams(window.location.search);
71
-
72
- /* eslint-disable @typescript-eslint/naming-convention */
73
- const {
74
- from_a,
75
- to_a,
76
- merge_from_a,
77
- merge_to_a,
78
- time_selection_a,
79
- filter_by_function,
80
- dashboard_items,
81
- } = queryParams;
82
-
83
- // eslint-disable-next-line @typescript-eslint/naming-convention
84
- const selection_a = getExpressionAsAString(queryParams.selection_a as string | []);
85
-
86
- // eslint-disable-next-line @typescript-eslint/naming-convention
87
- const expression_a = getExpressionAsAString(queryParams.expression_a as string | []);
88
-
89
- if (expression_a === undefined || selection_a === undefined) {
90
- return;
91
- }
92
-
93
- const mergeFrom = merge_from_a ?? undefined;
94
- const mergeTo = merge_to_a ?? undefined;
95
- const profileA = ProfileSelectionFromParams(
96
- mergeFrom as string,
97
- mergeTo as string,
98
- selection_a,
99
- filter_by_function as string
100
- );
101
- const queryA = {
102
- expression: expression_a,
103
- from: parseInt(from_a as string),
104
- to: parseInt(to_a as string),
105
- timeSelection: time_selection_a as string,
106
- };
107
-
108
- let compareQuery = {
109
- compare_a: 'true',
110
- expression_a: encodeURIComponent(queryA.expression),
111
- from_a: queryA.from.toString(),
112
- to_a: queryA.to.toString(),
113
- time_selection_a: queryA.timeSelection,
114
-
115
- compare_b: 'true',
116
- expression_b: encodeURIComponent(queryA.expression),
117
- from_b: queryA.from.toString(),
118
- to_b: queryA.to.toString(),
119
- time_selection_b: queryA.timeSelection,
120
- };
121
-
122
- if (profileA != null) {
123
- compareQuery = {
124
- ...SuffixParams(profileA.HistoryParams(), '_a'),
125
- ...compareQuery,
126
- };
127
- }
128
-
129
- void navigateTo('/', {
130
- ...compareQuery,
131
- search_string: '',
132
- dashboard_items: dashboard_items ?? defaultDashboardItems,
133
- });
134
- };