@parca/profile 0.16.77 → 0.16.79

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 (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/Callgraph/index.d.ts +0 -1
  3. package/dist/GraphTooltip/index.d.ts +0 -1
  4. package/dist/GraphTooltip/index.js +5 -6
  5. package/dist/IcicleGraph.d.ts +0 -1
  6. package/dist/MatchersInput/SuggestionItem.d.ts +0 -1
  7. package/dist/MatchersInput/SuggestionsList.d.ts +0 -1
  8. package/dist/MatchersInput/index.d.ts +0 -1
  9. package/dist/MetricsCircle/index.d.ts +0 -1
  10. package/dist/MetricsGraph/index.d.ts +0 -1
  11. package/dist/MetricsSeries/index.d.ts +0 -1
  12. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts +0 -1
  13. package/dist/ProfileExplorer/ProfileExplorerSingle.d.ts +0 -1
  14. package/dist/ProfileExplorer/index.d.ts +0 -1
  15. package/dist/{ProfileIcicleGraph.d.ts → ProfileIcicleGraph/index.d.ts} +0 -1
  16. package/dist/{ProfileIcicleGraph.js → ProfileIcicleGraph/index.js} +2 -2
  17. package/dist/ProfileMetricsGraph/index.d.ts +0 -1
  18. package/dist/ProfileSelector/CompareButton.d.ts +0 -1
  19. package/dist/ProfileSelector/MergeButton.d.ts +0 -1
  20. package/dist/ProfileSelector/index.d.ts +0 -1
  21. package/dist/ProfileSource.d.ts +0 -1
  22. package/dist/ProfileTypeSelector/index.d.ts +0 -1
  23. package/dist/ProfileView/FilterByFunctionButton.d.ts +0 -1
  24. package/dist/ProfileView/FilterByFunctionButton.js +12 -5
  25. package/dist/ProfileView/index.d.ts +0 -1
  26. package/dist/ProfileView/index.js +27 -4
  27. package/dist/ProfileViewWithData.d.ts +0 -1
  28. package/dist/TopTable.d.ts +0 -1
  29. package/dist/components/DiffLegend.d.ts +0 -1
  30. package/dist/components/ProfileShareButton/ResultBox.d.ts +0 -1
  31. package/dist/components/ProfileShareButton/index.d.ts +0 -1
  32. package/package.json +4 -4
  33. package/src/GraphTooltip/index.tsx +1 -2
  34. package/src/{ProfileIcicleGraph.stories.mdx → ProfileIcicleGraph/ProfileIcicleGraph.stories.mdx} +0 -0
  35. package/src/ProfileIcicleGraph/benchmarks/ProfileIcicleGraph-10M.benchmark.tsx +38 -0
  36. package/src/ProfileIcicleGraph/benchmarks/ProfileIcicleGraph-1M.benchmark.tsx +38 -0
  37. package/src/ProfileIcicleGraph/benchmarks/ProfileIcicleGraph-20M.benchmark.tsx +38 -0
  38. package/src/ProfileIcicleGraph/benchmarks/benchdata/populateData.js +85 -0
  39. package/src/{ProfileIcicleGraph.tsx → ProfileIcicleGraph/index.tsx} +2 -2
  40. package/src/ProfileView/FilterByFunctionButton.tsx +13 -4
  41. package/src/ProfileView/index.tsx +35 -5
  42. package/tsconfig.json +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
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.79](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.78...@parca/profile@0.16.79) (2022-12-07)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
10
+ ## [0.16.78](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.77...@parca/profile@0.16.78) (2022-12-06)
11
+
12
+ **Note:** Version bump only for package @parca/profile
13
+
6
14
  ## [0.16.77](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.76...@parca/profile@0.16.77) (2022-11-29)
7
15
 
8
16
  **Note:** Version bump only for package @parca/profile
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Callgraph as CallgraphType } from '@parca/client';
3
2
  export interface Props {
4
3
  graph: CallgraphType;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CallgraphNode, FlamegraphNode, FlamegraphNodeMeta, FlamegraphRootNode } from '@parca/client';
3
2
  import { Function, Location, Mapping } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
4
3
  interface GraphTooltipProps {
@@ -107,14 +107,13 @@ var TooltipMetaInfo = function (_a) {
107
107
  }
108
108
  }
