@parca/profile 0.16.62 → 0.16.64

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,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.64](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.63...@parca/profile@0.16.64) (2022-11-08)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
10
+ ## [0.16.63](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.62...@parca/profile@0.16.63) (2022-11-08)
11
+
12
+ **Note:** Version bump only for package @parca/profile
13
+
6
14
  ## 0.16.62 (2022-11-08)
7
15
 
8
16
  **Note:** Version bump only for package @parca/profile
@@ -108,7 +108,7 @@ var Callgraph = function (_a) {
108
108
  }), stage = _f[0], setStage = _f[1];
109
109
  var rawNodes = graph.nodes, total = graph.cumulative;
110
110
  var currentSearchString = useAppSelector(selectSearchNodeString);
111
- var isSearchEmpty = currentSearchString === undefined;
111
+ var isSearchEmpty = currentSearchString === undefined || currentSearchString === '';
112
112
  useEffect(function () {
113
113
  var getDataWithPositions = function () { return __awaiter(void 0, void 0, void 0, function () {
114
114
  var dataAsDot, jsonGraph;
@@ -159,24 +159,29 @@ var Callgraph = function (_a) {
159
159
  // 4. Add zooming
160
160
  var handleWheel = function (e) {
161
161
  var _a;
162
+ // stop default scrolling
162
163
  e.evt.preventDefault();
163
- var scaleXBy = 0.95;
164
- var scaleYBy = 1.05;
164
+ var scaleBy = 1.01;
165
165
  var stage = e.target.getStage();
166
166
  if (stage !== null) {
167
167
  var oldScale = stage.scaleX();
168
- var _b = (_a = stage.getPointerPosition()) !== null && _a !== void 0 ? _a : { x: 0, y: 0 }, x = _b.x, y = _b.y;
168
+ var pointer = (_a = stage.getPointerPosition()) !== null && _a !== void 0 ? _a : { x: 0, y: 0 };
169
169
  var mousePointTo = {
170
- x: x / oldScale - stage.x() / oldScale,
171
- y: y / oldScale - stage.y() / oldScale,
170
+ x: pointer.x / oldScale - stage.x() / oldScale,
171
+ y: pointer.y / oldScale - stage.y() / oldScale,
172
172
  };
173
- var newXScale = e.evt.deltaX > 0 ? oldScale * scaleXBy : oldScale / scaleXBy;
174
- var newYScale = e.evt.deltaY > 0 ? oldScale * scaleYBy : oldScale / scaleYBy;
175
- stage.scale({ x: newXScale, y: newYScale });
173
+ // whether to zoom in or out
174
+ var direction = e.evt.deltaY > 0 ? 1 : -1;
175
+ // for trackpad, e.evt.ctrlKey is true => in that case, revert direction
176
+ if (e.evt.ctrlKey) {
177
+ direction = -direction;
178
+ }
179
+ var newScale = direction > 0 ? oldScale * scaleBy : oldScale / scaleBy;
180
+ stage.scale({ x: newScale, y: newScale });
176
181
  setStage({
177
- scale: { x: newXScale, y: newYScale },
178
- x: -(mousePointTo.x - x / newXScale) * newXScale,
179
- y: -(mousePointTo.y - y / newYScale) * newYScale,
182
+ scale: { x: newScale, y: newScale },
183
+ x: -(mousePointTo.x - pointer.x / newScale) * newScale,
184
+ y: -(mousePointTo.y - pointer.y / newScale) * newScale,
180
185
  });
181
186
  }
182
187
  };
@@ -74,20 +74,29 @@ var TooltipMetaInfo = function (_a) {
74
74
  if (hoveringNode.meta === undefined)
75
75
  return _jsx(_Fragment, {});
76
76
  // populate meta from the flamegraph metadata tables
77
- if (locations !== undefined) {
78
- var location_1 = locations[hoveringNode.meta.locationIndex];
77
+ if (locations !== undefined &&
78
+ hoveringNode.meta.locationIndex !== undefined &&
79
+ hoveringNode.meta.locationIndex !== 0) {
80
+ var location_1 = locations[hoveringNode.meta.locationIndex - 1];
79
81
  hoveringNode.meta.location = location_1;
80
- if (mappings !== undefined) {
81
- var mapping = mappings[location_1.mappingIndex];
82
- if (strings !== undefined) {
83
- mapping.file = strings[mapping.fileStringIndex];
84
- mapping.buildId = strings[mapping.buildIdStringIndex];
82
+ if (location_1 !== undefined) {
83
+ if (mappings !== undefined &&
84
+ location_1.mappingIndex !== undefined &&
85
+ location_1.mappingIndex !== 0) {
86
+ var mapping = mappings[location_1.mappingIndex - 1];
87
+ if (strings !== undefined && mapping !== undefined) {
88
+ mapping.file =
89
+ (mapping === null || mapping === void 0 ? void 0 : mapping.fileStringIndex) !== undefined ? strings[mapping.fileStringIndex] : '';
90
+ mapping.buildId =
91
+ (mapping === null || mapping === void 0 ? void 0 : mapping.buildIdStringIndex) !== undefined ? strings[mapping.buildIdStringIndex] : '';
92
+ }
93
+ hoveringNode.meta.mapping = mapping;
85
94
  }
86
- hoveringNode.meta.mapping = mapping;
87
- }
88
- location_1.lines.forEach(function (line) {
89
- if (functions !== undefined && hoveringNode.meta !== undefined) {
90
- var func = functions[line.functionIndex];
95
+ if (functions !== undefined &&
96
+ location_1.lines !== undefined &&
97
+ hoveringNode.meta.lineIndex !== undefined &&
98
+ hoveringNode.meta.lineIndex < location_1.lines.length) {
99
+ var func = functions[location_1.lines[hoveringNode.meta.lineIndex].functionIndex - 1];
91
100
  if (strings !== undefined) {
92
101
  func.name = strings[func.nameStringIndex];
93
102
  func.systemName = strings[func.systemNameStringIndex];
@@ -95,7 +104,7 @@ var TooltipMetaInfo = function (_a) {
95
104
  }
96
105
  hoveringNode.meta.function = func;
97
106
  }
98
- });
107
+ }
99
108
  }
100
109
  var getTextForFile = function (hoveringNode) {
101
110
  var _a, _b, _c, _d;
@@ -56,14 +56,19 @@ function IcicleRect(_a) {
56
56
  } }), width > 5 && (_jsx("svg", __assign({ width: width - 5, height: height }, { children: _jsx("text", __assign({ x: 5, y: 15, style: { fontSize: '12px' } }, { children: name })) })))] })));
57
57
  }
58
58
  export function nodeLabel(node, strings, mappings, locations, functions) {
59
- var _a, _b;
59
+ var _a, _b, _c;
60
60
  if (((_a = node.meta) === null || _a === void 0 ? void 0 : _a.locationIndex) === undefined)
61
61
  return '<unknown>';
62
- var location = locations[node.meta.locationIndex];
63
- var mappingFile = strings[mappings[location.mappingIndex].fileStringIndex];
64
- var mappingString = "".concat(mappingFile !== '' ? '[' + ((_b = getLastItem(mappingFile)) !== null && _b !== void 0 ? _b : '') + '] ' : '');
62
+ if (((_b = node.meta) === null || _b === void 0 ? void 0 : _b.locationIndex) === 0)
63
+ return '<unknown>';
64
+ var location = locations[node.meta.locationIndex - 1];
65
+ var mapping = location.mappingIndex !== undefined || location.mappingIndex !== 0
66
+ ? mappings[location.mappingIndex - 1]
67
+ : undefined;
68
+ var mappingFile = (mapping === null || mapping === void 0 ? void 0 : mapping.fileStringIndex) !== undefined ? strings[mapping.fileStringIndex] : '';
69
+ var mappingString = "".concat(mappingFile !== '' ? '[' + ((_c = getLastItem(mappingFile)) !== null && _c !== void 0 ? _c : '') + '] ' : '');
65
70
  if (location.lines.length > 0) {
66
- var funcName = strings[functions[location.lines[0].functionIndex].nameStringIndex];
71
+ var funcName = strings[functions[location.lines[node.meta.lineIndex].functionIndex - 1].nameStringIndex];
67
72
  return "".concat(mappingString, " ").concat(funcName);
68
73
  }
69
74
  var address = hexifyAddress(location.address);
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.62",
3
+ "version": "0.16.64",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@iconify/react": "^3.2.2",
7
- "@parca/client": "^0.16.53",
8
- "@parca/components": "^0.16.58",
7
+ "@parca/client": "^0.16.54",
8
+ "@parca/components": "^0.16.59",
9
9
  "@parca/dynamicsize": "^0.16.51",
10
10
  "@parca/functions": "^0.16.51",
11
11
  "@parca/parser": "^0.16.50",
@@ -40,5 +40,5 @@
40
40
  "access": "public",
41
41
  "registry": "https://registry.npmjs.org/"
42
42
  },
43
- "gitHead": "34f834e5c01e7dce7aa7cb1b09fe861d413ac0a3"
43
+ "gitHead": "38667cf5c5702dff21fdfeb5d9f1053be97a1f9d"
44
44
  }
@@ -180,7 +180,7 @@ const Callgraph = ({graph, sampleUnit, width, colorRange}: Props): JSX.Element =
180
180
  });
181
181
  const {nodes: rawNodes, cumulative: total} = graph;
182
182
  const currentSearchString = useAppSelector(selectSearchNodeString);
183
- const isSearchEmpty = currentSearchString === undefined;
183
+ const isSearchEmpty = currentSearchString === undefined || currentSearchString === '';
184
184
 
185
185
  useEffect(() => {
186
186
  const getDataWithPositions = async (): Promise<void> => {
@@ -233,29 +233,35 @@ const Callgraph = ({graph, sampleUnit, width, colorRange}: Props): JSX.Element =
233
233
 
234
234
  // 4. Add zooming
235
235
  const handleWheel: (e: KonvaEventObject<WheelEvent>) => void = e => {
236
+ // stop default scrolling
236
237
  e.evt.preventDefault();
237
238
 
238
- const scaleXBy = 0.95;
239
- const scaleYBy = 1.05;
239
+ const scaleBy = 1.01;
240
240
  const stage = e.target.getStage();
241
241
 
242
242
  if (stage !== null) {
243
243
  const oldScale = stage.scaleX();
244
- const {x, y} = stage.getPointerPosition() ?? {x: 0, y: 0};
244
+ const pointer = stage.getPointerPosition() ?? {x: 0, y: 0};
245
245
  const mousePointTo = {
246
- x: x / oldScale - stage.x() / oldScale,
247
- y: y / oldScale - stage.y() / oldScale,
246
+ x: pointer.x / oldScale - stage.x() / oldScale,
247
+ y: pointer.y / oldScale - stage.y() / oldScale,
248
248
  };
249
249
 
250
- const newXScale = e.evt.deltaX > 0 ? oldScale * scaleXBy : oldScale / scaleXBy;
251
- const newYScale = e.evt.deltaY > 0 ? oldScale * scaleYBy : oldScale / scaleYBy;
250
+ // whether to zoom in or out
251
+ let direction = e.evt.deltaY > 0 ? 1 : -1;
252
252
 
253
- stage.scale({x: newXScale, y: newYScale});
253
+ // for trackpad, e.evt.ctrlKey is true => in that case, revert direction
254
+ if (e.evt.ctrlKey) {
255
+ direction = -direction;
256
+ }
257
+
258
+ const newScale = direction > 0 ? oldScale * scaleBy : oldScale / scaleBy;
259
+ stage.scale({x: newScale, y: newScale});
254
260
 
255
261
  setStage({
256
- scale: {x: newXScale, y: newYScale},
257
- x: -(mousePointTo.x - x / newXScale) * newXScale,
258
- y: -(mousePointTo.y - y / newYScale) * newYScale,
262
+ scale: {x: newScale, y: newScale},
263
+ x: -(mousePointTo.x - pointer.x / newScale) * newScale,
264
+ y: -(mousePointTo.y - pointer.y / newScale) * newScale,
259
265
  });
260
266
  }
261
267
  };
@@ -19,12 +19,7 @@ import {CallgraphNode, FlamegraphNode, FlamegraphNodeMeta, FlamegraphRootNode} f
19
19
  import {getLastItem, valueFormatter} from '@parca/functions';
20
20
  import useIsShiftDown from '@parca/components/src/hooks/useIsShiftDown';
21
21
  import {hexifyAddress, truncateString} from '../';
22
- import {
23
- Function,
24
- Location,
25
- Mapping,
26
- Line,
27
- } from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
22
+ import {Function, Location, Mapping} from '@parca/client/dist/parca/metastore/v1alpha1/metastore';
28
23
 
29
24
  interface GraphTooltipProps {
30
25
  x: number;
@@ -86,22 +81,37 @@ const TooltipMetaInfo = ({
86
81
  if (hoveringNode.meta === undefined) return <></>;
87
82
 
88
83
  // populate meta from the flamegraph metadata tables
89
- if (locations !== undefined) {
90
- const location = locations[hoveringNode.meta.locationIndex];
84
+ if (
85
+ locations !== undefined &&
86
+ hoveringNode.meta.locationIndex !== undefined &&
87
+ hoveringNode.meta.locationIndex !== 0
88
+ ) {
89
+ const location = locations[hoveringNode.meta.locationIndex - 1];
91
90
  hoveringNode.meta.location = location;
92
91
 
93
- if (mappings !== undefined) {
94
- const mapping = mappings[location.mappingIndex];
95
- if (strings !== undefined) {
96
- mapping.file = strings[mapping.fileStringIndex];
97
- mapping.buildId = strings[mapping.buildIdStringIndex];
92
+ if (location !== undefined) {
93
+ if (
94
+ mappings !== undefined &&
95
+ location.mappingIndex !== undefined &&
96
+ location.mappingIndex !== 0
97
+ ) {
98
+ const mapping = mappings[location.mappingIndex - 1];
99
+ if (strings !== undefined && mapping !== undefined) {
100
+ mapping.file =
101
+ mapping?.fileStringIndex !== undefined ? strings[mapping.fileStringIndex] : '';
102
+ mapping.buildId =
103
+ mapping?.buildIdStringIndex !== undefined ? strings[mapping.buildIdStringIndex] : '';
104
+ }
105
+ hoveringNode.meta.mapping = mapping;
98
106
  }
99
- hoveringNode.meta.mapping = mapping;
100
- }
101
107
 
102
- location.lines.forEach((line: Line) => {
103
- if (functions !== undefined && hoveringNode.meta !== undefined) {
104
- const func = functions[line.functionIndex];
108
+ if (
109
+ functions !== undefined &&
110
+ location.lines !== undefined &&
111
+ hoveringNode.meta.lineIndex !== undefined &&
112
+ hoveringNode.meta.lineIndex < location.lines.length
113
+ ) {
114
+ const func = functions[location.lines[hoveringNode.meta.lineIndex].functionIndex - 1];
105
115
  if (strings !== undefined) {
106
116
  func.name = strings[func.nameStringIndex];
107
117
  func.systemName = strings[func.systemNameStringIndex];
@@ -109,7 +119,7 @@ const TooltipMetaInfo = ({
109
119
  }
110
120
  hoveringNode.meta.function = func;
111
121
  }
112
- });
122
+ }
113
123
  }
114
124
 
115
125
  const getTextForFile = (hoveringNode: FlamegraphNode): string => {
@@ -149,16 +149,24 @@ export function nodeLabel(
149
149
  functions: Function[]
150
150
  ): string {
151
151
  if (node.meta?.locationIndex === undefined) return '<unknown>';
152
+ if (node.meta?.locationIndex === 0) return '<unknown>';
152
153
 
153
- const location = locations[node.meta.locationIndex];
154
- const mappingFile = strings[mappings[location.mappingIndex].fileStringIndex];
154
+ const location = locations[node.meta.locationIndex - 1];
155
+ const mapping =
156
+ location.mappingIndex !== undefined || location.mappingIndex !== 0
157
+ ? mappings[location.mappingIndex - 1]
158
+ : undefined;
159
+
160
+ const mappingFile =
161
+ mapping?.fileStringIndex !== undefined ? strings[mapping.fileStringIndex] : '';
155
162
 
156
163
  const mappingString: string = `${
157
164
  mappingFile !== '' ? '[' + (getLastItem(mappingFile) ?? '') + '] ' : ''
158
165
  }`;
159
166
 
160
167
  if (location.lines.length > 0) {
161
- const funcName = strings[functions[location.lines[0].functionIndex].nameStringIndex];
168
+ const funcName =
169
+ strings[functions[location.lines[node.meta.lineIndex].functionIndex - 1].nameStringIndex];
162
170
  return `${mappingString} ${funcName}`;
163
171
  }
164
172