@reicek/neataptic-ts 0.1.25 → 0.1.26
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/.github/copilot-instructions.md +11 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
- package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
- package/package.json +19 -13
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
- package/plans/README.md +24 -0
- package/plans/Roadmap.md +62 -40
- package/plans/analyze-trace-solid-split.plans.md +66 -0
- package/plans/architecture-solid-split.plans.md +9 -15
- package/plans/asciiMaze-typescript-repair.plans.md +1 -1
- package/plans/generate-docs-solid-split.plans.md +87 -0
- package/plans/methods-docs.plans.md +25 -1
- package/plans/methods-solid-split.plans.md +14 -14
- package/plans/neat-docs.plans.md +9 -1
- package/plans/neat-test-surface-repair.plans.md +1 -1
- package/plans/render-docs-html-solid-split.plans.md +68 -0
- package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
- package/plans/utils-docs.plans.md +6 -1
- package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
- package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
- package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
- package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
- package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
- package/scripts/analyze-trace/analyze-trace.ts +45 -0
- package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
- package/scripts/assets/theme.css +80 -23
- package/scripts/copy-examples.ts +239 -0
- package/scripts/export-onnx.ts +223 -0
- package/scripts/generate-bench-tables.ts +378 -37
- package/scripts/generate-docs/generate-docs.constants.ts +107 -0
- package/scripts/generate-docs/generate-docs.order.ts +355 -0
- package/scripts/generate-docs/generate-docs.state.ts +31 -0
- package/scripts/generate-docs/generate-docs.targets.ts +165 -0
- package/scripts/generate-docs/generate-docs.ts +63 -0
- package/scripts/generate-docs/generate-docs.types.ts +112 -0
- package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
- package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
- package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
- package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
- package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
- package/scripts/mermaid-cli.mjs +102 -22
- package/scripts/mermaid-cli.ts +736 -0
- package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
- package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
- package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
- package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
- package/scripts/render-docs-html.ts +23 -587
- package/scripts/run-docs.ts +238 -0
- package/scripts/write-dist-docs-pkg.ts +40 -0
- package/src/README.md +75 -75
- package/src/architecture/connection/README.md +5 -5
- package/src/architecture/layer/README.md +508 -508
- package/src/architecture/network/README.md +1458 -1458
- package/src/architecture/network/activate/README.md +694 -694
- package/src/architecture/network/bootstrap/README.md +77 -77
- package/src/architecture/network/connect/README.md +74 -74
- package/src/architecture/network/deterministic/README.md +135 -135
- package/src/architecture/network/evolve/README.md +364 -364
- package/src/architecture/network/gating/README.md +130 -130
- package/src/architecture/network/genetic/README.md +399 -399
- package/src/architecture/network/mutate/README.md +897 -897
- package/src/architecture/network/onnx/README.md +720 -720
- package/src/architecture/network/onnx/export/README.md +728 -728
- package/src/architecture/network/onnx/export/layers/README.md +450 -450
- package/src/architecture/network/onnx/import/README.md +618 -618
- package/src/architecture/network/onnx/schema/README.md +32 -32
- package/src/architecture/network/prune/README.md +245 -245
- package/src/architecture/network/remove/README.md +135 -135
- package/src/architecture/network/runtime/README.md +106 -106
- package/src/architecture/network/serialize/README.md +542 -542
- package/src/architecture/network/slab/README.md +608 -608
- package/src/architecture/network/standalone/README.md +212 -212
- package/src/architecture/network/stats/README.md +84 -84
- package/src/architecture/network/topology/README.md +465 -465
- package/src/architecture/network/training/README.md +200 -200
- package/src/architecture/node/README.md +5 -5
- package/src/architecture/nodePool/README.md +14 -14
- package/src/methods/README.md +99 -99
- package/src/methods/activation/README.md +189 -189
- package/src/methods/cost/README.md +131 -131
- package/src/methods/rate/README.md +86 -86
- package/src/multithreading/README.md +77 -77
- package/src/multithreading/workers/browser/README.md +8 -8
- package/src/multithreading/workers/node/README.md +8 -8
- package/src/neat/README.md +148 -148
- package/src/neat/adaptive/README.md +120 -120
- package/src/neat/adaptive/acceptance/README.md +40 -40
- package/src/neat/adaptive/complexity/README.md +137 -137
- package/src/neat/adaptive/core/README.md +197 -197
- package/src/neat/adaptive/lineage/README.md +90 -90
- package/src/neat/adaptive/mutation/README.md +284 -284
- package/src/neat/compat/README.md +43 -43
- package/src/neat/compat/core/README.md +90 -90
- package/src/neat/diversity/README.md +35 -35
- package/src/neat/diversity/core/README.md +88 -88
- package/src/neat/evaluate/README.md +85 -85
- package/src/neat/evaluate/auto-distance/README.md +75 -75
- package/src/neat/evaluate/entropy-compat/README.md +37 -37
- package/src/neat/evaluate/entropy-sharing/README.md +43 -43
- package/src/neat/evaluate/fitness/README.md +23 -23
- package/src/neat/evaluate/novelty/README.md +120 -120
- package/src/neat/evaluate/objectives/README.md +17 -17
- package/src/neat/evaluate/shared/README.md +94 -94
- package/src/neat/evolve/README.md +96 -96
- package/src/neat/evolve/adaptive/README.md +60 -60
- package/src/neat/evolve/objectives/README.md +63 -63
- package/src/neat/evolve/offspring/README.md +56 -56
- package/src/neat/evolve/population/README.md +171 -171
- package/src/neat/evolve/runtime/README.md +79 -79
- package/src/neat/evolve/speciation/README.md +74 -74
- package/src/neat/evolve/warnings/README.md +10 -10
- package/src/neat/export/README.md +114 -114
- package/src/neat/helpers/README.md +50 -50
- package/src/neat/init/README.md +9 -9
- package/src/neat/lineage/core/README.md +101 -101
- package/src/neat/multiobjective/category/README.md +74 -74
- package/src/neat/multiobjective/crowding/README.md +272 -272
- package/src/neat/multiobjective/dominance/README.md +171 -171
- package/src/neat/multiobjective/fronts/README.md +68 -68
- package/src/neat/multiobjective/metrics/README.md +43 -43
- package/src/neat/multiobjective/objectives/README.md +31 -31
- package/src/neat/multiobjective/shared/README.md +27 -27
- package/src/neat/mutation/README.md +97 -97
- package/src/neat/mutation/add-conn/README.md +115 -115
- package/src/neat/mutation/add-node/README.md +126 -126
- package/src/neat/mutation/flow/README.md +149 -149
- package/src/neat/mutation/repair/README.md +185 -185
- package/src/neat/mutation/select/README.md +117 -117
- package/src/neat/mutation/shared/README.md +32 -32
- package/src/neat/objectives/README.md +25 -25
- package/src/neat/objectives/core/README.md +67 -67
- package/src/neat/pruning/README.md +40 -40
- package/src/neat/pruning/core/README.md +171 -171
- package/src/neat/pruning/facade/README.md +32 -32
- package/src/neat/rng/README.md +104 -104
- package/src/neat/rng/core/README.md +137 -137
- package/src/neat/rng/facade/README.md +50 -50
- package/src/neat/selection/README.md +111 -111
- package/src/neat/selection/core/README.md +227 -227
- package/src/neat/selection/facade/README.md +61 -61
- package/src/neat/shared/README.md +163 -163
- package/src/neat/speciation/README.md +31 -31
- package/src/neat/speciation/threshold/README.md +35 -35
- package/src/neat/species/README.md +25 -25
- package/src/neat/species/core/README.md +20 -20
- package/src/neat/species/core/shared/README.md +18 -18
- package/src/neat/species/history/context/README.md +22 -22
- package/src/neat/telemetry/accessors/README.md +58 -58
- package/src/neat/telemetry/exports/README.md +233 -233
- package/src/neat/telemetry/facade/README.md +252 -252
- package/src/neat/telemetry/facade/archive/README.md +57 -57
- package/src/neat/telemetry/facade/buffer/README.md +43 -43
- package/src/neat/telemetry/facade/lineage/README.md +12 -12
- package/src/neat/telemetry/facade/objectives/README.md +44 -44
- package/src/neat/telemetry/facade/runtime/README.md +26 -26
- package/src/neat/telemetry/facade/species/README.md +27 -27
- package/src/neat/telemetry/metrics/README.md +696 -696
- package/src/neat/telemetry/recorder/README.md +57 -57
- package/src/neat/telemetry/types/README.md +32 -32
- package/src/neat/topology-intent/README.md +75 -75
- package/src/utils/README.md +193 -193
- package/test/examples/asciiMaze/browser-entry/README.md +92 -92
- package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
- package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
- package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
- package/test/examples/flappy_bird/browser-entry/README.md +508 -508
- package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
- package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
- package/test/examples/flappy_bird/constants/README.md +1070 -1070
- package/test/examples/flappy_bird/environment/README.md +22 -22
- package/test/examples/flappy_bird/evaluation/README.md +32 -32
- package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
- package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
- package/test/examples/flappy_bird/trainer/README.md +325 -325
- package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
- package/scripts/analyze-trace.ts +0 -590
- package/scripts/copy-examples.mjs +0 -114
- package/scripts/export-onnx.mjs +0 -86
- package/scripts/generate-bench-tables.mjs +0 -182
- package/scripts/generate-docs.ts +0 -2900
- package/scripts/write-dist-docs-pkg.mjs +0 -16
package/src/utils/README.md
CHANGED
|
@@ -44,38 +44,6 @@ flowchart TD
|
|
|
44
44
|
|
|
45
45
|
## utils/memory.ts
|
|
46
46
|
|
|
47
|
-
### MemoryStats
|
|
48
|
-
|
|
49
|
-
Detailed statistics describing the current estimated memory footprint of
|
|
50
|
-
tracked networks plus supporting pools.
|
|
51
|
-
|
|
52
|
-
Important: All byte counts here are *estimates*. JavaScript engine object
|
|
53
|
-
overhead varies; once slab (Structure of Arrays) storage dominates, these
|
|
54
|
-
estimates get closer to real usage. Treat values as relative metrics for
|
|
55
|
-
comparing configurations (e.g. before / after enabling pooling) rather than
|
|
56
|
-
exact allocations.
|
|
57
|
-
|
|
58
|
-
The payload is easiest to read as four cooperating layers:
|
|
59
|
-
|
|
60
|
-
- `connections`, `nodes`, and `estimatedTotalBytes` summarize the tracked
|
|
61
|
-
network footprint itself,
|
|
62
|
-
- `slabs` explains how much typed-array storage exists and how much of the
|
|
63
|
-
reserved connection capacity is currently used,
|
|
64
|
-
- `pools` shows whether reusable allocation infrastructure is active,
|
|
65
|
-
- `env` exposes the coarser browser or Node memory readings that surround the
|
|
66
|
-
heuristic network view.
|
|
67
|
-
|
|
68
|
-
### NetworkView
|
|
69
|
-
|
|
70
|
-
Minimal view of a network used for memory heuristics. Only properties
|
|
71
|
-
accessed by this module are declared. This keeps coupling light while
|
|
72
|
-
enabling typed local variables instead of loose catch-all types everywhere.
|
|
73
|
-
|
|
74
|
-
### SlabAllocStats
|
|
75
|
-
|
|
76
|
-
Minimal slab allocator stats shape used here. The real shape may
|
|
77
|
-
include additional fields; we only rely on fresh/pooled counts.
|
|
78
|
-
|
|
79
47
|
### memoryStats
|
|
80
48
|
|
|
81
49
|
```ts
|
|
@@ -109,20 +77,32 @@ const snapshot = memoryStats();
|
|
|
109
77
|
console.log(snapshot.estimatedTotalBytes, snapshot.slabs.fragmentationPct);
|
|
110
78
|
```
|
|
111
79
|
|
|
112
|
-
###
|
|
80
|
+
### MemoryStats
|
|
113
81
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
```
|
|
82
|
+
Detailed statistics describing the current estimated memory footprint of
|
|
83
|
+
tracked networks plus supporting pools.
|
|
117
84
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
85
|
+
Important: All byte counts here are *estimates*. JavaScript engine object
|
|
86
|
+
overhead varies; once slab (Structure of Arrays) storage dominates, these
|
|
87
|
+
estimates get closer to real usage. Treat values as relative metrics for
|
|
88
|
+
comparing configurations (e.g. before / after enabling pooling) rather than
|
|
89
|
+
exact allocations.
|
|
121
90
|
|
|
122
|
-
|
|
123
|
-
boundary before capturing the next snapshot.
|
|
91
|
+
The payload is easiest to read as four cooperating layers:
|
|
124
92
|
|
|
125
|
-
|
|
93
|
+
- `connections`, `nodes`, and `estimatedTotalBytes` summarize the tracked
|
|
94
|
+
network footprint itself,
|
|
95
|
+
- `slabs` explains how much typed-array storage exists and how much of the
|
|
96
|
+
reserved connection capacity is currently used,
|
|
97
|
+
- `pools` shows whether reusable allocation infrastructure is active,
|
|
98
|
+
- `env` exposes the coarser browser or Node memory readings that surround the
|
|
99
|
+
heuristic network view.
|
|
100
|
+
|
|
101
|
+
### NetworkView
|
|
102
|
+
|
|
103
|
+
Minimal view of a network used for memory heuristics. Only properties
|
|
104
|
+
accessed by this module are declared. This keeps coupling light while
|
|
105
|
+
enabling typed local variables instead of loose catch-all types everywhere.
|
|
126
106
|
|
|
127
107
|
### registerTrackedNetwork
|
|
128
108
|
|
|
@@ -146,6 +126,26 @@ Parameters:
|
|
|
146
126
|
|
|
147
127
|
Returns: void
|
|
148
128
|
|
|
129
|
+
### resetMemoryTracking
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
resetMemoryTracking(): void
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Clear the internal list of networks tracked by `memoryStats()` when no
|
|
136
|
+
explicit networks are provided. This does NOT free memory; it only
|
|
137
|
+
removes references held by the registry.
|
|
138
|
+
|
|
139
|
+
Use this when a teaching example, benchmark, or test wants a fresh registry
|
|
140
|
+
boundary before capturing the next snapshot.
|
|
141
|
+
|
|
142
|
+
Returns: void
|
|
143
|
+
|
|
144
|
+
### SlabAllocStats
|
|
145
|
+
|
|
146
|
+
Minimal slab allocator stats shape used here. The real shape may
|
|
147
|
+
include additional fields; we only rely on fresh/pooled counts.
|
|
148
|
+
|
|
149
149
|
### unregisterTrackedNetwork
|
|
150
150
|
|
|
151
151
|
```ts
|
|
@@ -197,44 +197,44 @@ flowchart LR
|
|
|
197
197
|
Build --> Payload[MemoryStats]
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
-
###
|
|
200
|
+
### accumulateCapacitySlices
|
|
201
201
|
|
|
202
202
|
```ts
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
accumulateCapacitySlices(
|
|
204
|
+
accumulators: Accumulators,
|
|
205
|
+
network: NetworkView,
|
|
206
|
+
heuristics: HeuristicBytes,
|
|
207
|
+
): void
|
|
207
208
|
```
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
This helper keeps the public entrypoint flexible without making later
|
|
212
|
-
aggregation code branch on every call path.
|
|
210
|
+
Track reserved vs used bytes based on connection capacity slices.
|
|
213
211
|
|
|
214
212
|
Parameters:
|
|
215
|
-
- `
|
|
216
|
-
- `
|
|
217
|
-
|
|
218
|
-
Returns: Array of networks to summarize.
|
|
213
|
+
- `accumulators` - Running totals for the memory snapshot.
|
|
214
|
+
- `network` - Network exposing capacity metadata.
|
|
215
|
+
- `heuristics` - Fallback byte weights for connection objects.
|
|
219
216
|
|
|
220
|
-
###
|
|
217
|
+
### accumulateSlabArrays
|
|
221
218
|
|
|
222
219
|
```ts
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
220
|
+
accumulateSlabArrays(
|
|
221
|
+
accumulators: Accumulators,
|
|
222
|
+
typedArrays: (Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int32Array<ArrayBufferLike>)[],
|
|
223
|
+
): void
|
|
226
224
|
```
|
|
227
225
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
Allocator telemetry is useful but optional. A failed probe should degrade the
|
|
231
|
-
snapshot gracefully instead of turning diagnostics into a source of runtime
|
|
232
|
-
failures.
|
|
226
|
+
Sum slab-backed array counts and byte sizes into the accumulator.
|
|
233
227
|
|
|
234
228
|
Parameters:
|
|
235
|
-
- `
|
|
229
|
+
- `accumulators` - Running totals for the memory snapshot.
|
|
230
|
+
- `typedArrays` - Connection-parallel arrays to measure.
|
|
236
231
|
|
|
237
|
-
|
|
232
|
+
### Accumulators
|
|
233
|
+
|
|
234
|
+
Running totals used while walking networks to summarize memory consumption.
|
|
235
|
+
Accumulates counts, slab byte totals, and reserved vs used capacity
|
|
236
|
+
snapshots. This is the file's working ledger before the public-facing
|
|
237
|
+
`MemoryStats` object is assembled.
|
|
238
238
|
|
|
239
239
|
### aggregateNetworkStats
|
|
240
240
|
|
|
@@ -258,20 +258,33 @@ Parameters:
|
|
|
258
258
|
|
|
259
259
|
Returns: Accumulated summary of network metrics.
|
|
260
260
|
|
|
261
|
-
###
|
|
261
|
+
### buildFlagSnapshot
|
|
262
262
|
|
|
263
263
|
```ts
|
|
264
|
-
|
|
264
|
+
buildFlagSnapshot(
|
|
265
|
+
configSnapshot: ConfigSnapshot,
|
|
266
|
+
allocationStats: SlabAllocStats,
|
|
267
|
+
): { warnings: unknown; float32Mode: unknown; deterministicChainMode: unknown; enableGatingTraces: unknown; poolMaxPerBucket: number | null; poolPrewarmCount: number | null; enableNodePooling: boolean; allocStats: unknown; }
|
|
265
268
|
```
|
|
266
269
|
|
|
267
|
-
|
|
270
|
+
Build flag snapshot derived from config and allocator stats.
|
|
268
271
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
summary.
|
|
272
|
+
Flag snapshots explain *why* the memory picture may look the way it does by
|
|
273
|
+
capturing the small set of runtime options that materially alter pooling,
|
|
274
|
+
slab layout, and feature-gated storage paths.
|
|
273
275
|
|
|
274
|
-
|
|
276
|
+
Parameters:
|
|
277
|
+
- `configSnapshot` - Relevant configuration values.
|
|
278
|
+
- `allocationStats` - Allocator stats (nullable on failure).
|
|
279
|
+
|
|
280
|
+
Returns: Flags snapshot for MemoryStats.
|
|
281
|
+
|
|
282
|
+
### BuildMemoryStatsInput
|
|
283
|
+
|
|
284
|
+
Structured inputs required to assemble a MemoryStats snapshot in one pass.
|
|
285
|
+
Bundles precomputed accumulators, environment info, allocator stats, and
|
|
286
|
+
flags. This keeps the final snapshot builder declarative: collect first,
|
|
287
|
+
then fold into the public payload.
|
|
275
288
|
|
|
276
289
|
### buildMemoryStatsSnapshot
|
|
277
290
|
|
|
@@ -292,96 +305,84 @@ Parameters:
|
|
|
292
305
|
|
|
293
306
|
Returns: Complete MemoryStats snapshot.
|
|
294
307
|
|
|
295
|
-
###
|
|
308
|
+
### buildSlabStats
|
|
296
309
|
|
|
297
310
|
```ts
|
|
298
|
-
|
|
299
|
-
|
|
311
|
+
buildSlabStats(
|
|
312
|
+
accumulators: Accumulators,
|
|
313
|
+
networksToSummarize: NetworkView[],
|
|
300
314
|
allocationStats: SlabAllocStats,
|
|
301
|
-
): {
|
|
315
|
+
): { slabBytes: number; slabArrayCount: number; fragmentationPct: number | null; reservedBytes: number | null; usedBytes: number | null; slabVersion: number | null; asyncBuilds: number; pooledFraction: number | null; }
|
|
302
316
|
```
|
|
303
317
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
Flag snapshots explain *why* the memory picture may look the way it does by
|
|
307
|
-
capturing the small set of runtime options that materially alter pooling,
|
|
308
|
-
slab layout, and feature-gated storage paths.
|
|
318
|
+
Assemble slab-related statistics for the MemoryStats payload.
|
|
309
319
|
|
|
310
320
|
Parameters:
|
|
311
|
-
- `
|
|
312
|
-
- `
|
|
313
|
-
|
|
314
|
-
Returns: Flags snapshot for MemoryStats.
|
|
315
|
-
|
|
316
|
-
### HeuristicBytes
|
|
317
|
-
|
|
318
|
-
Heuristic byte weights used to approximate per-object overhead in the allocator.
|
|
319
|
-
These numbers represent typical JS object footprints, not exact runtime
|
|
320
|
-
measurements. They are teaching weights: stable enough to compare runs and
|
|
321
|
-
storage strategies even when the engine's true overhead is more complicated.
|
|
322
|
-
|
|
323
|
-
### Accumulators
|
|
321
|
+
- `accumulators` - Running totals collected during aggregation.
|
|
322
|
+
- `networksToSummarize` - Networks included in the snapshot.
|
|
323
|
+
- `allocationStats` - Optional allocator stats for pooled fraction.
|
|
324
324
|
|
|
325
|
-
|
|
326
|
-
Accumulates counts, slab byte totals, and reserved vs used capacity
|
|
327
|
-
snapshots. This is the file's working ledger before the public-facing
|
|
328
|
-
`MemoryStats` object is assembled.
|
|
325
|
+
Returns: Structured slab metrics block.
|
|
329
326
|
|
|
330
|
-
###
|
|
327
|
+
### calculateFragmentation
|
|
331
328
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
329
|
+
```ts
|
|
330
|
+
calculateFragmentation(
|
|
331
|
+
accumulators: Accumulators,
|
|
332
|
+
): number | null
|
|
333
|
+
```
|
|
336
334
|
|
|
337
|
-
|
|
335
|
+
Compute fragmentation percentage from reserved vs used connection bytes.
|
|
338
336
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
flags. This keeps the final snapshot builder declarative: collect first,
|
|
342
|
-
then fold into the public payload.
|
|
337
|
+
Parameters:
|
|
338
|
+
- `accumulators` - Running totals holding reserved and used bytes.
|
|
343
339
|
|
|
344
|
-
|
|
340
|
+
Returns: Fragmentation percent (0-100) or null when undefined.
|
|
345
341
|
|
|
346
|
-
|
|
347
|
-
Used as a fallback when typed-array parallel data is unavailable.
|
|
342
|
+
### calculatePooledFraction
|
|
348
343
|
|
|
349
|
-
|
|
344
|
+
```ts
|
|
345
|
+
calculatePooledFraction(
|
|
346
|
+
allocationStats: SlabAllocStats,
|
|
347
|
+
): number | null
|
|
348
|
+
```
|
|
350
349
|
|
|
351
|
-
|
|
352
|
-
This heuristic keeps node weight comparable to connection objects during summaries.
|
|
350
|
+
Calculate pooled fraction from allocator stats with four-decimal precision.
|
|
353
351
|
|
|
354
|
-
|
|
352
|
+
Parameters:
|
|
353
|
+
- `allocationStats` - Allocator snapshot or null when unavailable.
|
|
355
354
|
|
|
356
|
-
|
|
357
|
-
Centralizes the fallback values so downstream summaries stay consistent.
|
|
358
|
-
Read this as the chapter's shared baseline for "object-heavy" accounting
|
|
359
|
-
when typed-array widths are unavailable or incomplete.
|
|
355
|
+
Returns: Fraction of pooled allocations or null if indeterminate.
|
|
360
356
|
|
|
361
|
-
###
|
|
357
|
+
### captureEnvironmentMetrics
|
|
362
358
|
|
|
363
359
|
```ts
|
|
364
|
-
|
|
360
|
+
captureEnvironmentMetrics(): { isBrowser: boolean; usedJSHeapSize?: number | undefined; totalJSHeapSize?: number | undefined; jsHeapSizeLimit?: number | undefined; rss?: number | undefined; heapUsed?: number | undefined; heapTotal?: number | undefined; external?: number | undefined; }
|
|
365
361
|
```
|
|
366
362
|
|
|
367
|
-
|
|
363
|
+
Capture environment memory metrics from browser or Node when available.
|
|
368
364
|
|
|
369
|
-
|
|
365
|
+
The environment block complements the network-centric heuristics. It is not
|
|
366
|
+
specific enough to explain every connection or node, but it helps readers see
|
|
367
|
+
whether the broader runtime is moving in the same direction as the network
|
|
368
|
+
summary.
|
|
370
369
|
|
|
371
|
-
|
|
370
|
+
Returns: Environment metrics structure for the snapshot.
|
|
371
|
+
|
|
372
|
+
### captureVersionMetadata
|
|
372
373
|
|
|
373
374
|
```ts
|
|
374
|
-
|
|
375
|
+
captureVersionMetadata(
|
|
376
|
+
accumulators: Accumulators,
|
|
375
377
|
network: NetworkView,
|
|
376
|
-
):
|
|
378
|
+
): void
|
|
377
379
|
```
|
|
378
380
|
|
|
379
|
-
Capture
|
|
381
|
+
Capture slab metadata (version and async builds) once across all networks.
|
|
380
382
|
|
|
381
383
|
Parameters:
|
|
382
|
-
- `
|
|
383
|
-
|
|
384
|
-
Returns: Connection and node counts.
|
|
384
|
+
- `accumulators` - Running totals with metadata slots.
|
|
385
|
+
- `network` - Network providing slab metadata fields.
|
|
385
386
|
|
|
386
387
|
### collectConnectionTypedArrays
|
|
387
388
|
|
|
@@ -398,37 +399,42 @@ Parameters:
|
|
|
398
399
|
|
|
399
400
|
Returns: Typed arrays aligned to connections.
|
|
400
401
|
|
|
401
|
-
###
|
|
402
|
+
### computeCounts
|
|
402
403
|
|
|
403
404
|
```ts
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
): void
|
|
405
|
+
computeCounts(
|
|
406
|
+
network: NetworkView,
|
|
407
|
+
): CountSnapshot
|
|
408
408
|
```
|
|
409
409
|
|
|
410
|
-
|
|
410
|
+
Capture simple counts for nodes and connections on a network view.
|
|
411
411
|
|
|
412
412
|
Parameters:
|
|
413
|
-
- `
|
|
414
|
-
- `typedArrays` - Connection-parallel arrays to measure.
|
|
413
|
+
- `network` - Network being summarized.
|
|
415
414
|
|
|
416
|
-
|
|
415
|
+
Returns: Connection and node counts.
|
|
416
|
+
|
|
417
|
+
### ConfigSnapshot
|
|
418
|
+
|
|
419
|
+
Captured configuration knobs that influence memory usage and pooling behavior.
|
|
420
|
+
Keeps only the flags relevant to the memory snapshot to avoid leaking full
|
|
421
|
+
config. The goal is to explain the memory story, not to smuggle the entire
|
|
422
|
+
runtime configuration surface into a diagnostic payload.
|
|
423
|
+
|
|
424
|
+
### CONNECTION_OBJECT_BYTES
|
|
425
|
+
|
|
426
|
+
Estimated per-connection JS object footprint in bytes (includes metadata fields).
|
|
427
|
+
Used as a fallback when typed-array parallel data is unavailable.
|
|
428
|
+
|
|
429
|
+
### createEmptyAccumulators
|
|
417
430
|
|
|
418
431
|
```ts
|
|
419
|
-
|
|
420
|
-
accumulators: Accumulators,
|
|
421
|
-
network: NetworkView,
|
|
422
|
-
heuristics: HeuristicBytes,
|
|
423
|
-
): void
|
|
432
|
+
createEmptyAccumulators(): Accumulators
|
|
424
433
|
```
|
|
425
434
|
|
|
426
|
-
|
|
435
|
+
Initialize a fresh accumulator snapshot for memory summaries.
|
|
427
436
|
|
|
428
|
-
|
|
429
|
-
- `accumulators` - Running totals for the memory snapshot.
|
|
430
|
-
- `network` - Network exposing capacity metadata.
|
|
431
|
-
- `heuristics` - Fallback byte weights for connection objects.
|
|
437
|
+
Returns: Zeroed accumulators ready for aggregation.
|
|
432
438
|
|
|
433
439
|
### describeConnectionBytes
|
|
434
440
|
|
|
@@ -447,66 +453,60 @@ Parameters:
|
|
|
447
453
|
|
|
448
454
|
Returns: Estimated bytes per connection entry.
|
|
449
455
|
|
|
450
|
-
###
|
|
451
|
-
|
|
452
|
-
```ts
|
|
453
|
-
captureVersionMetadata(
|
|
454
|
-
accumulators: Accumulators,
|
|
455
|
-
network: NetworkView,
|
|
456
|
-
): void
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
Capture slab metadata (version and async builds) once across all networks.
|
|
460
|
-
|
|
461
|
-
Parameters:
|
|
462
|
-
- `accumulators` - Running totals with metadata slots.
|
|
463
|
-
- `network` - Network providing slab metadata fields.
|
|
456
|
+
### HEURISTIC_BYTES
|
|
464
457
|
|
|
465
|
-
|
|
458
|
+
Default heuristics mapping human-readable weights to their byte estimates.
|
|
459
|
+
Centralizes the fallback values so downstream summaries stay consistent.
|
|
460
|
+
Read this as the chapter's shared baseline for "object-heavy" accounting
|
|
461
|
+
when typed-array widths are unavailable or incomplete.
|
|
466
462
|
|
|
467
|
-
|
|
468
|
-
buildSlabStats(
|
|
469
|
-
accumulators: Accumulators,
|
|
470
|
-
networksToSummarize: NetworkView[],
|
|
471
|
-
allocationStats: SlabAllocStats,
|
|
472
|
-
): { slabBytes: number; slabArrayCount: number; fragmentationPct: number | null; reservedBytes: number | null; usedBytes: number | null; slabVersion: number | null; asyncBuilds: number; pooledFraction: number | null; }
|
|
473
|
-
```
|
|
463
|
+
### HeuristicBytes
|
|
474
464
|
|
|
475
|
-
|
|
465
|
+
Heuristic byte weights used to approximate per-object overhead in the allocator.
|
|
466
|
+
These numbers represent typical JS object footprints, not exact runtime
|
|
467
|
+
measurements. They are teaching weights: stable enough to compare runs and
|
|
468
|
+
storage strategies even when the engine's true overhead is more complicated.
|
|
476
469
|
|
|
477
|
-
|
|
478
|
-
- `accumulators` - Running totals collected during aggregation.
|
|
479
|
-
- `networksToSummarize` - Networks included in the snapshot.
|
|
480
|
-
- `allocationStats` - Optional allocator stats for pooled fraction.
|
|
470
|
+
### NODE_OBJECT_BYTES
|
|
481
471
|
|
|
482
|
-
|
|
472
|
+
Estimated per-node JS object footprint in bytes, covering activation state and IDs.
|
|
473
|
+
This heuristic keeps node weight comparable to connection objects during summaries.
|
|
483
474
|
|
|
484
|
-
###
|
|
475
|
+
### normalizeNetworks
|
|
485
476
|
|
|
486
477
|
```ts
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
478
|
+
normalizeNetworks(
|
|
479
|
+
targets: NetworkView | NetworkView[] | undefined,
|
|
480
|
+
trackedNetworks: NetworkView[],
|
|
481
|
+
): NetworkView[]
|
|
490
482
|
```
|
|
491
483
|
|
|
492
|
-
|
|
484
|
+
Normalize provided targets to an array of networks, falling back to tracked registry.
|
|
485
|
+
|
|
486
|
+
This helper keeps the public entrypoint flexible without making later
|
|
487
|
+
aggregation code branch on every call path.
|
|
493
488
|
|
|
494
489
|
Parameters:
|
|
495
|
-
- `
|
|
490
|
+
- `targets` - Optional single network or array.
|
|
491
|
+
- `trackedNetworks` - Internal registry of tracked networks.
|
|
496
492
|
|
|
497
|
-
Returns:
|
|
493
|
+
Returns: Array of networks to summarize.
|
|
498
494
|
|
|
499
|
-
###
|
|
495
|
+
### safeGetSlabAllocationStats
|
|
500
496
|
|
|
501
497
|
```ts
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
):
|
|
498
|
+
safeGetSlabAllocationStats(
|
|
499
|
+
getSlabAllocationStats: () => unknown,
|
|
500
|
+
): SlabAllocStats
|
|
505
501
|
```
|
|
506
502
|
|
|
507
|
-
|
|
503
|
+
Safely read slab allocation stats, guarding against provider errors.
|
|
504
|
+
|
|
505
|
+
Allocator telemetry is useful but optional. A failed probe should degrade the
|
|
506
|
+
snapshot gracefully instead of turning diagnostics into a source of runtime
|
|
507
|
+
failures.
|
|
508
508
|
|
|
509
509
|
Parameters:
|
|
510
|
-
- `
|
|
510
|
+
- `getSlabAllocationStats` - Provider function returning allocator stats.
|
|
511
511
|
|
|
512
|
-
Returns:
|
|
512
|
+
Returns: Slab allocation stats or null on failure.
|