109
109
  var getTextForFile = function (hoveringNode) {
110
- var _a, _b, _c, _d;
111
- if (hoveringNode.meta === undefined)
110
+ var _a, _b, _c, _d, _e;
111
+ if (((_a = hoveringNode.meta) === null || _a === void 0 ? void 0 : _a.function) == null)
112
112
  return '<unknown>';
113
- // @ts-expect-error
114
- return "".concat(hoveringNode.meta.function.filename, " ").concat(((_a = hoveringNode.meta.line) === null || _a === void 0 ? void 0 : _a.line) !== undefined && ((_b = hoveringNode.meta.line) === null || _b === void 0 ? void 0 : _b.line) !== '0'
113
+ return "".concat(hoveringNode.meta.function.filename, " ").concat(((_b = hoveringNode.meta.line) === null || _b === void 0 ? void 0 : _b.line) !== undefined && ((_c = hoveringNode.meta.line) === null || _c === void 0 ? void 0 : _c.line) !== '0'
115
114
  ? " +".concat(hoveringNode.meta.line.line.toString())
116
- : "".concat(((_c = hoveringNode.meta.function) === null || _c === void 0 ? void 0 : _c.startLine) !== undefined &&
117
- ((_d = hoveringNode.meta.function) === null || _d === void 0 ? void 0 : _d.startLine) !== '0'
115
+ : "".concat(((_d = hoveringNode.meta.function) === null || _d === void 0 ? void 0 : _d.startLine) !== undefined &&
116
+ ((_e = hoveringNode.meta.function) === null || _e === void 0 ? void 0 : _e.startLine) !== '0'
118
117
  ? " +".concat(hoveringNode.meta.function.startLine)
119
118
  : ''));
120
119
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Flamegraph, FlamegraphNode, FlamegraphRootNode } from '@parca/client';
3
2
  import { Mapping, Function, Location } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
4
3
  interface IcicleGraphProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  isHighlighted: boolean;
4
3
  onHighlight: () => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare class Suggestion {
3
2
  type: string;
4
3
  typeahead: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Query } from '@parca/parser';
3
2
  import { LabelsResponse, QueryServiceClient } from '@parca/client';
4
3
  interface MatchersInputProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface MetricsCircleProps {
3
2
  cx: number;
4
3
  cy: number;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SingleProfileSelection } from '..';
3
2
  import { MetricsSeries as MetricsSeriesPb, Label } from '@parca/client';
4
3
  import { DateTimeRange } from '@parca/components';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import * as d3 from 'd3';
3
2
  interface MetricsSeriesProps {
4
3
  data: any;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ProfileSelection, NavigateFunction } from '..';
3
2
  import { QueryServiceClient } from '@parca/client';
4
3
  import { QuerySelection } from '../ProfileSelector';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryServiceClient } from '@parca/client';
3
2
  import { ProfileSelection, NavigateFunction } from '..';
4
3
  import { QuerySelection } from '../ProfileSelector';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { NavigateFunction } from '..';
3
2
  import { QueryServiceClient } from '@parca/client';
4
3
  interface ProfileExplorerProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Flamegraph } from '@parca/client';
3
2
  interface ProfileIcicleGraphProps {
4
3
  width?: number;
@@ -12,8 +12,8 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useAppSelector, selectCompareMode } from '@parca/store';
14
14
  import { useContainerDimensions } from '@parca/dynamicsize';
15
- import DiffLegend from './components/DiffLegend';
16
- import IcicleGraph from './IcicleGraph';
15
+ import DiffLegend from '../components/DiffLegend';
16
+ import IcicleGraph from '../IcicleGraph';
17
17
  var ProfileIcicleGraph = function (_a) {
18
18
  var graph = _a.graph, curPath = _a.curPath, setNewCurPath = _a.setNewCurPath, sampleUnit = _a.sampleUnit;
19
19
  var compareMode = useAppSelector(selectCompareMode);
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ProfileSelection } from '..';
3
2
  import { QueryServiceClient, QueryRangeResponse } from '@parca/client';
