profiler-md 0.2.0 → 0.3.0

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.
@@ -0,0 +1,13 @@
1
+ # JSC heap snapshot
2
+
3
+ The
4
+ [JSC heap snapshot](https://webkit.org/blog/6425/memory-debugging-with-web-inspector)
5
+ is a JSON format produced by JavaScriptCore, the engine powering Safari and
6
+ WebKit, that captures the full live object graph at a point in time.
7
+
8
+ Unlike heap profiles, which sample allocations, snapshots show what objects
9
+ currently exist in memory. This is useful for diagnosing memory leaks rather
10
+ than allocation hotspots.
11
+
12
+ Files use the `.json` extension and contain `"type": "Inspector"` and
13
+ `"version": 2` fields.
@@ -0,0 +1,9 @@
1
+ # WebKit timeline recording
2
+
3
+ The [WebKit timeline recording](https://webkit.org/web-inspector/timelines-tab)
4
+ is a JSON format captured by Safari's Web Inspector. It combines a CPU profile
5
+ from sampling, a browser activity breakdown (layout, rendering, script
6
+ execution, network requests), and optionally in-use memory readings and heap
7
+ allocation snapshots when those instruments are enabled.
8
+
9
+ Files use the `.json` extension.
@@ -88,7 +88,7 @@ HeapProfilerStart("heap.prof");
88
88
 
89
89
  // Code to profile...
90
90
 
91
- HeapProfilerDump("checkpoint"); // optional mid-run snapshot
91
+ HeapProfilerDump("checkpoint"); // optional mid-run profile dump
92
92
  HeapProfilerStop();
93
93
  ```
94
94
 
@@ -41,7 +41,7 @@ defer pprof.StopCPUProfile()
41
41
  Heap profiles come in two variants:
42
42
 
43
43
  - **heap** (`inuse_space` / `inuse_objects`): live allocations at the time of
44
- the snapshot; useful for finding memory leaks
44
+ the time of each sample; useful for finding memory leaks
45
45
  - **allocs** (`alloc_space` / `alloc_objects`): all allocations since program
46
46
  start; useful for finding allocation hot spots
47
47
 
@@ -74,7 +74,7 @@ import (
74
74
  "runtime/pprof"
75
75
  )
76
76
 
77
- runtime.GC() // Flush pending samples before snapshotting
77
+ runtime.GC() // Flush pending samples before writing the profile
78
78
 
79
79
  // Live heap
80
80
  f, _ := os.Create("heap.pprof")
@@ -183,3 +183,37 @@ Stop when done to see allocation hot spots by call stack.
183
183
 
184
184
  Open the **Memory** panel, select **Heap snapshot**, and click **Take
185
185
  snapshot**.
186
+
187
+ ## Safari Web Inspector
188
+
189
+ Safari's Web Inspector records a timeline that combines CPU sampling, browser
190
+ activity, and optionally memory readings and heap allocations, all exported as a
191
+ single file.
192
+
193
+ ### Connecting
194
+
195
+ Open the Web Inspector with **Develop → Show Web Inspector** (or ⌥⌘I).
196
+
197
+ ### Recording
198
+
199
+ 1. Click the **Timelines** tab.
200
+ 2. Enable the instruments you want: **JavaScript & Events** (always), and
201
+ optionally **Memory** and **JavaScript Allocations**.
202
+ 3. Click **Start Recording** (or ⌘R).
203
+ 4. Reproduce the scenario you want to profile.
204
+ 5. Click **Stop Recording**.
205
+ 6. Click the **Export** button (arrow icon) and save as a `.json` file.
206
+
207
+ ### Heap snapshots
208
+
209
+ Open the **Memory** panel, select **Heap Snapshot**, and click **Take
210
+ Snapshot**.
211
+
212
+ #### Programmatic API
213
+
214
+ `console.takeHeapSnapshot()` is a non-standard WebKit extension that takes a
215
+ heap snapshot from JavaScript and adds it to the **Memory** panel:
216
+
217
+ ```js
218
+ console.takeHeapSnapshot()
219
+ ```
@@ -5,7 +5,7 @@ Took 2.44s over 15,182 samples (161.2µs per sample).
5
5
  | Category | % | Time | Samples |
6
6
  | ----------- | ----: | ------: | ------: |
7
7
  | ours | 73.0% | 1.78s | 11,143 |
8
- | native | 23.6% | 578.7ms | 3,551 |
8
+ | stdlib | 23.6% | 578.7ms | 3,551 |
9
9
  | third-party | 3.0% | 72.7ms | 425 |
10
10
  | module | 0.4% | 10.1ms | 62 |
11
11
  | unknown | 0.0% | 0.2ms | 1 |
@@ -34,10 +34,10 @@ Functions ranked by time spent directly in the function body, excluding callees.
34
34
  | 1.3% | 32.1ms | 200 | `uneval` | uneval/src/index.ts:75:16 |
35
35
  | 1.2% | 28.3ms | 178 | `unevalBoolean` | uneval/src/internal/primitive.ts:8:30 |
36
36
  | 0.5% | 13.0ms | 80 | `push` | `<native>` |
37
- | 0.4% | 11.0ms | 7 | `(anonymous)` | `<native>` |
38
37
  | 0.3% | 8.2ms | 46 | `map` | `<native>` |
39
- | 0.3% | 7.5ms | 38 | `parseModule` | `<native>` |
40
38
  | 0.3% | 7.3ms | 47 | `unevalInternal` | uneval/src/internal/index.ts:25:32 |
39
+ | 0.2% | 5.5ms | 35 | `unevalObjectInternal` | uneval/src/internal/object.ts:68:30 |
40
+ | 0.2% | 4.1ms | 26 | `unevalObjectAssign` | uneval/src/internal/collection.ts:89:28 |
41
41
 
42
42
  #### Lines
43
43
 
@@ -151,12 +151,6 @@ Lines ranked by contribution to each function's self time.
151
151
  | -----: | -----: | ------: | ----------------------------------- |
152
152
  | 100.0% | 28.3ms | 178 | uneval/src/internal/primitive.ts:10 |
153
153
 
154
- ##### `(anonymous)` (`<native>`)
155
-
156
- | % | Time | Samples | Location |
157
- | ----: | -----: | ------: | -------- |
158
- | 96.2% | 10.5ms | 4 | 11 |
159
-
160
154
  ##### `map` (`<native>`)
161
155
 
162
156
  | % | Time | Samples | Location |
@@ -173,6 +167,19 @@ Lines ranked by contribution to each function's self time.
173
167
  | 2.2% | 0.2ms | 1 | uneval/src/internal/index.ts:54 |
174
168
  | 2.1% | 0.2ms | 1 | uneval/src/internal/index.ts:44 |
175
169
 
170
+ ##### `unevalObjectInternal` (uneval/src/internal/object.ts:68:30)
171
+
172
+ | % | Time | Samples | Location |
173
+ | ----: | ----: | ------: | -------------------------------- |
174
+ | 82.9% | 4.5ms | 29 | uneval/src/internal/object.ts:69 |
175
+ | 17.1% | 0.9ms | 6 | uneval/src/internal/object.ts:78 |
176
+
177
+ ##### `unevalObjectAssign` (uneval/src/internal/collection.ts:89:28)
178
+
179
+ | % | Time | Samples | Location |
180
+ | -----: | ----: | ------: | ------------------------------------ |
181
+ | 100.0% | 4.1ms | 26 | uneval/src/internal/collection.ts:89 |
182
+
176
183
  #### Callers
177
184
 
178
185
  Callers ranked by contribution to each function's self time. Caller attribution may be imprecise due to inlining.
@@ -185,11 +192,10 @@ Callers ranked by contribution to each function's self time. Caller attribution
185
192
 
186
193
  ##### `join` (`<native>`)
187
194
 
188
- | % | Time | Samples | Caller | Location |
189
- | ----: | ------: | ------: | ------------------------- | ------------------------------------------------------------------------------------------- |
190
- | 61.8% | 173.9ms | 1,091 | `unevalObjectLike` | uneval/src/internal/object.ts:103:26 |
191
- | 37.6% | 105.9ms | 668 | `unevalArray` | uneval/src/internal/collection.ts:7:47 |
192
- | 0.5% | 1.5ms | 9 | `mapperWithCloneIfNeeded` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:468:25 |
195
+ | % | Time | Samples | Caller | Location |
196
+ | ----: | ------: | ------: | ------------------ | -------------------------------------- |
197
+ | 61.8% | 173.9ms | 1,091 | `unevalObjectLike` | uneval/src/internal/object.ts:103:26 |
198
+ | 37.6% | 105.9ms | 668 | `unevalArray` | uneval/src/internal/collection.ts:7:47 |
193
199
 
194
200
  ##### `traverseObject` (uneval/src/index.ts:204:26)
195
201
 
@@ -275,19 +281,11 @@ Callers ranked by contribution to each function's self time. Caller attribution
275
281
 
276
282
  ##### `push` (`<native>`)
277
283
 
278
- | % | Time | Samples | Caller | Location |
279
- | ----: | ----: | ------: | ---------------- | -------------------------------------------------------------------------------------------- |
280
- | 45.3% | 5.9ms | 36 | `unevalArray` | uneval/src/internal/collection.ts:7:47 |
281
- | 28.8% | 3.7ms | 23 | `wrapper` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:3113:9 |
282
- | 11.2% | 1.5ms | 9 | `generateNItems` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:3097:16 |
283
- | 10.8% | 1.4ms | 9 | `tupleWrapper` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:1023:22 |
284
- | 2.6% | 0.3ms | 2 | `traverseObject` | uneval/src/index.ts:204:26 |
285
-
286
- ##### `(anonymous)` (`<native>`)
287
-
288
- | % | Time | Samples | Caller | Location |
289
- | ---: | ----: | ------: | ------------- | ---------- |
290
- | 6.2% | 0.7ms | 5 | `(anonymous)` | `<native>` |
284
+ | % | Time | Samples | Caller | Location |
285
+ | ----: | ----: | ------: | ------------------ | -------------------------------------- |
286
+ | 45.3% | 5.9ms | 36 | `unevalArray` | uneval/src/internal/collection.ts:7:47 |
287
+ | 2.6% | 0.3ms | 2 | `traverseObject` | uneval/src/index.ts:204:26 |
288
+ | 1.3% | 0.2ms | 1 | `unevalObjectLike` | uneval/src/internal/object.ts:103:26 |
291
289
 
292
290
  ##### `map` (`<native>`)
293
291
 
@@ -295,12 +293,6 @@ Callers ranked by contribution to each function's self time. Caller attribution
295
293
  | -----: | ----: | ------: | ------------------ | ------------------------------------ |
296
294
  | 100.0% | 8.2ms | 46 | `unevalObjectLike` | uneval/src/internal/object.ts:103:26 |
297
295
 
298
- ##### `parseModule` (`<native>`)
299
-
300
- | % | Time | Samples | Caller | Location |
301
- | -----: | ----: | ------: | ------------- | ---------- |
302
- | 100.0% | 7.5ms | 38 | `(anonymous)` | `<native>` |
303
-
304
296
  ##### `unevalInternal` (uneval/src/internal/index.ts:25:32)
305
297
 
306
298
  | % | Time | Samples | Caller | Location |
@@ -310,51 +302,49 @@ Callers ranked by contribution to each function's self time. Caller attribution
310
302
  | 4.4% | 0.3ms | 2 | `unevalObjectLiteralKey` | uneval/src/internal/object.ts:384:32 |
311
303
  | 2.2% | 0.2ms | 1 | `uneval` | uneval/src/index.ts:75:16 |
312
304
 
313
- ### Total time
305
+ ##### `unevalObjectInternal` (uneval/src/internal/object.ts:68:30)
314
306
 
315
- Functions ranked by total time spent in the function and all its callees.
307
+ | % | Time | Samples | Caller | Location |
308
+ | ----: | ----: | ------: | -------------- | -------------------------------------- |
309
+ | 96.7% | 5.3ms | 34 | `unevalObject` | uneval/src/internal/object.ts:20:29 |
310
+ | 3.3% | 0.2ms | 1 | `unevalArray` | uneval/src/internal/collection.ts:7:47 |
316
311
 
317
- | % | Time | Samples | Function | Location |
318
- | ----: | ------: | ------: | -------------------------- | -------------------------------------------------------------------------------------------- |
319
- | 98.9% | 2.42s | 15,097 | `loadAndEvaluateModule` | `<native>` |
320
- | 98.7% | 2.41s | 15,063 | `moduleEvaluation` | `<native>` |
321
- | 98.7% | 2.41s | 15,062 | `evaluate` | `<native>` |
322
- | 94.7% | 2.31s | 14,473 | `uneval` | uneval/src/index.ts:75:16 |
323
- | 52.5% | 1.28s | 8,030 | `unevalObjectLike` | uneval/src/internal/object.ts:103:26 |
324
- | 41.2% | 1s | 6,318 | `unevalInternal` | uneval/src/internal/index.ts:25:32 |
325
- | 33.1% | 809.8ms | 5,072 | `unevalArray` | uneval/src/internal/collection.ts:7:47 |
326
- | 30.0% | 734.8ms | 4,609 | `unevalString` | uneval/src/internal/primitive.ts:133:29 |
327
- | 28.7% | 701.7ms | 4,405 | `unevalLiteral` | uneval/src/internal/primitive.ts:139:23 |
328
- | 26.9% | 658.3ms | 4,095 | `createState` | uneval/src/index.ts:144:21 |
329
- | 25.6% | 625.9ms | 3,912 | `traverse` | uneval/src/index.ts:164:20 |
330
- | 25.5% | 623.7ms | 3,908 | `unevalObjectLiteralKey` | uneval/src/internal/object.ts:384:32 |
331
- | 23.8% | 582.9ms | 3,650 | `traverseObject` | uneval/src/index.ts:204:26 |
332
- | 11.5% | 281.3ms | 1,768 | `join` | `<native>` |
333
- | 9.5% | 232.9ms | 1,454 | `unevalNumber` | uneval/src/internal/primitive.ts:12:29 |
334
- | 7.2% | 176.8ms | 1,111 | `getOwnPropertyDescriptor` | `<native>` |
335
- | 4.5% | 110.1ms | 694 | `getType` | uneval/src/internal/type.ts:4:24 |
336
- | 3.5% | 84.5ms | 496 | `sample` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:2551:16 |
337
- | 3.4% | 84.2ms | 494 | `performIteration` | `<native>` |
338
- | 3.4% | 84.1ms | 493 | `mapHelper` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:58:27 |
312
+ ##### `unevalObjectAssign` (uneval/src/internal/collection.ts:89:28)
339
313
 
340
- #### Callees
314
+ | % | Time | Samples | Caller | Location |
315
+ | -----: | ----: | ------: | ------------- | -------------------------------------- |
316
+ | 100.0% | 4.1ms | 26 | `unevalArray` | uneval/src/internal/collection.ts:7:47 |
341
317
 
342
- Callees ranked by contribution to each function's total time. Callee attribution may be imprecise due to inlining.
318
+ ### Total time
343
319
 
344
- ##### `loadAndEvaluateModule` (`<native>`)
320
+ Functions ranked by total time spent in the function and all its callees.
345
321
 
346
- | % | Time | Samples | Callee | Location |
347
- | ----: | ----: | ------: | ----------------------- | ---------- |
348
- | 99.8% | 2.41s | 15,063 | `moduleEvaluation` | `<native>` |
349
- | 0.1% | 3.0ms | 22 | `linkAndEvaluateModule` | `<native>` |
350
- | 0.1% | 1.3ms | 9 | `loadModule` | `<native>` |
322
+ | % | Time | Samples | Function | Location |
323
+ | ----: | ------: | ------: | ------------------------------------------- | --------------------------------------- |
324
+ | 94.7% | 2.31s | 14,473 | `uneval` | uneval/src/index.ts:75:16 |
325
+ | 52.5% | 1.28s | 8,030 | `unevalObjectLike` | uneval/src/internal/object.ts:103:26 |
326
+ | 41.2% | 1s | 6,318 | `unevalInternal` | uneval/src/internal/index.ts:25:32 |
327
+ | 33.1% | 809.8ms | 5,072 | `unevalArray` | uneval/src/internal/collection.ts:7:47 |
328
+ | 30.0% | 734.8ms | 4,609 | `unevalString` | uneval/src/internal/primitive.ts:133:29 |
329
+ | 28.7% | 701.7ms | 4,405 | `unevalLiteral` | uneval/src/internal/primitive.ts:139:23 |
330
+ | 26.9% | 658.3ms | 4,095 | `createState` | uneval/src/index.ts:144:21 |
331
+ | 25.6% | 625.9ms | 3,912 | `traverse` | uneval/src/index.ts:164:20 |
332
+ | 25.5% | 623.7ms | 3,908 | `unevalObjectLiteralKey` | uneval/src/internal/object.ts:384:32 |
333
+ | 23.8% | 582.9ms | 3,650 | `traverseObject` | uneval/src/index.ts:204:26 |
334
+ | 11.5% | 281.3ms | 1,768 | `join` | `<native>` |
335
+ | 9.5% | 232.9ms | 1,454 | `unevalNumber` | uneval/src/internal/primitive.ts:12:29 |
336
+ | 7.2% | 176.8ms | 1,111 | `getOwnPropertyDescriptor` | `<native>` |
337
+ | 4.5% | 110.1ms | 694 | `getType` | uneval/src/internal/type.ts:4:24 |
338
+ | 2.2% | 54.8ms | 341 | `/^[$_\p{ID_Start}][$_\p{ID_Continue}]*$/u` | `<native>` |
339
+ | 1.2% | 28.3ms | 178 | `unevalBoolean` | uneval/src/internal/primitive.ts:8:30 |
340
+ | 0.5% | 13.0ms | 80 | `push` | `<native>` |
341
+ | 0.4% | 8.6ms | 55 | `unevalObject` | uneval/src/internal/object.ts:20:29 |
342
+ | 0.3% | 8.2ms | 46 | `map` | `<native>` |
343
+ | 0.2% | 5.5ms | 35 | `unevalObjectInternal` | uneval/src/internal/object.ts:68:30 |
351
344
 
352
- ##### `moduleEvaluation` (`<native>`)
345
+ #### Callees
353
346
 
354
- | % | Time | Samples | Callee | Location |
355
- | -----: | ----: | ------: | ------------------ | ---------- |
356
- | 100.0% | 2.41s | 15,062 | `evaluate` | `<native>` |
357
- | 100.0% | 2.41s | 15,061 | `moduleEvaluation` | `<native>` |
347
+ Callees ranked by contribution to each function's total time. Callee attribution may be imprecise due to inlining.
358
348
 
359
349
  ##### `uneval` (uneval/src/index.ts:75:16)
360
350
 
@@ -448,30 +438,18 @@ Callees ranked by contribution to each function's total time. Callee attribution
448
438
  | ---: | ----: | ------: | ---------- | ---------- |
449
439
  | 0.4% | 0.5ms | 3 | `toString` | `<native>` |
450
440
 
451
- ##### `sample` (uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:2551:16)
452
-
453
- | % | Time | Samples | Callee | Location |
454
- | ----: | -----: | ------: | ------------------ | -------------------------------------------------------------------------------------------- |
455
- | 99.7% | 84.2ms | 494 | `performIteration` | `<native>` |
456
- | 0.3% | 0.3ms | 2 | `streamSample` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:2524:22 |
457
-
458
- ##### `performIteration` (`<native>`)
459
-
460
- | % | Time | Samples | Callee | Location |
461
- | ----: | -----: | ------: | ----------------- | ---------- |
462
- | 99.8% | 84.1ms | 493 | `generatorResume` | `<native>` |
463
-
464
- ##### `mapHelper` (uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:58:27)
441
+ ##### `unevalObject` (uneval/src/internal/object.ts:20:29)
465
442
 
466
- | % | Time | Samples | Callee | Location |
467
- | ----: | -----: | ------: | ----------------- | ---------- |
468
- | 99.8% | 83.9ms | 492 | `generatorResume` | `<native>` |
443
+ | % | Time | Samples | Callee | Location |
444
+ | ----: | ----: | ------: | ---------------------- | ----------------------------------- |
445
+ | 61.6% | 5.3ms | 34 | `unevalObjectInternal` | uneval/src/internal/object.ts:68:30 |
446
+ | 2.0% | 0.2ms | 1 | `get` | `<native>` |
469
447
 
470
448
  ## Hottest call stacks
471
449
 
472
- Call stacks ranked by time spent in their top frame.
450
+ Call stacks ranked by time spent in their leaf frame.
473
451
 
474
- Common call stack: `uneval` (uneval/src/index.ts:75:16) ← `evaluate` ← `moduleEvaluation` ← `moduleEvaluation` ← `loadAndEvaluateModule`
452
+ Common call stack: `uneval` (uneval/src/index.ts:75:16)
475
453
 
476
454
  | % | Time | Samples | Call stack |
477
455
  | ---: | ------: | ------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -10,7 +10,7 @@ Took 6.08s over 46,255 samples (131.6µs per sample).
10
10
  | program | 1.7% | 106.1ms | 817 |
11
11
  | third-party | 1.2% | 71.1ms | 536 |
12
12
  | idle | 0.8% | 50.1ms | 38 |
13
- | native | 0.0% | 0.1ms | 1 |
13
+ | stdlib | 0.0% | 0.1ms | 1 |
14
14
 
15
15
  ## Hottest functions
16
16
 
@@ -451,16 +451,9 @@ Callees ranked by contribution to each function's total time. Callee attribution
451
451
  | ----: | ------: | ------: | --------------- | --------------------------------------- |
452
452
  | 92.9% | 529.6ms | 4,061 | `unevalLiteral` | uneval/src/internal/primitive.ts:139:23 |
453
453
 
454
- ##### `sample` (uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:2551:16)
455
-
456
- | % | Time | Samples | Callee | Location |
457
- | ----: | -----: | ------: | -------------- | -------------------------------------------------------------------------------------------- |
458
- | 97.5% | 66.7ms | 502 | `mapHelper` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:58:20 |
459
- | 0.4% | 0.3ms | 2 | `streamSample` | uneval/node_modules/.pnpm/fast-check@4.6.0/node_modules/fast-check/lib/fast-check.js:2524:22 |
460
-
461
454
  ## Hottest call stacks
462
455
 
463
- Call stacks ranked by time spent in their top frame.
456
+ Call stacks ranked by time spent in their leaf frame.
464
457
 
465
458
  Common call stack: `uneval` (uneval/src/index.ts:75:16) ← `(anonymous)` (uneval/scripts/profile.ts:1:1)
466
459