@nimblesite/lsp-profiler-ui 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/out/src/bind-host.d.ts +3 -0
- package/out/src/bind-host.js +52 -0
- package/out/src/bind-host.js.map +1 -0
- package/out/src/context-keys.d.ts +4 -0
- package/out/src/context-keys.js +54 -0
- package/out/src/context-keys.js.map +1 -0
- package/out/src/dap-evaluate.d.ts +84 -0
- package/out/src/dap-evaluate.js +442 -0
- package/out/src/dap-evaluate.js.map +1 -0
- package/out/src/dap-output.d.ts +50 -0
- package/out/src/dap-output.js +177 -0
- package/out/src/dap-output.js.map +1 -0
- package/out/src/debug/adapter-resolution.d.ts +56 -0
- package/out/src/debug/adapter-resolution.js +112 -0
- package/out/src/debug/adapter-resolution.js.map +1 -0
- package/out/src/debug/dap-messages.d.ts +18 -0
- package/out/src/debug/dap-messages.js +71 -0
- package/out/src/debug/dap-messages.js.map +1 -0
- package/out/src/debug/index.d.ts +7 -0
- package/out/src/debug/index.js +27 -0
- package/out/src/debug/index.js.map +1 -0
- package/out/src/debug/launch-config.d.ts +42 -0
- package/out/src/debug/launch-config.js +73 -0
- package/out/src/debug/launch-config.js.map +1 -0
- package/out/src/debug/launch-lifecycle.d.ts +29 -0
- package/out/src/debug/launch-lifecycle.js +40 -0
- package/out/src/debug/launch-lifecycle.js.map +1 -0
- package/out/src/debug/poll.d.ts +25 -0
- package/out/src/debug/poll.js +70 -0
- package/out/src/debug/poll.js.map +1 -0
- package/out/src/debug/profiling.d.ts +34 -0
- package/out/src/debug/profiling.js +81 -0
- package/out/src/debug/profiling.js.map +1 -0
- package/out/src/debug/testing/assertions.d.ts +27 -0
- package/out/src/debug/testing/assertions.js +111 -0
- package/out/src/debug/testing/assertions.js.map +1 -0
- package/out/src/debug/testing/dap-client.d.ts +86 -0
- package/out/src/debug/testing/dap-client.js +204 -0
- package/out/src/debug/testing/dap-client.js.map +1 -0
- package/out/src/debug/testing/index.d.ts +7 -0
- package/out/src/debug/testing/index.js +31 -0
- package/out/src/debug/testing/index.js.map +1 -0
- package/out/src/debug/testing/vscode-harness.d.ts +44 -0
- package/out/src/debug/testing/vscode-harness.js +81 -0
- package/out/src/debug/testing/vscode-harness.js.map +1 -0
- package/out/src/debug/ui-stubs.d.ts +26 -0
- package/out/src/debug/ui-stubs.js +88 -0
- package/out/src/debug/ui-stubs.js.map +1 -0
- package/out/src/debug-link-setup.d.ts +4 -0
- package/out/src/debug-link-setup.js +19 -0
- package/out/src/debug-link-setup.js.map +1 -0
- package/out/src/debug-link-view.d.ts +4 -0
- package/out/src/debug-link-view.js +49 -0
- package/out/src/debug-link-view.js.map +1 -0
- package/out/src/debug-link.d.ts +6 -0
- package/out/src/debug-link.js +95 -0
- package/out/src/debug-link.js.map +1 -0
- package/out/src/debug-selection.d.ts +14 -0
- package/out/src/debug-selection.js +33 -0
- package/out/src/debug-selection.js.map +1 -0
- package/out/src/debuggee-pause.d.ts +11 -0
- package/out/src/debuggee-pause.js +109 -0
- package/out/src/debuggee-pause.js.map +1 -0
- package/out/src/editor-path-key.d.ts +52 -0
- package/out/src/editor-path-key.js +105 -0
- package/out/src/editor-path-key.js.map +1 -0
- package/out/src/failure.d.ts +5 -0
- package/out/src/failure.js +53 -0
- package/out/src/failure.js.map +1 -0
- package/out/src/file-log-sink.d.ts +20 -0
- package/out/src/file-log-sink.js +74 -0
- package/out/src/file-log-sink.js.map +1 -0
- package/out/src/flame-html.d.ts +8 -0
- package/out/src/flame-html.js +104 -0
- package/out/src/flame-html.js.map +1 -0
- package/out/src/flame-model.d.ts +93 -0
- package/out/src/flame-model.js +242 -0
- package/out/src/flame-model.js.map +1 -0
- package/out/src/flame-script-helpers.d.ts +26 -0
- package/out/src/flame-script-helpers.js +71 -0
- package/out/src/flame-script-helpers.js.map +1 -0
- package/out/src/flame-script.d.ts +1 -0
- package/out/src/flame-script.js +332 -0
- package/out/src/flame-script.js.map +1 -0
- package/out/src/flame-time-order.d.ts +14 -0
- package/out/src/flame-time-order.js +112 -0
- package/out/src/flame-time-order.js.map +1 -0
- package/out/src/flamegraph-artifact.d.ts +9 -0
- package/out/src/flamegraph-artifact.js +45 -0
- package/out/src/flamegraph-artifact.js.map +1 -0
- package/out/src/host.d.ts +31 -0
- package/out/src/host.js +6 -0
- package/out/src/host.js.map +1 -0
- package/out/src/ids.d.ts +27 -0
- package/out/src/ids.js +63 -0
- package/out/src/ids.js.map +1 -0
- package/out/src/index.d.ts +42 -0
- package/out/src/index.js +98 -0
- package/out/src/index.js.map +1 -0
- package/out/src/logger.d.ts +50 -0
- package/out/src/logger.js +86 -0
- package/out/src/logger.js.map +1 -0
- package/out/src/memory-autopilot.d.ts +64 -0
- package/out/src/memory-autopilot.js +306 -0
- package/out/src/memory-autopilot.js.map +1 -0
- package/out/src/memory-capture-ids.d.ts +17 -0
- package/out/src/memory-capture-ids.js +45 -0
- package/out/src/memory-capture-ids.js.map +1 -0
- package/out/src/memory-capture-ingest.d.ts +15 -0
- package/out/src/memory-capture-ingest.js +84 -0
- package/out/src/memory-capture-ingest.js.map +1 -0
- package/out/src/memory-capture-legs.d.ts +4 -0
- package/out/src/memory-capture-legs.js +55 -0
- package/out/src/memory-capture-legs.js.map +1 -0
- package/out/src/memory-capture-present.d.ts +32 -0
- package/out/src/memory-capture-present.js +71 -0
- package/out/src/memory-capture-present.js.map +1 -0
- package/out/src/memory-capture-roundtrip.d.ts +17 -0
- package/out/src/memory-capture-roundtrip.js +75 -0
- package/out/src/memory-capture-roundtrip.js.map +1 -0
- package/out/src/memory-capture-state.d.ts +23 -0
- package/out/src/memory-capture-state.js +89 -0
- package/out/src/memory-capture-state.js.map +1 -0
- package/out/src/memory-capture-types.d.ts +28 -0
- package/out/src/memory-capture-types.js +70 -0
- package/out/src/memory-capture-types.js.map +1 -0
- package/out/src/memory-capture.d.ts +24 -0
- package/out/src/memory-capture.js +51 -0
- package/out/src/memory-capture.js.map +1 -0
- package/out/src/memory-dashboard-html.d.ts +3 -0
- package/out/src/memory-dashboard-html.js +327 -0
- package/out/src/memory-dashboard-html.js.map +1 -0
- package/out/src/memory-dashboard-mapping.d.ts +34 -0
- package/out/src/memory-dashboard-mapping.js +135 -0
- package/out/src/memory-dashboard-mapping.js.map +1 -0
- package/out/src/memory-dashboard.d.ts +82 -0
- package/out/src/memory-dashboard.js +142 -0
- package/out/src/memory-dashboard.js.map +1 -0
- package/out/src/memory-decorations.d.ts +61 -0
- package/out/src/memory-decorations.js +247 -0
- package/out/src/memory-decorations.js.map +1 -0
- package/out/src/memory-finalize.d.ts +25 -0
- package/out/src/memory-finalize.js +207 -0
- package/out/src/memory-finalize.js.map +1 -0
- package/out/src/memory-guidance.d.ts +14 -0
- package/out/src/memory-guidance.js +36 -0
- package/out/src/memory-guidance.js.map +1 -0
- package/out/src/memory-inspect-commands.d.ts +20 -0
- package/out/src/memory-inspect-commands.js +114 -0
- package/out/src/memory-inspect-commands.js.map +1 -0
- package/out/src/memory-launch-direct.d.ts +12 -0
- package/out/src/memory-launch-direct.js +74 -0
- package/out/src/memory-launch-direct.js.map +1 -0
- package/out/src/memory-launch.d.ts +4 -0
- package/out/src/memory-launch.js +92 -0
- package/out/src/memory-launch.js.map +1 -0
- package/out/src/memory-leak-offer.d.ts +18 -0
- package/out/src/memory-leak-offer.js +51 -0
- package/out/src/memory-leak-offer.js.map +1 -0
- package/out/src/memory-profiler.d.ts +27 -0
- package/out/src/memory-profiler.js +71 -0
- package/out/src/memory-profiler.js.map +1 -0
- package/out/src/memory-ref-graph.d.ts +62 -0
- package/out/src/memory-ref-graph.js +248 -0
- package/out/src/memory-ref-graph.js.map +1 -0
- package/out/src/memory-ref-picker.d.ts +21 -0
- package/out/src/memory-ref-picker.js +103 -0
- package/out/src/memory-ref-picker.js.map +1 -0
- package/out/src/memory-registration.d.ts +4 -0
- package/out/src/memory-registration.js +63 -0
- package/out/src/memory-registration.js.map +1 -0
- package/out/src/memory-start-core.d.ts +8 -0
- package/out/src/memory-start-core.js +165 -0
- package/out/src/memory-start-core.js.map +1 -0
- package/out/src/memory-start-stop-commands.d.ts +10 -0
- package/out/src/memory-start-stop-commands.js +75 -0
- package/out/src/memory-start-stop-commands.js.map +1 -0
- package/out/src/memory-start.d.ts +6 -0
- package/out/src/memory-start.js +13 -0
- package/out/src/memory-start.js.map +1 -0
- package/out/src/memory-status.d.ts +24 -0
- package/out/src/memory-status.js +135 -0
- package/out/src/memory-status.js.map +1 -0
- package/out/src/palette-vscode.d.ts +2 -0
- package/out/src/palette-vscode.js +50 -0
- package/out/src/palette-vscode.js.map +1 -0
- package/out/src/palette.d.ts +70 -0
- package/out/src/palette.js +150 -0
- package/out/src/palette.js.map +1 -0
- package/out/src/process-bind-panel.d.ts +11 -0
- package/out/src/process-bind-panel.js +65 -0
- package/out/src/process-bind-panel.js.map +1 -0
- package/out/src/process-commands.d.ts +5 -0
- package/out/src/process-commands.js +112 -0
- package/out/src/process-commands.js.map +1 -0
- package/out/src/process-context-keys.d.ts +11 -0
- package/out/src/process-context-keys.js +48 -0
- package/out/src/process-context-keys.js.map +1 -0
- package/out/src/process-decoration.d.ts +18 -0
- package/out/src/process-decoration.js +76 -0
- package/out/src/process-decoration.js.map +1 -0
- package/out/src/process-explorer-rows.d.ts +59 -0
- package/out/src/process-explorer-rows.js +47 -0
- package/out/src/process-explorer-rows.js.map +1 -0
- package/out/src/process-explorer.d.ts +66 -0
- package/out/src/process-explorer.js +241 -0
- package/out/src/process-explorer.js.map +1 -0
- package/out/src/process-group-item.d.ts +8 -0
- package/out/src/process-group-item.js +55 -0
- package/out/src/process-group-item.js.map +1 -0
- package/out/src/process-launch-item.d.ts +12 -0
- package/out/src/process-launch-item.js +57 -0
- package/out/src/process-launch-item.js.map +1 -0
- package/out/src/process-launch.d.ts +47 -0
- package/out/src/process-launch.js +205 -0
- package/out/src/process-launch.js.map +1 -0
- package/out/src/process-message-item.d.ts +10 -0
- package/out/src/process-message-item.js +53 -0
- package/out/src/process-message-item.js.map +1 -0
- package/out/src/process-poll.d.ts +26 -0
- package/out/src/process-poll.js +125 -0
- package/out/src/process-poll.js.map +1 -0
- package/out/src/process-reactivity.d.ts +55 -0
- package/out/src/process-reactivity.js +188 -0
- package/out/src/process-reactivity.js.map +1 -0
- package/out/src/process-registration.d.ts +11 -0
- package/out/src/process-registration.js +55 -0
- package/out/src/process-registration.js.map +1 -0
- package/out/src/process-tree-item.d.ts +18 -0
- package/out/src/process-tree-item.js +219 -0
- package/out/src/process-tree-item.js.map +1 -0
- package/out/src/processes-state.d.ts +75 -0
- package/out/src/processes-state.js +76 -0
- package/out/src/processes-state.js.map +1 -0
- package/out/src/profile-on-launch.d.ts +4 -0
- package/out/src/profile-on-launch.js +16 -0
- package/out/src/profile-on-launch.js.map +1 -0
- package/out/src/profile-server.d.ts +24 -0
- package/out/src/profile-server.js +170 -0
- package/out/src/profile-server.js.map +1 -0
- package/out/src/profiler-attach.d.ts +19 -0
- package/out/src/profiler-attach.js +129 -0
- package/out/src/profiler-attach.js.map +1 -0
- package/out/src/profiler-commands.d.ts +8 -0
- package/out/src/profiler-commands.js +110 -0
- package/out/src/profiler-commands.js.map +1 -0
- package/out/src/profiler-decorations.d.ts +74 -0
- package/out/src/profiler-decorations.js +237 -0
- package/out/src/profiler-decorations.js.map +1 -0
- package/out/src/profiler-dispose.d.ts +6 -0
- package/out/src/profiler-dispose.js +20 -0
- package/out/src/profiler-dispose.js.map +1 -0
- package/out/src/profiler-flamegraph-html.d.ts +61 -0
- package/out/src/profiler-flamegraph-html.js +366 -0
- package/out/src/profiler-flamegraph-html.js.map +1 -0
- package/out/src/profiler-format.d.ts +10 -0
- package/out/src/profiler-format.js +28 -0
- package/out/src/profiler-format.js.map +1 -0
- package/out/src/profiler-launch-cooperative.d.ts +16 -0
- package/out/src/profiler-launch-cooperative.js +167 -0
- package/out/src/profiler-launch-cooperative.js.map +1 -0
- package/out/src/profiler-launch.d.ts +29 -0
- package/out/src/profiler-launch.js +123 -0
- package/out/src/profiler-launch.js.map +1 -0
- package/out/src/profiler-results.d.ts +22 -0
- package/out/src/profiler-results.js +104 -0
- package/out/src/profiler-results.js.map +1 -0
- package/out/src/profiler-session-core.d.ts +42 -0
- package/out/src/profiler-session-core.js +116 -0
- package/out/src/profiler-session-core.js.map +1 -0
- package/out/src/profiler-state.d.ts +87 -0
- package/out/src/profiler-state.js +83 -0
- package/out/src/profiler-state.js.map +1 -0
- package/out/src/profiler-status.d.ts +38 -0
- package/out/src/profiler-status.js +163 -0
- package/out/src/profiler-status.js.map +1 -0
- package/out/src/profiler-styles.d.ts +21 -0
- package/out/src/profiler-styles.js +160 -0
- package/out/src/profiler-styles.js.map +1 -0
- package/out/src/profiler-webview.d.ts +95 -0
- package/out/src/profiler-webview.js +243 -0
- package/out/src/profiler-webview.js.map +1 -0
- package/out/src/profiler.d.ts +23 -0
- package/out/src/profiler.js +113 -0
- package/out/src/profiler.js.map +1 -0
- package/out/src/progress-ops.d.ts +24 -0
- package/out/src/progress-ops.js +135 -0
- package/out/src/progress-ops.js.map +1 -0
- package/out/src/reactive-refresh.d.ts +24 -0
- package/out/src/reactive-refresh.js +33 -0
- package/out/src/reactive-refresh.js.map +1 -0
- package/out/src/sample-summary.d.ts +39 -0
- package/out/src/sample-summary.js +32 -0
- package/out/src/sample-summary.js.map +1 -0
- package/out/src/sampled-view.d.ts +15 -0
- package/out/src/sampled-view.js +56 -0
- package/out/src/sampled-view.js.map +1 -0
- package/out/src/server-command.d.ts +4 -0
- package/out/src/server-command.js +14 -0
- package/out/src/server-command.js.map +1 -0
- package/out/src/settings.d.ts +1 -0
- package/out/src/settings.js +22 -0
- package/out/src/settings.js.map +1 -0
- package/out/src/store.d.ts +34 -0
- package/out/src/store.js +64 -0
- package/out/src/store.js.map +1 -0
- package/out/src/testing/cpu-capture-assertions.d.ts +8 -0
- package/out/src/testing/cpu-capture-assertions.js +71 -0
- package/out/src/testing/cpu-capture-assertions.js.map +1 -0
- package/out/src/testing/cpu-capture-contract.d.ts +8 -0
- package/out/src/testing/cpu-capture-contract.js +123 -0
- package/out/src/testing/cpu-capture-contract.js.map +1 -0
- package/out/src/testing/webview-contract-helpers.d.ts +24 -0
- package/out/src/testing/webview-contract-helpers.js +125 -0
- package/out/src/testing/webview-contract-helpers.js.map +1 -0
- package/out/src/testing/webview-contract-leak.d.ts +2 -0
- package/out/src/testing/webview-contract-leak.js +80 -0
- package/out/src/testing/webview-contract-leak.js.map +1 -0
- package/out/src/testing/webview-contract-memory.d.ts +5 -0
- package/out/src/testing/webview-contract-memory.js +221 -0
- package/out/src/testing/webview-contract-memory.js.map +1 -0
- package/out/src/testing/webview-contract-palette.d.ts +6 -0
- package/out/src/testing/webview-contract-palette.js +121 -0
- package/out/src/testing/webview-contract-palette.js.map +1 -0
- package/out/src/testing/webview-contract-panel.d.ts +7 -0
- package/out/src/testing/webview-contract-panel.js +100 -0
- package/out/src/testing/webview-contract-panel.js.map +1 -0
- package/out/src/testing/webview-contract-results.d.ts +6 -0
- package/out/src/testing/webview-contract-results.js +136 -0
- package/out/src/testing/webview-contract-results.js.map +1 -0
- package/out/src/testing/webview-contract.d.ts +18 -0
- package/out/src/testing/webview-contract.js +23 -0
- package/out/src/testing/webview-contract.js.map +1 -0
- package/out/src/timeouts.d.ts +21 -0
- package/out/src/timeouts.js +30 -0
- package/out/src/timeouts.js.map +1 -0
- package/out/src/trace-actions.d.ts +33 -0
- package/out/src/trace-actions.js +135 -0
- package/out/src/trace-actions.js.map +1 -0
- package/out/src/unknown-shape.d.ts +58 -0
- package/out/src/unknown-shape.js +110 -0
- package/out/src/unknown-shape.js.map +1 -0
- package/out/src/wire-adapters.d.ts +18 -0
- package/out/src/wire-adapters.js +160 -0
- package/out/src/wire-adapters.js.map +1 -0
- package/out/src/wire-generated.d.ts +760 -0
- package/out/src/wire-generated.js +38 -0
- package/out/src/wire-generated.js.map +1 -0
- package/package.json +53 -4
- package/scripts/contributions.mjs +187 -0
- package/README.md +0 -3
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Implements [PROF-UI-AUTOPILOT] + [PROF-UI-MEMORY].
|
|
3
|
+
// See docs/specs/LSP-PROFILER-SPEC.md
|
|
4
|
+
/**
|
|
5
|
+
* The memory autopilot: captures snapshots automatically while tracking is
|
|
6
|
+
* active, so the interactive leak hunt is "set a breakpoint and press Continue"
|
|
7
|
+
* instead of a per-pause click treadmill.
|
|
8
|
+
*
|
|
9
|
+
* Two triggers, one capture core ([`captureSnapshotAndDiff`](./memory-capture.ts)):
|
|
10
|
+
* - every debugger pause — [PROF-UI-AUTOPILOT] (on by default)
|
|
11
|
+
* - a fixed interval — [PROF-UI-AUTOPILOT] (opt-in)
|
|
12
|
+
*
|
|
13
|
+
* It also surfaces one proactive leak action the first time a site escalates to
|
|
14
|
+
* High/Definite ([PROF-UI-MEMORY]).
|
|
15
|
+
*
|
|
16
|
+
* The interval timer's lifecycle follows the store's tracking signal — no timer
|
|
17
|
+
* outlives its session. Guards (a synchronous re-entrancy flag plus the shared
|
|
18
|
+
* `isMemoryOperationInFlight` flag) ensure a capture's own transparent pause, an
|
|
19
|
+
* in-progress manual op, or two near-simultaneous `stopped` events never trigger
|
|
20
|
+
* a duplicate capture.
|
|
21
|
+
*/
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35
|
+
}) : function(o, v) {
|
|
36
|
+
o["default"] = v;
|
|
37
|
+
});
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.recordedAutopilotCaptures = recordedAutopilotCaptures;
|
|
57
|
+
exports.recordedLeakOffers = recordedLeakOffers;
|
|
58
|
+
exports.registerMemoryAutopilot = registerMemoryAutopilot;
|
|
59
|
+
exports.disposeMemoryAutopilot = disposeMemoryAutopilot;
|
|
60
|
+
exports.notifyDebuggeePause = notifyDebuggeePause;
|
|
61
|
+
exports.captureIntervalSeconds = captureIntervalSeconds;
|
|
62
|
+
const vscode = __importStar(require("vscode"));
|
|
63
|
+
const ids_1 = require("./ids");
|
|
64
|
+
const signals_core_1 = require("@preact/signals-core");
|
|
65
|
+
const logger_1 = require("./logger");
|
|
66
|
+
const progress_ops_1 = require("./progress-ops");
|
|
67
|
+
const memory_capture_1 = require("./memory-capture");
|
|
68
|
+
const debuggee_pause_1 = require("./debuggee-pause");
|
|
69
|
+
const memory_decorations_1 = require("./memory-decorations");
|
|
70
|
+
const memory_leak_offer_1 = require("./memory-leak-offer");
|
|
71
|
+
/** Progress title for an automatic capture (visible feedback each pass). */
|
|
72
|
+
function autoCaptureTitle() {
|
|
73
|
+
return `${(0, ids_1.brand)()}: Auto-capturing memory`;
|
|
74
|
+
}
|
|
75
|
+
/** Confidence at/above which the proactive leak action is offered. */
|
|
76
|
+
const ACTION_THRESHOLD = "HIGH";
|
|
77
|
+
/** Minimum interval (seconds) so a misconfigured tiny value can't busy-loop. */
|
|
78
|
+
const MIN_INTERVAL_SECS = 1;
|
|
79
|
+
const DEFAULT_INTERVAL_SECS = 30;
|
|
80
|
+
/** Milliseconds per second (interval setting is in seconds). */
|
|
81
|
+
const MS_PER_SECOND = 1000;
|
|
82
|
+
let autopilotCaptures = [];
|
|
83
|
+
let leakActionOffers = [];
|
|
84
|
+
/** The automatic captures performed this session (e2e seam). */
|
|
85
|
+
function recordedAutopilotCaptures() {
|
|
86
|
+
return autopilotCaptures;
|
|
87
|
+
}
|
|
88
|
+
/** The proactive leak-action offers made this session (e2e seam). */
|
|
89
|
+
function recordedLeakOffers() {
|
|
90
|
+
return leakActionOffers;
|
|
91
|
+
}
|
|
92
|
+
const autopilotState = {
|
|
93
|
+
boundStore: undefined,
|
|
94
|
+
intervalTimer: undefined,
|
|
95
|
+
leakOfferedForSession: undefined,
|
|
96
|
+
};
|
|
97
|
+
/** Synchronous re-entrancy guard — set before the first `await` of a capture. */
|
|
98
|
+
let autopilotBusy = false;
|
|
99
|
+
/** Previous tracking state, to detect active⇄idle transitions in the effect. */
|
|
100
|
+
let prevMemoryState = "idle";
|
|
101
|
+
// ── Registration ────────────────────────────────────────────────────────────
|
|
102
|
+
/**
|
|
103
|
+
* Wire the autopilot to the store. The returned disposable tears down the
|
|
104
|
+
* tracking-signal effect and any live interval timer.
|
|
105
|
+
*/
|
|
106
|
+
function registerMemoryAutopilot(store) {
|
|
107
|
+
autopilotState.boundStore = store;
|
|
108
|
+
prevMemoryState = store.profiler.value.memory;
|
|
109
|
+
const disposeEffect = (0, signals_core_1.effect)(() => { autopilotLifecycle(store); });
|
|
110
|
+
return [
|
|
111
|
+
(0, debuggee_pause_1.onDebuggeePaused)((sessionId) => { notifyDebuggeePause(sessionId); }),
|
|
112
|
+
{ dispose: () => { disposeEffect(); disposeMemoryAutopilot(); } },
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
/** Clear all autopilot state (deactivation / test teardown). */
|
|
116
|
+
function disposeMemoryAutopilot() {
|
|
117
|
+
stopInterval();
|
|
118
|
+
autopilotState.boundStore = undefined;
|
|
119
|
+
autopilotBusy = false;
|
|
120
|
+
autopilotState.leakOfferedForSession = undefined;
|
|
121
|
+
prevMemoryState = "idle";
|
|
122
|
+
autopilotCaptures = [];
|
|
123
|
+
leakActionOffers = [];
|
|
124
|
+
}
|
|
125
|
+
// ── Pause trigger ────────────────────────────────────────────────────────────
|
|
126
|
+
/**
|
|
127
|
+
* Called by the DAP tracker on every `stopped` event ([PROF-UI-AUTOPILOT]).
|
|
128
|
+
* Captures automatically when tracking is active for *this* session, the pause
|
|
129
|
+
* is a genuine user pause (no memory op already in flight), and pause-capture is
|
|
130
|
+
* enabled. Fire-and-forget — never blocks the DAP tracker.
|
|
131
|
+
*/
|
|
132
|
+
function notifyDebuggeePause(sessionId) {
|
|
133
|
+
const store = pauseCaptureStore(sessionId);
|
|
134
|
+
if (store === undefined) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
autopilotBusy = true;
|
|
138
|
+
logger_1.Logger.info(`[Memory] autopilot: capturing on pause (session ${sessionId})`);
|
|
139
|
+
void runAutoCapture(store, "pause");
|
|
140
|
+
}
|
|
141
|
+
/** The bound store when a pause should auto-capture, else undefined. */
|
|
142
|
+
function pauseCaptureStore(sessionId) {
|
|
143
|
+
// A direct runtime cannot read a heap the debugger holds paused, and a read
|
|
144
|
+
// started just after a Continue blocks at the next pause, so pause-driven
|
|
145
|
+
// capture is courier-only; a direct runtime is captured on the interval
|
|
146
|
+
// ([PROF-MEMORY-MODE]).
|
|
147
|
+
if ((0, memory_capture_1.isDirectMemorySession)()) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
const store = autopilotState.boundStore;
|
|
151
|
+
if (store === undefined) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
return canCapturePause(store, sessionId) ? store : undefined;
|
|
155
|
+
}
|
|
156
|
+
/** Whether this session may capture on its pause right now. */
|
|
157
|
+
function canCapturePause(store, sessionId) {
|
|
158
|
+
if (autopilotBusy || (0, memory_capture_1.isMemoryOperationInFlight)()) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
if (store.profiler.value.memory !== "active") {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
if (store.profiler.value.memoryDebugSessionId !== sessionId) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
return isPauseCaptureEnabled();
|
|
168
|
+
}
|
|
169
|
+
// ── Interval trigger ─────────────────────────────────────────────────────────
|
|
170
|
+
/** Start/stop the interval timer as tracking turns on and off. */
|
|
171
|
+
function autopilotLifecycle(store) {
|
|
172
|
+
const state = store.profiler.value.memory;
|
|
173
|
+
if (state === "active" && prevMemoryState !== "active") {
|
|
174
|
+
// A fresh tracking session: reset per-session state, arm the interval timer.
|
|
175
|
+
resetSessionState();
|
|
176
|
+
armIntervalIfEnabled(store);
|
|
177
|
+
}
|
|
178
|
+
else if (state !== "active" && prevMemoryState === "active") {
|
|
179
|
+
stopInterval();
|
|
180
|
+
}
|
|
181
|
+
prevMemoryState = state;
|
|
182
|
+
}
|
|
183
|
+
/** Seconds between interval captures, or undefined while interval mode is off. */
|
|
184
|
+
function captureIntervalSeconds() {
|
|
185
|
+
const config = vscode.workspace.getConfiguration(`${(0, ids_1.configSection)()}.profiler`);
|
|
186
|
+
if (!config.get("autoSnapshot", false)) {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
return Math.max(MIN_INTERVAL_SECS, config.get("autoSnapshotInterval", DEFAULT_INTERVAL_SECS));
|
|
190
|
+
}
|
|
191
|
+
/** Arm the interval timer if interval mode is enabled in settings. */
|
|
192
|
+
function armIntervalIfEnabled(store) {
|
|
193
|
+
const seconds = captureIntervalSeconds();
|
|
194
|
+
if (seconds === undefined) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
stopInterval();
|
|
198
|
+
autopilotState.intervalTimer = setInterval(() => { void onIntervalTick(store); }, seconds * MS_PER_SECOND);
|
|
199
|
+
logger_1.Logger.info(`[Memory] autopilot interval armed: every ${String(seconds)}s`);
|
|
200
|
+
}
|
|
201
|
+
/** Stop the interval timer if running. */
|
|
202
|
+
function stopInterval() {
|
|
203
|
+
if (autopilotState.intervalTimer !== undefined) {
|
|
204
|
+
clearInterval(autopilotState.intervalTimer);
|
|
205
|
+
autopilotState.intervalTimer = undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/** One interval tick: capture if idle and still tracking. */
|
|
209
|
+
async function onIntervalTick(store) {
|
|
210
|
+
if (autopilotBusy || (0, memory_capture_1.isMemoryOperationInFlight)()) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (store.profiler.value.memory !== "active") {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
// A direct runtime's heap cannot be read while the debugger holds it paused.
|
|
217
|
+
if ((0, memory_capture_1.isDirectMemorySession)() && (0, debuggee_pause_1.isDebuggeePaused)(store.profiler.value.memoryDebugSessionId)) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
autopilotBusy = true;
|
|
221
|
+
logger_1.Logger.info("[Memory] autopilot: capturing on interval");
|
|
222
|
+
await runAutoCapture(store, "interval");
|
|
223
|
+
}
|
|
224
|
+
// ── Capture ──────────────────────────────────────────────────────────────────
|
|
225
|
+
/**
|
|
226
|
+
* Run one automatic capture under a progress notification, record it, and offer
|
|
227
|
+
* a leak action if a site just escalated. Assumes `autopilotBusy` is already set
|
|
228
|
+
* by the caller (synchronously, to close the two-events race); always clears it.
|
|
229
|
+
*/
|
|
230
|
+
async function runAutoCapture(store, trigger) {
|
|
231
|
+
try {
|
|
232
|
+
const result = await (0, progress_ops_1.withUserProgress)(autoCaptureTitle(), async (report) => (0, memory_capture_1.captureSnapshotAndDiff)(store, report));
|
|
233
|
+
recordCapture(trigger, result.diff);
|
|
234
|
+
maybeOfferLeakActions(store, result.diff);
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
logger_1.Logger.warn(`[Memory] autopilot capture failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
238
|
+
}
|
|
239
|
+
finally {
|
|
240
|
+
autopilotBusy = false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/** Record a capture's diff into the ledger (the e2e seam). */
|
|
244
|
+
function recordCapture(trigger, diff) {
|
|
245
|
+
const leaks = diff?.suspectedLeaks ?? [];
|
|
246
|
+
const worst = (0, memory_leak_offer_1.leakToOffer)(leaks);
|
|
247
|
+
autopilotCaptures.push({
|
|
248
|
+
trigger,
|
|
249
|
+
suspectedLeakCount: leaks.length,
|
|
250
|
+
maxConfidence: worst?.confidence ?? "none",
|
|
251
|
+
leakLines: leaks.map((leak) => leak.line),
|
|
252
|
+
});
|
|
253
|
+
logger_1.Logger.info(`[Memory] autopilot capture (${trigger}): ${String(leaks.length)} suspected leak(s), ` +
|
|
254
|
+
`max confidence ${worst?.confidence ?? "none"}`);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Offer the proactive leak action the first time a site reaches the threshold
|
|
258
|
+
* confidence this session ([PROF-UI-MEMORY]) — at most once, so the
|
|
259
|
+
* Continue loop is never spammed.
|
|
260
|
+
*/
|
|
261
|
+
function maybeOfferLeakActions(store, diff) {
|
|
262
|
+
const leak = (0, memory_leak_offer_1.leakToOffer)(diff?.suspectedLeaks ?? []);
|
|
263
|
+
if (leak === undefined || (0, memory_decorations_1.confidenceRank)(leak.confidence) < (0, memory_decorations_1.confidenceRank)(ACTION_THRESHOLD)) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const sessionId = store.profiler.value.memorySessionId;
|
|
267
|
+
if (sessionId === undefined || autopilotState.leakOfferedForSession === sessionId) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
autopilotState.leakOfferedForSession = sessionId;
|
|
271
|
+
recordLeakOffer(leak);
|
|
272
|
+
}
|
|
273
|
+
/** Record and announce one proactive leak-action offer (at most once per session). */
|
|
274
|
+
function recordLeakOffer(leak) {
|
|
275
|
+
const named = `${(0, memory_leak_offer_1.describeLeak)(leak)} (${leak.confidence})`;
|
|
276
|
+
const message = `${(0, ids_1.brand)()}: Suspected memory leak: ${named}. ${leak.reason}`;
|
|
277
|
+
const { file, line, typeName, confidence } = leak;
|
|
278
|
+
leakActionOffers.push({ file, line, typeName, confidence, message });
|
|
279
|
+
logger_1.Logger.warn(`[Memory] autopilot: suspected leak ${named}`);
|
|
280
|
+
void offerLeakActions(message);
|
|
281
|
+
}
|
|
282
|
+
/** Show the one-click leak-action notification (Reference Graph / Force GC). */
|
|
283
|
+
async function offerLeakActions(message) {
|
|
284
|
+
const showGraph = "Show Reference Graph";
|
|
285
|
+
const forceGc = "Force Garbage Collection";
|
|
286
|
+
const choice = await vscode.window.showWarningMessage(message, showGraph, forceGc);
|
|
287
|
+
if (choice === showGraph) {
|
|
288
|
+
await vscode.commands.executeCommand((0, ids_1.cmd)("memoryReferences"));
|
|
289
|
+
}
|
|
290
|
+
else if (choice === forceGc) {
|
|
291
|
+
await vscode.commands.executeCommand((0, ids_1.cmd)("memoryGcCollect"));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/** Reset per-session state at the start of a new tracking session. */
|
|
295
|
+
function resetSessionState() {
|
|
296
|
+
autopilotCaptures = [];
|
|
297
|
+
leakActionOffers = [];
|
|
298
|
+
autopilotState.leakOfferedForSession = undefined;
|
|
299
|
+
}
|
|
300
|
+
/** Whether per-pause auto-capture is enabled (default true). */
|
|
301
|
+
function isPauseCaptureEnabled() {
|
|
302
|
+
return vscode.workspace
|
|
303
|
+
.getConfiguration(`${(0, ids_1.configSection)()}.profiler`)
|
|
304
|
+
.get("autoSnapshotOnPause", true);
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=memory-autopilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-autopilot.js","sourceRoot":"","sources":["../../src/memory-autopilot.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,sCAAsC;AACtC;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,MAAY,MAAM,mCAAe;AACjC,+BAAkD;AAClD,uDAA8C;AAC9C,qCAAkC;AAElC,iDAAkD;AAClD,qDAA4G;AAC5G,qDAAsE;AAEtE,6DAAsD;AACtD,2DAAgE;AAEhE,4EAA4E;AAC5E,SAAS,gBAAgB;IACvB,OAAO,GAAG,IAAA,WAAK,GAAE,yBAAyB,CAAC;AAC7C,CAAC;AAED,sEAAsE;AACtE,MAAM,gBAAgB,GAAmB,MAAM,CAAC;AAEhD,gFAAgF;AAChF,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,gEAAgE;AAChE,MAAM,aAAa,GAAG,IAAI,CAAC;AAgC3B,IAAI,iBAAiB,GAAuB,EAAE,CAAC;AAC/C,IAAI,gBAAgB,GAAsB,EAAE,CAAC;AAE7C,gEAAgE;AAChE;IACE,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,qEAAqE;AACrE;IACE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAWD,MAAM,cAAc,GAAmB;IACrC,UAAU,EAAE,SAAS;IACrB,aAAa,EAAE,SAAS;IACxB,qBAAqB,EAAE,SAAS;CACjC,CAAC;AACF,iFAAiF;AACjF,IAAI,aAAa,GAAG,KAAK,CAAC;AA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
+
export declare const LSP_MEM_CMD: {
|
|
3
|
+
readonly start: string;
|
|
4
|
+
readonly snapshot: string;
|
|
5
|
+
readonly diff: string;
|
|
6
|
+
readonly references: string;
|
|
7
|
+
readonly objectsByType: string;
|
|
8
|
+
readonly gcCollect: string;
|
|
9
|
+
readonly ingest: string;
|
|
10
|
+
readonly stop: string;
|
|
11
|
+
};
|
|
12
|
+
/** The tracemalloc traceback depth injected at start. */
|
|
13
|
+
export declare const TRACEBACK_DEPTH = 25;
|
|
14
|
+
/** The progress title of a memory start; a function so it follows the installed brand. */
|
|
15
|
+
export declare function memStartTitle(): string;
|
|
16
|
+
/** [PROF-UI-STATE] Progress-notification titles, one per memory operation. */
|
|
17
|
+
export declare function memOpTitle(command: string): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRACEBACK_DEPTH = exports.LSP_MEM_CMD = void 0;
|
|
4
|
+
exports.memStartTitle = memStartTitle;
|
|
5
|
+
exports.memOpTitle = memOpTitle;
|
|
6
|
+
// Implements [PROF-UI-MEMORY] + [PROF-UI-AUTOPILOT]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
7
|
+
const ids_1 = require("./ids");
|
|
8
|
+
/** The `<prefix>.lspProfiler.memory.*` LSP command names (one round-trip leg each). */
|
|
9
|
+
exports.LSP_MEM_CMD = (0, ids_1.lspTable)({
|
|
10
|
+
start: "memory.start",
|
|
11
|
+
snapshot: "memory.snapshot",
|
|
12
|
+
diff: "memory.diff",
|
|
13
|
+
references: "memory.references",
|
|
14
|
+
objectsByType: "memory.objectsByType",
|
|
15
|
+
gcCollect: "memory.gcCollect",
|
|
16
|
+
ingest: "memory.ingest",
|
|
17
|
+
stop: "memory.stop",
|
|
18
|
+
});
|
|
19
|
+
/** The tracemalloc traceback depth injected at start. */
|
|
20
|
+
exports.TRACEBACK_DEPTH = 25;
|
|
21
|
+
/** The progress title of a memory start; a function so it follows the installed brand. */
|
|
22
|
+
function memStartTitle() {
|
|
23
|
+
return `${(0, ids_1.brand)()}: Starting memory tracking`;
|
|
24
|
+
}
|
|
25
|
+
/** [PROF-UI-STATE] Progress-notification titles, one per memory operation. */
|
|
26
|
+
function memOpTitle(command) {
|
|
27
|
+
switch (command) {
|
|
28
|
+
case exports.LSP_MEM_CMD.snapshot: {
|
|
29
|
+
return `${(0, ids_1.brand)()}: Taking memory snapshot`;
|
|
30
|
+
}
|
|
31
|
+
case exports.LSP_MEM_CMD.diff: {
|
|
32
|
+
return `${(0, ids_1.brand)()}: Comparing memory snapshots`;
|
|
33
|
+
}
|
|
34
|
+
case exports.LSP_MEM_CMD.gcCollect: {
|
|
35
|
+
return `${(0, ids_1.brand)()}: Forcing garbage collection`;
|
|
36
|
+
}
|
|
37
|
+
case exports.LSP_MEM_CMD.references: {
|
|
38
|
+
return `${(0, ids_1.brand)()}: Building the reference graph`;
|
|
39
|
+
}
|
|
40
|
+
default: {
|
|
41
|
+
return `${(0, ids_1.brand)()}: Inspecting memory`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=memory-capture-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-capture-ids.js","sourceRoot":"","sources":["../../src/memory-capture-ids.ts"],"names":[],"mappings":";;;;;AAAA,yFAAyF;AACzF,+BAAwC;AAExC,uFAAuF;AAC1E,QAAA,WAAW,GAAG,IAAA,cAAQ,EAAC;IAClC,KAAK,EAAE,cAAc;IACrB,QAAQ,EAAE,iBAAiB;IAC3B,IAAI,EAAE,aAAa;IACnB,UAAU,EAAE,mBAAmB;IAC/B,aAAa,EAAE,sBAAsB;IACrC,SAAS,EAAE,kBAAkB;IAC7B,MAAM,EAAE,eAAe;IACvB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC;AAEH,yDAAyD;AAC5C,QAAA,eAAe,GAAG,EAAE,CAAC;AAElC,0FAA0F;AAC1F;IACE,OAAO,GAAG,IAAA,WAAK,GAAE,4BAA4B,CAAC;AAChD,CAAC;AAED,8EAA8E;AAC9E,oBAA2B,OAAe;IACxC,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,QAAA,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC1B,OAAO,GAAG,IAAA,WAAK,GAAE,0BAA0B,CAAC;QAC9C,CAAC;QACD,KAAK,QAAA,WAAW,CAAC,IAAI,EAAE,CAAC;YACtB,OAAO,GAAG,IAAA,WAAK,GAAE,8BAA8B,CAAC;QAClD,CAAC;QACD,KAAK,QAAA,WAAW,CAAC,SAAS,EAAE,CAAC;YAC3B,OAAO,GAAG,IAAA,WAAK,GAAE,8BAA8B,CAAC;QAClD,CAAC;QACD,KAAK,QAAA,WAAW,CAAC,UAAU,EAAE,CAAC;YAC5B,OAAO,GAAG,IAAA,WAAK,GAAE,gCAAgC,CAAC;QACpD,CAAC;QACD,SAAS,CAAC;YACR,OAAO,GAAG,IAAA,WAAK,GAAE,qBAAqB,CAAC;QACzC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MemoryIngestResult } from "./memory-dashboard-mapping";
|
|
2
|
+
import type { LspClient } from "./memory-capture-types";
|
|
3
|
+
/** Post a script's raw output to `<prefix>.lspProfiler.memory.ingest` and read the structured result. */
|
|
4
|
+
export declare function ingestOutput(client: LspClient, memorySessionId: string, output: string): Promise<MemoryIngestResult | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Read the debuggee's at-exit snapshot payload, deleting the file once it is read
|
|
7
|
+
* intact ([PROF-PY-MEMORY-FINAL]). The debuggee writes atomically (sibling temp +
|
|
8
|
+
* `os.replace`), so a readable marker-bearing file is whole. A short poll covers
|
|
9
|
+
* the terminate-event/flush race. The file is unlinked ONLY once a complete
|
|
10
|
+
* (marker-bearing) payload is read — a missing or marker-less read is never
|
|
11
|
+
* destructive. Returns null when no usable payload arrived by the deadline.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readFinalSnapshot(path: string): Promise<string | null>;
|
|
14
|
+
/** Read a `currentMemory` figure off an ingest result (for logging/summaries). */
|
|
15
|
+
export declare function snapshotCurrentMemory(result: MemoryIngestResult): number;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ingestOutput = ingestOutput;
|
|
37
|
+
exports.readFinalSnapshot = readFinalSnapshot;
|
|
38
|
+
exports.snapshotCurrentMemory = snapshotCurrentMemory;
|
|
39
|
+
// Implements [PROF-UI-MEMORY] + [PROF-UI-AUTOPILOT]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
40
|
+
const fs = __importStar(require("node:fs"));
|
|
41
|
+
const server_command_1 = require("./server-command");
|
|
42
|
+
const wire_adapters_1 = require("./wire-adapters");
|
|
43
|
+
const memory_dashboard_mapping_1 = require("./memory-dashboard-mapping");
|
|
44
|
+
const memory_capture_ids_1 = require("./memory-capture-ids");
|
|
45
|
+
const timeouts_1 = require("./timeouts");
|
|
46
|
+
/** [PROF-PY-MEMORY-FINAL] How long to wait for the at-exit snapshot file after the
|
|
47
|
+
* program exits (covers the terminate-event/final-flush race), and the poll
|
|
48
|
+
* cadence while waiting. */
|
|
49
|
+
const FINAL_SNAPSHOT_WAIT_MS = 3000;
|
|
50
|
+
const FINAL_SNAPSHOT_POLL_MS = 100;
|
|
51
|
+
/** Post a script's raw output to `<prefix>.lspProfiler.memory.ingest` and read the structured result. */
|
|
52
|
+
async function ingestOutput(client, memorySessionId, output) {
|
|
53
|
+
const result = await (0, server_command_1.executeServerCommand)(client, memory_capture_ids_1.LSP_MEM_CMD.ingest, { memory_session_id: memorySessionId, output });
|
|
54
|
+
return result === undefined ? null : (0, wire_adapters_1.toMemoryIngestResult)(result);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read the debuggee's at-exit snapshot payload, deleting the file once it is read
|
|
58
|
+
* intact ([PROF-PY-MEMORY-FINAL]). The debuggee writes atomically (sibling temp +
|
|
59
|
+
* `os.replace`), so a readable marker-bearing file is whole. A short poll covers
|
|
60
|
+
* the terminate-event/flush race. The file is unlinked ONLY once a complete
|
|
61
|
+
* (marker-bearing) payload is read — a missing or marker-less read is never
|
|
62
|
+
* destructive. Returns null when no usable payload arrived by the deadline.
|
|
63
|
+
*/
|
|
64
|
+
async function readFinalSnapshot(path) {
|
|
65
|
+
return readFinalSnapshotUntil(path, Date.now() + FINAL_SNAPSHOT_WAIT_MS);
|
|
66
|
+
}
|
|
67
|
+
/** Poll for the at-exit snapshot until it lands or the deadline passes. */
|
|
68
|
+
async function readFinalSnapshotUntil(path, deadline) {
|
|
69
|
+
const contents = await fs.promises.readFile(path, "utf8").catch(() => null);
|
|
70
|
+
if (contents?.includes("__LSPPROF_MEM__") === true) {
|
|
71
|
+
await fs.promises.unlink(path).catch(() => null);
|
|
72
|
+
return contents;
|
|
73
|
+
}
|
|
74
|
+
if (Date.now() >= deadline) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
await (0, timeouts_1.delay)(FINAL_SNAPSHOT_POLL_MS);
|
|
78
|
+
return readFinalSnapshotUntil(path, deadline);
|
|
79
|
+
}
|
|
80
|
+
/** Read a `currentMemory` figure off an ingest result (for logging/summaries). */
|
|
81
|
+
function snapshotCurrentMemory(result) {
|
|
82
|
+
return (0, memory_dashboard_mapping_1.asNumber)(result.currentMemory);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=memory-capture-ingest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-capture-ingest.js","sourceRoot":"","sources":["../../src/memory-capture-ingest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yFAAyF;AACzF,MAAY,EAAE,oCAAgB;AAC9B,qDAAwD;AACxD,mDAAuD;AAGvD,yEAAsD;AACtD,6DAAmD;AAEnD,yCAAmC;AAEnC;;6BAE6B;AAC7B,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,yGAAyG;AAClG,KAAK,uBAAuB,MAAiB,EAAE,eAA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
|
|
1
|
+
import type { MemoryIngestResult } from "./memory-dashboard-mapping";
|
|
2
|
+
import type { ActiveMemorySession, MemoryOperation } from "./memory-capture-types";
|
|
3
|
+
/** Leg 1: ask for the operation's step; a completed step is the result, a courier step runs in the debuggee. */
|
|
4
|
+
export declare function requestStep(op: MemoryOperation, active: ActiveMemorySession): Promise<MemoryIngestResult | null>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestStep = requestStep;
|
|
4
|
+
// Implements [PROF-UI-MEMORY]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
5
|
+
const ids_1 = require("./ids");
|
|
6
|
+
const dap_evaluate_1 = require("./dap-evaluate");
|
|
7
|
+
const server_command_1 = require("./server-command");
|
|
8
|
+
const wire_adapters_1 = require("./wire-adapters");
|
|
9
|
+
const memory_capture_types_1 = require("./memory-capture-types");
|
|
10
|
+
const memory_capture_ingest_1 = require("./memory-capture-ingest");
|
|
11
|
+
/** Leg 1: ask for the operation's step; a completed step is the result, a courier step runs in the debuggee. */
|
|
12
|
+
async function requestStep(op, active) {
|
|
13
|
+
op.report("Asking the profiler…");
|
|
14
|
+
const step = await (0, server_command_1.executeServerCommand)(active.client, op.command, { memory_session_id: active.memorySessionId, ...op.extraArgs });
|
|
15
|
+
if (step === undefined) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (step.kind === "Completed") {
|
|
19
|
+
return (0, wire_adapters_1.toMemoryIngestResult)(step.result);
|
|
20
|
+
}
|
|
21
|
+
return courierStep(op, active, step.script);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A courier step ([PROF-MEMORY-MODE]): the runtime cannot read its own heap,
|
|
25
|
+
* so the script runs inside the paused debuggee and its output is posted back.
|
|
26
|
+
*/
|
|
27
|
+
async function courierStep(op, active, script) {
|
|
28
|
+
op.report("Pausing the program…");
|
|
29
|
+
const acquired = await (0, dap_evaluate_1.acquireStoppedFrame)();
|
|
30
|
+
if (acquired === null) {
|
|
31
|
+
(0, memory_capture_types_1.warnUnlessQuiet)(op, `${(0, ids_1.brand)()}: Could not pause the program for memory inspection — pause at a breakpoint and retry.`);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return await evaluateAndIngest(op, { ...active, frameId: acquired.frameId }, script);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await acquired.release();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Leg 2: run the script in the frame, then post the output to ingest. */
|
|
42
|
+
async function evaluateAndIngest(op, ctx, script) {
|
|
43
|
+
if (script === "") {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
op.report("Inspecting the debuggee…");
|
|
47
|
+
const output = await (0, dap_evaluate_1.evaluateInDebugSession)(script, ctx.frameId);
|
|
48
|
+
if (output === null) {
|
|
49
|
+
(0, memory_capture_types_1.warnUnlessQuiet)(op, `${(0, ids_1.brand)()}: Could not run the memory script in the debuggee.`);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
op.report("Analyzing…");
|
|
53
|
+
return (0, memory_capture_ingest_1.ingestOutput)(ctx.client, ctx.memorySessionId, output);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=memory-capture-legs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-capture-legs.js","sourceRoot":"","sources":["../../src/memory-capture-legs.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,+BAA8B;AAC9B,iDAA6E;AAC7E,qDAAwD;AACxD,mDAAuD;AAIvD,iEAAyD;AACzD,mEAAuD;AAEvD,gHAAgH;AACzG,KAAK,sBAAsB,EAAmB,EAAE,MAA2B;IAChF,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,IAAA,qCAAoB,EAAa,MAAM,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AM,GAAG,MAAM,IAAA,qCAAsB,EAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACjE,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,IAAA,sCAAe,EAAC,EAAE,EAAE,GAAG,IAAA,WAAK,GAAE,oDAAoD,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACxB,OAAO,IAAA,oCAAY,EAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ProfilerStore as Store } from "./store";
|
|
2
|
+
import type { MemoryDiffResult } from "./memory-decorations";
|
|
3
|
+
import type { MemoryIngestResult } from "./memory-dashboard-mapping";
|
|
4
|
+
/**
|
|
5
|
+
* Land a snapshot result: paint the allocation track, append a timeline
|
|
6
|
+
* point, and retain it for a later "Compare". With `openResultsView` (the
|
|
7
|
+
* manual "Take Memory Snapshot" affordance), open the memory dashboard
|
|
8
|
+
* — the raw V8 `.heapprofile` stays one click away on its own button
|
|
9
|
+
* ([PROF-CPU-START]). Without it (the autopilot's quiet per-pass capture) only
|
|
10
|
+
* the decorations + timeline update — the diff step surfaces the dashboard.
|
|
11
|
+
*/
|
|
12
|
+
export declare function presentSnapshot(result: MemoryIngestResult, options: {
|
|
13
|
+
openResultsView: boolean;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Land a diff result: paint the leak decorations (confidence-coloured) and refresh
|
|
17
|
+
* the dashboard with the leak analysis alongside the last snapshot. Returns the
|
|
18
|
+
* typed diff so callers (the autopilot) can read suspected-leak confidence.
|
|
19
|
+
*/
|
|
20
|
+
export declare function presentDiff(result: MemoryIngestResult): Promise<MemoryDiffResult>;
|
|
21
|
+
/** The result of one combined autopilot capture. */
|
|
22
|
+
export interface CaptureResult {
|
|
23
|
+
readonly snapshot: MemoryIngestResult | null;
|
|
24
|
+
readonly diff: MemoryDiffResult | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The autopilot's combined capture: a snapshot then a diff, presented quietly
|
|
28
|
+
* (decorations + dashboard + timeline, no new `.heapprofile` tab on each pass).
|
|
29
|
+
* Brackets the whole pair as one in-flight op so the transparent pauses it may
|
|
30
|
+
* perform never trigger a second auto-capture ([PROF-UI-AUTOPILOT]).
|
|
31
|
+
*/
|
|
32
|
+
export declare function captureSnapshotAndDiff(store: Store, report: (message: string) => void): Promise<CaptureResult>;
|