4
3
  import { RpcError } from '@protobuf-ts/runtime-rpc';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const CompareButton: ({ disabled, onClick, }: {
3
2
  disabled: boolean;
4
3
  onClick: () => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const MergeButton: ({ disabled, onClick, }: {
3
2
  disabled: boolean;
4
3
  onClick: () => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryServiceClient, ProfileTypesResponse } from '@parca/client';
3
2
  import { RpcError } from '@protobuf-ts/runtime-rpc';
4
3
  import { ProfileSelection } from '..';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ProfileType } from '@parca/parser';
3
2
  import { Label, QueryRequest, ProfileDiffSelection } from '@parca/client';
4
3
  export interface ProfileSource {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ProfileType, ProfileTypesResponse } from '@parca/client';
3
2
  import { RpcError } from '@protobuf-ts/runtime-rpc';
4
3
  interface WellKnownProfile {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const FilterByFunctionButton: () => JSX.Element;
3
2
  export default FilterByFunctionButton;
@@ -13,14 +13,21 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  // limitations under the License.
14
14
  import { Input } from '@parca/components';
15
15
  import { selectFilterByFunction, setFilterByFunction, useAppDispatch, useAppSelector, } from '@parca/store';
16
- import { useState } from 'react';
16
+ import { Icon } from '@iconify/react';
17
+ import { useCallback, useMemo, useState } from 'react';
17
18
  var FilterByFunctionButton = function () {
18
19
  var dispatch = useAppDispatch();
19
20
  var storeVal = useAppSelector(selectFilterByFunction);
20
21
  var _a = useState(storeVal !== null && storeVal !== void 0 ? storeVal : ''), value = _a[0], setValue = _a[1];
21
- var onAction = function () {
22
- dispatch(setFilterByFunction(value));
23
- };
24
- return (_jsx(Input, { placeholder: "Filter by function", className: "text-sm", onAction: onAction, onChange: function (e) { return setValue(e.target.value); }, value: value, onBlur: function () { return setValue(storeVal !== null && storeVal !== void 0 ? storeVal : ''); } }));
22
+ var isClearAction = useMemo(function () {
23
+ return value === storeVal && value != null;
24
+ }, [value, storeVal]);
25
+ var onAction = useCallback(function () {
26
+ dispatch(setFilterByFunction(isClearAction ? undefined : value));
27
+ if (isClearAction) {
28
+ setValue('');
29
+ }
30
+ }, [dispatch, isClearAction, value]);
31
+ return (_jsx(Input, { placeholder: "Filter by function", className: "text-sm", onAction: onAction, onChange: function (e) { return setValue(e.target.value); }, value: value, onBlur: function () { return setValue(storeVal !== null && storeVal !== void 0 ? storeVal : ''); }, actionIcon: isClearAction ? _jsx(Icon, { icon: "ep:circle-close" }) : _jsx(Icon, { icon: "ep:arrow-right" }) }));
25
32
  };
26
33
  export default FilterByFunctionButton;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryServiceClient, Flamegraph, Top, Callgraph as CallgraphType } from '@parca/client';
3
2
  import { ProfileSource } from '../ProfileSource';
4
3
  import '../ProfileView.styles.css';
@@ -26,9 +26,9 @@ import { Profiler, useEffect, useMemo, useState } from 'react';
26
26
  import { scaleLinear } from 'd3';
27
27
  import { getNewSpanColor, parseParams } from '@parca/functions';
28
28
  import useUIFeatureFlag from '@parca/functions/useUIFeatureFlag';
29
- import { Button, Card, SearchNodes, useParcaContext } from '@parca/components';
29
+ import { Button, Card, useParcaContext } from '@parca/components';
30
30
  import { useContainerDimensions } from '@parca/dynamicsize';
31
- import { useAppSelector, selectDarkMode, selectSearchNodeString } from '@parca/store';
31
+ import { useAppSelector, selectDarkMode, selectSearchNodeString, selectFilterByFunction, useAppDispatch, setSearchNodeString, } from '@parca/store';
32
32
  import { Callgraph } from '../';
33
33
  import ProfileShareButton from '../components/ProfileShareButton';
34
34
  import FilterByFunctionButton from './FilterByFunctionButton';
@@ -58,13 +58,15 @@ export var useProfileVisState = function () {
58
58
  };
59
59
  export var ProfileView = function (_a) {
60
60
  var flamegraphData = _a.flamegraphData, topTableData = _a.topTableData, callgraphData = _a.callgraphData, sampleUnit = _a.sampleUnit, profileSource = _a.profileSource, queryClient = _a.queryClient, navigateTo = _a.navigateTo, profileVisState = _a.profileVisState, onDownloadPProf = _a.onDownloadPProf;
61
+ var dispatch = useAppDispatch();
61
62
  var _b = useContainerDimensions(), ref = _b.ref, dimensions = _b.dimensions;
62
63
  var _c = useState([]), curPath = _c[0], setCurPath = _c[1];
63
64
  var currentView = profileVisState.currentView, setCurrentView = profileVisState.setCurrentView;
64
65
  var isDarkMode = useAppSelector(selectDarkMode);
65
66
  var currentSearchString = useAppSelector(selectSearchNodeString);
67
+ var filterByFunctionString = useAppSelector(selectFilterByFunction);
66
68
  var callgraphEnabled = useUIFeatureFlag('callgraph')[0];
67
- var filterByFunctionEnabled = useUIFeatureFlag('filterByFunction')[0];
69
+ var highlightAfterFilteringEnabled = useUIFeatureFlag('highlightAfterFiltering')[0];
68
70
  var _d = useParcaContext(), loader = _d.loader, perf = _d.perf;
69
71
  useEffect(function () {
70
72
  // Reset the current path when the profile source changes
@@ -85,6 +87,27 @@ export var ProfileView = function (_a) {
85
87
  }
86
88
  return false;
87
89
  }, [currentView, callgraphData === null || callgraphData === void 0 ? void 0 : callgraphData.loading, flamegraphData === null || flamegraphData === void 0 ? void 0 : flamegraphData.loading, topTableData === null || topTableData === void 0 ? void 0 : topTableData.loading]);
90
+ useEffect(function () {
91
+ if (!highlightAfterFilteringEnabled) {
92
+ if (currentSearchString !== undefined && currentSearchString !== '') {
93
+ dispatch(setSearchNodeString(''));
94
+ }
95
+ return;
96
+ }
97
+ if (isLoading) {
98
+ return;
99
+ }
100
+ if (filterByFunctionString === currentSearchString) {
101
+ return;
102
+ }
103
+ dispatch(setSearchNodeString(filterByFunctionString));
104
+ }, [
105
+ isLoading,
106
+ filterByFunctionString,
107
+ dispatch,
108
+ highlightAfterFilteringEnabled,
109
+ currentSearchString,
110
+ ]);
88
111
  var isLoaderVisible = useDelayedLoader(isLoading);
89
112
  if (isLoaderVisible) {
90
113
  return _jsx(_Fragment, { children: loader });
@@ -117,5 +140,5 @@ export var ProfileView = function (_a) {
117
140
  return (_jsx(_Fragment, { children: _jsx("div", __assign({ className: "py-3" }, { children: _jsx(Card, { children: _jsxs(Card.Body, { children: [_jsxs("div", __assign({ className: "flex py-3 w-full" }, { children: [_jsxs("div", __assign({ className: "w-2/5 flex space-x-4" }, { children: [_jsxs("div", __assign({ className: "flex space-x-1" }, { children: [profileSource != null && queryClient != null ? (_jsx(ProfileShareButton, { queryRequest: profileSource.QueryRequest(), queryClient: queryClient })) : null, _jsx(Button, __assign({ color: "neutral", onClick: function (e) {
118
141
  e.preventDefault();
119
142
  onDownloadPProf();
120
- } }, { children: "Download pprof" }))] })), filterByFunctionEnabled ? _jsx(FilterByFunctionButton, {}) : _jsx(SearchNodes, {})] })), _jsxs("div", __assign({ className: "flex ml-auto gap-2" }, { children: [filterByFunctionEnabled ? _jsx(SearchNodes, {}) : null, _jsx(Button, __assign({ color: "neutral", onClick: resetIcicleGraph, disabled: curPath.length === 0, className: "whitespace-nowrap text-ellipsis" }, { children: "Reset View" })), callgraphEnabled ? (_jsx(Button, __assign({ variant: "".concat(currentView === 'callgraph' ? 'primary' : 'neutral'), onClick: function () { return switchProfileView('callgraph'); }, className: "whitespace-nowrap text-ellipsis" }, { children: "Callgraph" }))) : null, _jsxs("div", __assign({ className: "flex" }, { children: [_jsx(Button, __assign({ variant: "".concat(currentView === 'table' ? 'primary' : 'neutral'), className: "items-center rounded-tr-none rounded-br-none w-auto px-8 whitespace-nowrap text-ellipsis no-outline-on-buttons", onClick: function () { return switchProfileView('table'); } }, { children: "Table" })), _jsx(Button, __assign({ variant: "".concat(currentView === 'both' ? 'primary' : 'neutral'), className: "items-center rounded-tl-none rounded-tr-none rounded-bl-none rounded-br-none border-l-0 border-r-0 w-auto px-8 whitespace-nowrap no-outline-on-buttons text-ellipsis", onClick: function () { return switchProfileView('both'); } }, { children: "Both" })), _jsx(Button, __assign({ variant: "".concat(currentView === 'icicle' ? 'primary' : 'neutral'), className: "items-center rounded-tl-none rounded-bl-none w-auto px-8 whitespace-nowrap text-ellipsis no-outline-on-buttons", onClick: function () { return switchProfileView('icicle'); } }, { children: "Icicle Graph" }))] }))] }))] })), _jsxs("div", __assign({ ref: ref, className: "flex space-x-4 justify-between w-full" }, { children: [currentView === 'icicle' && (flamegraphData === null || flamegraphData === void 0 ? void 0 : flamegraphData.data) != null && (_jsx("div", __assign({ className: "w-full" }, { children: _jsx(Profiler, __assign({ id: "icicleGraph", onRender: perf === null || perf === void 0 ? void 0 : perf.onRender }, { children: _jsx(ProfileIcicleGraph, { curPath: curPath, setNewCurPath: setNewCurPath, graph: flamegraphData.data, sampleUnit: sampleUnit }) })) }))), currentView === 'callgraph' && (callgraphData === null || callgraphData === void 0 ? void 0 : callgraphData.data) != null && (_jsx("div", __assign({ className: "w-full" }, { children: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) !== undefined && (_jsx(Callgraph, { graph: callgraphData.data, sampleUnit: sampleUnit, width: dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, colorRange: colorRange })) }))), currentView === 'table' && topTableData != null && (_jsx("div", __assign({ className: "w-full" }, { children: _jsx(TopTable, { data: topTableData.data, sampleUnit: sampleUnit }) }))), currentView === 'both' && (_jsxs(_Fragment, { children: [_jsx("div", __assign({ className: "w-1/2" }, { children: _jsx(TopTable, { data: topTableData === null || topTableData === void 0 ? void 0 : topTableData.data, sampleUnit: sampleUnit }) })), _jsx("div", __assign({ className: "w-1/2" }, { children: flamegraphData != null && (_jsx(ProfileIcicleGraph, { curPath: curPath, setNewCurPath: setNewCurPath, graph: flamegraphData.data, sampleUnit: sampleUnit })) }))] }))] }))] }) }) })) }));
143
+ } }, { children: "Download pprof" }))] })), _jsx(FilterByFunctionButton, {})] })), _jsxs("div", __assign({ className: "flex ml-auto gap-2" }, { children: [_jsx(Button, __assign({ color: "neutral", onClick: resetIcicleGraph, disabled: curPath.length === 0, className: "whitespace-nowrap text-ellipsis" }, { children: "Reset View" })), callgraphEnabled ? (_jsx(Button, __assign({ variant: "".concat(currentView === 'callgraph' ? 'primary' : 'neutral'), onClick: function () { return switchProfileView('callgraph'); }, className: "whitespace-nowrap text-ellipsis" }, { children: "Callgraph" }))) : null, _jsxs("div", __assign({ className: "flex" }, { children: [_jsx(Button, __assign({ variant: "".concat(currentView === 'table' ? 'primary' : 'neutral'), className: "items-center rounded-tr-none rounded-br-none w-auto px-8 whitespace-nowrap text-ellipsis no-outline-on-buttons", onClick: function () { return switchProfileView('table'); } }, { children: "Table" })), _jsx(Button, __assign({ variant: "".concat(currentView === 'both' ? 'primary' : 'neutral'), className: "items-center rounded-tl-none rounded-tr-none rounded-bl-none rounded-br-none border-l-0 border-r-0 w-auto px-8 whitespace-nowrap no-outline-on-buttons text-ellipsis", onClick: function () { return switchProfileView('both'); } }, { children: "Both" })), _jsx(Button, __assign({ variant: "".concat(currentView === 'icicle' ? 'primary' : 'neutral'), className: "items-center rounded-tl-none rounded-bl-none w-auto px-8 whitespace-nowrap text-ellipsis no-outline-on-buttons", onClick: function () { return switchProfileView('icicle'); } }, { children: "Icicle Graph" }))] }))] }))] })), _jsxs("div", __assign({ ref: ref, className: "flex space-x-4 justify-between w-full" }, { children: [currentView === 'icicle' && (flamegraphData === null || flamegraphData === void 0 ? void 0 : flamegraphData.data) != null && (_jsx("div", __assign({ className: "w-full" }, { children: _jsx(Profiler, __assign({ id: "icicleGraph", onRender: perf === null || perf === void 0 ? void 0 : perf.onRender }, { children: _jsx(ProfileIcicleGraph, { curPath: curPath, setNewCurPath: setNewCurPath, graph: flamegraphData.data, sampleUnit: sampleUnit }) })) }))), currentView === 'callgraph' && (callgraphData === null || callgraphData === void 0 ? void 0 : callgraphData.data) != null && (_jsx("div", __assign({ className: "w-full" }, { children: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) !== undefined && (_jsx(Callgraph, { graph: callgraphData.data, sampleUnit: sampleUnit, width: dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, colorRange: colorRange })) }))), currentView === 'table' && topTableData != null && (_jsx("div", __assign({ className: "w-full" }, { children: _jsx(TopTable, { data: topTableData.data, sampleUnit: sampleUnit }) }))), currentView === 'both' && (_jsxs(_Fragment, { children: [_jsx("div", __assign({ className: "w-1/2" }, { children: _jsx(TopTable, { data: topTableData === null || topTableData === void 0 ? void 0 : topTableData.data, sampleUnit: sampleUnit }) })), _jsx("div", __assign({ className: "w-1/2" }, { children: flamegraphData != null && (_jsx(ProfileIcicleGraph, { curPath: curPath, setNewCurPath: setNewCurPath, graph: flamegraphData.data, sampleUnit: sampleUnit })) }))] }))] }))] }) }) })) }));
121
144
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryServiceClient } from '@parca/client';
3
2
  import { ProfileSource } from './ProfileSource';
4
3
  export type NavigateFunction = (path: string, queryParams: any) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { TopNodeMeta, Top } from '@parca/client';
3
2
  import './TopTable.styles.css';
4
3
  interface TopTableProps {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const DiffLegend: () => JSX.Element;
3
2
  export default DiffLegend;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  value: string;
4
3
  className?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { QueryRequest, QueryServiceClient } from '@parca/client';
3
2
  interface Props {
4
3
  queryRequest: QueryRequest;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.77",
3
+ "version": "0.16.79",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
- "@parca/client": "^0.16.56",
7
- "@parca/components": "^0.16.67",
6
+ "@parca/client": "^0.16.57",
7
+ "@parca/components": "^0.16.69",
8
8
  "@parca/dynamicsize": "^0.16.51",
9
9
  "@parca/functions": "^0.16.53",
10
10
  "@parca/parser": "^0.16.51",
@@ -42,5 +42,5 @@
42
42
  "access": "public",
43
43
  "registry": "https://registry.npmjs.org/"
44
44
  },
45
- "gitHead": "32660c63e7b5d189c3e29abb0321d8e49bbcbc28"
45
+ "gitHead": "0dd3c9d9932a54c9d2ee031610f1c4645b9038dc"
46
46
  }
@@ -123,9 +123,8 @@ const TooltipMetaInfo = ({
123
123
  }
124
124
 
125
125
  const getTextForFile = (hoveringNode: FlamegraphNode): string => {
126
- if (hoveringNode.meta === undefined) return '<unknown>';
126
+ if (hoveringNode.meta?.function == null) return '<unknown>';
127
127
 
128
- // @ts-expect-error
129
128
  return `${hoveringNode.meta.function.filename} ${
130
129
  hoveringNode.meta.line?.line !== undefined && hoveringNode.meta.line?.line !== '0'
131
130
  ? ` +${hoveringNode.meta.line.line.toString()}`
@@ -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 React from 'react';
15
+ import ProfileIcicleGraph from '..';
16
+ import {Provider} from 'react-redux';
17
+ import {store} from '@parca/store';
18
+ import parca10mGraphData from './benchdata/parca-10m.json';
19
+ import {Flamegraph} from '@parca/client';
20
+
21
+ const {store: reduxStore} = store();
22
+
23
+ const parca10mGraph = parca10mGraphData as Flamegraph;
24
+
25
+ export default function ({callback = () => {}}): React.ReactElement {
26
+ return (
27
+ <div ref={callback}>
28
+ <Provider store={reduxStore}>
29
+ <ProfileIcicleGraph
30
+ graph={parca10mGraph}
31
+ sampleUnit={parca10mGraph.unit}
32
+ curPath={[]}
33
+ setNewCurPath={() => {}}
34
+ />
35
+ </Provider>
36
+ </div>
37
+ );
38
+ }
@@ -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 React from 'react';
15
+ import ProfileIcicleGraph from '../';
16
+ import {Provider} from 'react-redux';
17
+ import {store} from '@parca/store';
18
+ import {Flamegraph} from '@parca/client';
19
+ import parca1mGraphData from './benchdata/parca-1m.json';
20
+
21
+ const {store: reduxStore} = store();
22
+
23
+ const parca1mGraph = parca1mGraphData as Flamegraph;
24
+
25
+ export default function ({callback = () => {}}): React.ReactElement {
26
+ return (
27
+ <div ref={callback}>
28
+ <Provider store={reduxStore}>
29
+ <ProfileIcicleGraph
30
+ graph={parca1mGraph}
31
+ sampleUnit={parca1mGraph.unit}
32
+ curPath={[]}
33
+ setNewCurPath={() => {}}
34
+ />
35
+ </Provider>
36
+ </div>
37
+ );
38
+ }
@@ -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 React from 'react';
15
+ import ProfileIcicleGraph from '..';
16
+ import {Provider} from 'react-redux';
17
+ import {store} from '@parca/store';
18
+ import parca20mGraphData from './benchdata/parca-20m.json';
19
+ import {Flamegraph} from '@parca/client';
20
+
21
+ const {store: reduxStore} = store();
22
+
23
+ const parca20mGraph = parca20mGraphData as Flamegraph;
24
+
25
+ export default function ({callback = () => {}}): React.ReactElement {
26
+ return (
27
+ <div ref={callback}>
28
+ <Provider store={reduxStore}>
29
+ <ProfileIcicleGraph
30
+ graph={parca20mGraph}
31
+ sampleUnit={parca20mGraph.unit}
32
+ curPath={[]}
33
+ setNewCurPath={() => {}}
34
+ />
35
+ </Provider>
36
+ </div>
37
+ );
38
+ }
@@ -0,0 +1,85 @@
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
+ const {GrpcWebFetchTransport} = require('@protobuf-ts/grpcweb-transport');
15
+ const client = require('@parca/client');
16
+ const fs = require('fs-extra');
17
+ const path = require('path');
18
+ // const {fileURLToPath} = require('url');
19
+ const fetch = require('node-fetch');
20
+
21
+ globalThis.fetch = fetch;
22
+ globalThis.Headers = fetch.Headers;
23
+ const DIR_NAME = __dirname; // path.dirname(fileURLToPath(import.meta.url));
24
+
25
+ const apiEndpoint = 'https://demo.parca.dev';
26
+
27
+ const queryClient = new client.QueryServiceClient(
28
+ new GrpcWebFetchTransport({
29
+ baseUrl: `${apiEndpoint}/api`,
30
+ })
31
+ );
32
+
33
+ const populateDataIfNeeded = async (from, filename) => {
34
+ const filePath = path.join(DIR_NAME, filename);
35
+ if (Object.keys(await readFile(filePath)).length > 0) {
36
+ return;
37
+ }
38
+ const {response} = await queryClient.query({
39
+ options: {
40
+ oneofKind: 'merge',
41
+ merge: {
42
+ start: client.Timestamp.fromDate(from),
43
+ end: client.Timestamp.fromDate(new Date()),
44
+ query: 'parca_agent_cpu:samples:count:cpu:nanoseconds:delta{container="parca"}',
45
+ },
46
+ },
47
+ reportType: client.QueryRequest_ReportType.FLAMEGRAPH_TABLE,
48
+ mode: client.QueryRequest_Mode.MERGE,
49
+ });
50
+ if (response.report.oneofKind !== 'flamegraph') {
51
+ throw new Error('Expected flamegraph report');
52
+ }
53
+ await writeToFile(response.report.flamegraph, filePath);
54
+ };
55
+
56
+ const writeToFile = async (data, filename) => {
57
+ await fs.createFile(filename);
58
+ return await fs.writeFile(filename, JSON.stringify(data));
59
+ };
60
+
61
+ const readFile = async filename => {
62
+ try {
63
+ return await fs.readJSON(filename);
64
+ } catch (e) {
65
+ return {};
66
+ }
67
+ };
68
+
69
+ const run = async () => {
70
+ await Promise.all([
71
+ populateDataIfNeeded(new Date(new Date().getTime() - 1000 * 60), 'parca-1m.json'),
72
+ populateDataIfNeeded(new Date(new Date().getTime() - 1000 * 60 * 10), 'parca-10m.json'),
73
+ populateDataIfNeeded(new Date(new Date().getTime() - 1000 * 60 * 20), 'parca-20m.json'),
74
+ ]);
75
+ };
76
+
77
+ run()
78
+ .then(() => {
79
+ console.log('done');
80
+ process.exit(0);
81
+ })
82
+ .catch(err => {
83
+ console.error('Error:', err);
84
+ process.exit(1);
85
+ });
@@ -15,8 +15,8 @@ import {Flamegraph} from '@parca/client';
15
15
  import {useAppSelector, selectCompareMode} from '@parca/store';
16
16
  import {useContainerDimensions} from '@parca/dynamicsize';
17
17
 
18
- import DiffLegend from './components/DiffLegend';
19
- import IcicleGraph from './IcicleGraph';
18
+ import DiffLegend from '../components/DiffLegend';
19
+ import IcicleGraph from '../IcicleGraph';
20
20
 
21
21
  interface ProfileIcicleGraphProps {
22
22
  width?: number;
@@ -18,16 +18,24 @@ import {
18
18
  useAppDispatch,
19
19
  useAppSelector,
20
20
  } from '@parca/store';
21
- import {useState} from 'react';
21
+ import {Icon} from '@iconify/react';
22
+ import {useCallback, useMemo, useState} from 'react';
22
23
 
23
24
  const FilterByFunctionButton = (): JSX.Element => {
24
25
  const dispatch = useAppDispatch();
25
26
  const storeVal = useAppSelector(selectFilterByFunction);
26
27
  const [value, setValue] = useState<string>(storeVal ?? '');
27
28
 
28
- const onAction = (): void => {
29
- dispatch(setFilterByFunction(value));
30
- };
29
+ const isClearAction = useMemo(() => {
30
+ return value === storeVal && value != null;
31
+ }, [value, storeVal]);
32
+
33
+ const onAction = useCallback((): void => {
34
+ dispatch(setFilterByFunction(isClearAction ? undefined : value));
35
+ if (isClearAction) {
36
+ setValue('');
37
+ }
38
+ }, [dispatch, isClearAction, value]);
31
39
 
32
40
  return (
33
41
  <Input
@@ -37,6 +45,7 @@ const FilterByFunctionButton = (): JSX.Element => {
37
45
  onChange={e => setValue(e.target.value)}
38
46
  value={value}
39
47
  onBlur={() => setValue(storeVal ?? '')}
48
+ actionIcon={isClearAction ? <Icon icon="ep:circle-close" /> : <Icon icon="ep:arrow-right" />}
40
49
  />
41
50
  );
42
51
  };
@@ -17,9 +17,16 @@ import {scaleLinear} from 'd3';
17
17
  import {getNewSpanColor, parseParams} from '@parca/functions';
18
18
  import useUIFeatureFlag from '@parca/functions/useUIFeatureFlag';
19
19
  import {QueryServiceClient, Flamegraph, Top, Callgraph as CallgraphType} from '@parca/client';
20
- import {Button, Card, SearchNodes, useParcaContext} from '@parca/components';
20
+ import {Button, Card, useParcaContext} from '@parca/components';
21
21
  import {useContainerDimensions} from '@parca/dynamicsize';
22
- import {useAppSelector, selectDarkMode, selectSearchNodeString} from '@parca/store';
22
+ import {
23
+ useAppSelector,
24
+ selectDarkMode,
25
+ selectSearchNodeString,
26
+ selectFilterByFunction,
27
+ useAppDispatch,
28
+ setSearchNodeString,
29
+ } from '@parca/store';
23
30
 
24
31
  import {Callgraph} from '../';
25
32
  import ProfileShareButton from '../components/ProfileShareButton';
@@ -107,14 +114,16 @@ export const ProfileView = ({
107
114
  profileVisState,
108
115
  onDownloadPProf,
109
116
  }: ProfileViewProps): JSX.Element => {
117
+ const dispatch = useAppDispatch();
110
118
  const {ref, dimensions} = useContainerDimensions();
111
119
  const [curPath, setCurPath] = useState<string[]>([]);
112
120
  const {currentView, setCurrentView} = profileVisState;
113
121
  const isDarkMode = useAppSelector(selectDarkMode);
114
122
  const currentSearchString = useAppSelector(selectSearchNodeString);
123
+ const filterByFunctionString = useAppSelector(selectFilterByFunction);
115
124
 
116
125
  const [callgraphEnabled] = useUIFeatureFlag('callgraph');
117
- const [filterByFunctionEnabled] = useUIFeatureFlag('filterByFunction');
126
+ const [highlightAfterFilteringEnabled] = useUIFeatureFlag('highlightAfterFiltering');
118
127
 
119
128
  const {loader, perf} = useParcaContext();
120
129
 
@@ -139,6 +148,28 @@ export const ProfileView = ({
139
148
  return false;
140
149
  }, [currentView, callgraphData?.loading, flamegraphData?.loading, topTableData?.loading]);
141
150
 
151
+ useEffect(() => {
152
+ if (!highlightAfterFilteringEnabled) {
153
+ if (currentSearchString !== undefined && currentSearchString !== '') {
154
+ dispatch(setSearchNodeString(''));
155
+ }
156
+ return;
157
+ }
158
+ if (isLoading) {
159
+ return;
160
+ }
161
+ if (filterByFunctionString === currentSearchString) {
162
+ return;
163
+ }
164
+ dispatch(setSearchNodeString(filterByFunctionString));
165
+ }, [
166
+ isLoading,
167
+ filterByFunctionString,
168
+ dispatch,
169
+ highlightAfterFilteringEnabled,
170
+ currentSearchString,
171
+ ]);
172
+
142
173
  const isLoaderVisible = useDelayedLoader(isLoading);
143
174
 
144
175
  if (isLoaderVisible) {
@@ -210,11 +241,10 @@ export const ProfileView = ({
210
241
  Download pprof
211
242
  </Button>
212
243
  </div>
213
- {filterByFunctionEnabled ? <FilterByFunctionButton /> : <SearchNodes />}
244
+ <FilterByFunctionButton />
214
245
  </div>
215
246
 
216
247
  <div className="flex ml-auto gap-2">
217
- {filterByFunctionEnabled ? <SearchNodes /> : null}
218
248
  <Button
219
249
  color="neutral"
220
250
  onClick={resetIcicleGraph}
package/tsconfig.json CHANGED
@@ -8,5 +8,5 @@
8
8
  "noEmit": false,
9
9
  "declaration": true
10
10
  },
11
- "exclude": ["node_modules", "dist", "dist/**/*.d.ts", "**/*.test.ts"]
11
+ "exclude": ["node_modules", "dist", "dist/**/*.d.ts", "**/*.test.ts", "**/*.benchmark.tsx"]
12
12
  }