@nimblesite/lsp-profiler-ui 0.0.0-stage → 0.0.1
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,366 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Implements [PROF-UI]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
3
|
+
/**
|
|
4
|
+
* CPU profile results webview for the profiler.
|
|
5
|
+
*
|
|
6
|
+
* Owns the results panel end to end: the interactive flame graph hero (the
|
|
7
|
+
* inferno SVG the LSP exports on every stop, [PROF-EXPORT-FLAMEGRAPH]), summary
|
|
8
|
+
* cards, hot function/line tables with click-to-source navigation, and the
|
|
9
|
+
* result-landing flow that never dead-ends the user (#145): the panel is the
|
|
10
|
+
* primary view on stop, with the raw V8 trace one click away.
|
|
11
|
+
*
|
|
12
|
+
* Panel lifecycle, CSP, and safe data embedding come from the shared webview
|
|
13
|
+
* host ([PROF-UI-WEBVIEW], profiler-webview.ts).
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.loadFlamegraphSvgDataUri = void 0;
|
|
50
|
+
exports.profileHasNoUsableData = profileHasNoUsableData;
|
|
51
|
+
exports.presentProfileResult = presentProfileResult;
|
|
52
|
+
exports.handleFlamegraphMessage = handleFlamegraphMessage;
|
|
53
|
+
exports.openFlamegraphWebview = openFlamegraphWebview;
|
|
54
|
+
exports.flamegraphPanelState = flamegraphPanelState;
|
|
55
|
+
exports.flamegraphPanelOpen = flamegraphPanelOpen;
|
|
56
|
+
exports.disposeFlamegraphPanel = disposeFlamegraphPanel;
|
|
57
|
+
exports.buildFlamegraphHtml = buildFlamegraphHtml;
|
|
58
|
+
const sampled_view_1 = require("./sampled-view");
|
|
59
|
+
const flamegraph_artifact_1 = require("./flamegraph-artifact");
|
|
60
|
+
const ids_1 = require("./ids");
|
|
61
|
+
const vscode = __importStar(require("vscode"));
|
|
62
|
+
const logger_1 = require("./logger");
|
|
63
|
+
const failure_1 = require("./failure");
|
|
64
|
+
const trace_actions_1 = require("./trace-actions");
|
|
65
|
+
const profiler_styles_1 = require("./profiler-styles");
|
|
66
|
+
const profiler_webview_1 = require("./profiler-webview");
|
|
67
|
+
var flamegraph_artifact_2 = require("./flamegraph-artifact");
|
|
68
|
+
Object.defineProperty(exports, "loadFlamegraphSvgDataUri", { enumerable: true, get: function () { return flamegraph_artifact_2.loadFlamegraphSvgDataUri; } });
|
|
69
|
+
// Implements [PROF-CPU-START]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
70
|
+
// ── Result presentation (#145) ─────────────────────────────────────────────
|
|
71
|
+
/** Completion-toast actions that always reach a working view (#145). */
|
|
72
|
+
const OPEN_NATIVE_TRACE = "Open Trace in VS Code Viewer";
|
|
73
|
+
const REVEAL_TRACE = "Reveal Trace File";
|
|
74
|
+
// Implements [PROF-CPU-START]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
75
|
+
/**
|
|
76
|
+
* Whether a completed profile has nothing worth showing — no hot functions and
|
|
77
|
+
* no hot lines (#145).
|
|
78
|
+
*
|
|
79
|
+
* Raw sample count is the wrong signal: a sub-tick program (e.g.
|
|
80
|
+
* `debug_demo.py` ≈ 1 ms) finishes before its work can be sampled, yet the
|
|
81
|
+
* session keeps sampling the idle/exiting interpreter — so the result can carry
|
|
82
|
+
* dozens of samples that resolve to zero user-code attribution. A sampling
|
|
83
|
+
* profiler at 100 Hz cannot fix this by raising the rate; deterministic
|
|
84
|
+
* profiling can (Phase 2). When there is no attribution, say so honestly instead
|
|
85
|
+
* of presenting an empty flame chart/heat map as a result.
|
|
86
|
+
*/
|
|
87
|
+
function profileHasNoUsableData(result) {
|
|
88
|
+
return result.hotFunctions.length === 0 && result.hotLines.length === 0;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Land a completed CPU profile on a viewable result ([PROF-CPU-START], #145).
|
|
92
|
+
*
|
|
93
|
+
* The self-contained results panel (summary cards, flame graph hero, navigable
|
|
94
|
+
* hot-function/line tables) opens immediately as the primary view: it always
|
|
95
|
+
* renders, while VS Code's built-in `.cpuprofile` viewer lands on a raw
|
|
96
|
+
* self/total-time table that reads as a wall of numbers until the user finds
|
|
97
|
+
* its flame icon. The native trace stays one deliberate click away — the
|
|
98
|
+
* completion toast's "Open Trace in VS Code Viewer" action, the panel's own
|
|
99
|
+
* button, or the `${brand()}: Show Profile Results` re-entry command — so the
|
|
100
|
+
* user is never stranded and never dumped somewhere confusing.
|
|
101
|
+
*/
|
|
102
|
+
async function presentProfileResult(result) {
|
|
103
|
+
if (profileHasNoUsableData(result)) {
|
|
104
|
+
presentNoUsableData(result);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
await openFlamegraphWebview(result);
|
|
108
|
+
logger_1.Logger.info(`Profiling stopped: ${String(result.totalSamples)} samples, ${result.duration.toFixed(1)}s, output: ${result.outputFile}`);
|
|
109
|
+
// A failed/refused export is never silent — even when there is still data to
|
|
110
|
+
// show, surface why an artifact is missing ([PROF-EXPORT-VALIDATE]).
|
|
111
|
+
if (result.exportError !== undefined && result.exportError !== "") {
|
|
112
|
+
void vscode.window.showWarningMessage(`${(0, ids_1.brand)()}: Some profile artifacts could not be exported — ${result.exportError}`);
|
|
113
|
+
}
|
|
114
|
+
// Fire-and-forget: a notification carrying action buttons is sticky (VS Code
|
|
115
|
+
// does not auto-dismiss it), so awaiting it would block the stop handler until
|
|
116
|
+
// the user clicks. Its actions open their views when chosen; a rejection is logged.
|
|
117
|
+
void offerProfileResultActionsSafely(result);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A profile with no attribution (#145, [PROF-CPU-START]). Be honest —
|
|
121
|
+
* don't present an empty flame chart/heat map as a real result, and don't
|
|
122
|
+
* promise a "higher sample rate" that provably cannot help a sub-tick run.
|
|
123
|
+
* Fire-and-forget (a notification is sticky if it carries a button, but even
|
|
124
|
+
* plain ones must not block the stop handler).
|
|
125
|
+
*/
|
|
126
|
+
function presentNoUsableData(result) {
|
|
127
|
+
const detail = result.exportError !== undefined && result.exportError !== "" ? ` (${result.exportError})` : "";
|
|
128
|
+
if (result.totalSamples === 0) {
|
|
129
|
+
void vscode.window.showWarningMessage(`${(0, ids_1.brand)()}: Profiling captured no samples — the program finished before sampling began${detail}. ` +
|
|
130
|
+
"Sampling needs a longer-running target; short scripts need precise (deterministic) profiling.");
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
void vscode.window.showWarningMessage(`${(0, ids_1.brand)()}: Captured ${String(result.totalSamples)} sample${result.totalSamples === 1 ? "" : "s"}, but none ` +
|
|
134
|
+
"landed in your code — the program ran its work too briefly to profile by sampling. " +
|
|
135
|
+
"Short scripts need precise (deterministic) profiling.");
|
|
136
|
+
}
|
|
137
|
+
/** Completion toast that always offers a path to the raw trace (#145). */
|
|
138
|
+
async function offerProfileResultActions(result) {
|
|
139
|
+
const choice = await vscode.window.showInformationMessage(`${(0, ids_1.brand)()}: Profile complete — ${String(result.totalSamples)} samples in ${result.duration.toFixed(1)}s`, OPEN_NATIVE_TRACE, REVEAL_TRACE);
|
|
140
|
+
if (choice === OPEN_NATIVE_TRACE) {
|
|
141
|
+
await (0, trace_actions_1.openNativeTraceViewer)(result.cpuProfilePath ?? "", (0, trace_actions_1.traceFileFor)(result));
|
|
142
|
+
}
|
|
143
|
+
else if (choice === REVEAL_TRACE) {
|
|
144
|
+
await (0, trace_actions_1.revealTraceFile)((0, trace_actions_1.traceFileFor)(result));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Offer the completion actions, turning a failed action into a logged warning. */
|
|
148
|
+
async function offerProfileResultActionsSafely(result) {
|
|
149
|
+
try {
|
|
150
|
+
await offerProfileResultActions(result);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
logger_1.Logger.warn(`Profile completion action failed: ${(0, failure_1.errorText)(error)}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// ── Webview panel ─────────────────────────────────────────────────────────
|
|
157
|
+
/** Route a message posted from the results webview; a host that keeps its own results panel routes through it too. */
|
|
158
|
+
function handleFlamegraphMessage(msg) {
|
|
159
|
+
if ((0, profiler_webview_1.handleSourceNavigation)(msg.type === "select" ? { ...msg, type: "navigateToSource" } : msg)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const file = msg.file ?? "";
|
|
163
|
+
if (file === "") {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (msg.type === "openSpeedscope") {
|
|
167
|
+
void (0, trace_actions_1.openSpeedscopeImport)(file);
|
|
168
|
+
}
|
|
169
|
+
else if (msg.type === "openCpuProfile") {
|
|
170
|
+
// The panel's "Open Trace in VS Code Viewer" button — the on-demand path to
|
|
171
|
+
// the built-in `.cpuprofile` table view ([PROF-CPU-START]).
|
|
172
|
+
void (0, trace_actions_1.openNativeTraceViewer)(file, file);
|
|
173
|
+
}
|
|
174
|
+
else if (msg.type === "openFlamegraphSvg") {
|
|
175
|
+
// The inferno SVG carries its own zoom/search interactivity, which the
|
|
176
|
+
// CSP-locked webview intentionally does not run — open it externally where
|
|
177
|
+
// its script works ([PROF-EXPORT-FLAMEGRAPH]).
|
|
178
|
+
void vscode.env.openExternal(vscode.Uri.file(file));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const flamegraphPanel = new profiler_webview_1.SingletonWebviewPanel(() => (0, ids_1.cmd)("flamegraph"), handleFlamegraphMessage);
|
|
182
|
+
/** Open (or reveal) the profile results panel beside the source. */
|
|
183
|
+
async function openFlamegraphWebview(result) {
|
|
184
|
+
flamegraphPanel.show(`${(0, ids_1.brand)()} Profiler`, await buildFlamegraphHtml(result));
|
|
185
|
+
}
|
|
186
|
+
/** The open results panel's view type, title and HTML (e2e seam). */
|
|
187
|
+
function flamegraphPanelState() {
|
|
188
|
+
const described = flamegraphPanel.describe();
|
|
189
|
+
return described === undefined ? undefined : { ...described, html: flamegraphPanel.html() ?? "" };
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Test seam: is the self-contained results panel currently open? Lets the
|
|
193
|
+
* run→profile→view e2e assert the user reaches a working flame chart rather
|
|
194
|
+
* than dead-ending on the built-in viewer's error ([PROF-CPU-START]).
|
|
195
|
+
*/
|
|
196
|
+
function flamegraphPanelOpen() {
|
|
197
|
+
return flamegraphPanel.isOpen();
|
|
198
|
+
}
|
|
199
|
+
/** Close and forget the panel (extension teardown). */
|
|
200
|
+
function disposeFlamegraphPanel() {
|
|
201
|
+
flamegraphPanel.dispose();
|
|
202
|
+
}
|
|
203
|
+
// ── Document assembly ─────────────────────────────────────────────────────
|
|
204
|
+
/** The results panel's layout: fixed-width tables, the sampled view's accents, narrow panels and reduced motion. */
|
|
205
|
+
const FLAMEGRAPH_LAYOUT_CSS = `
|
|
206
|
+
body { padding: 20px; }
|
|
207
|
+
.summary-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 720px; }
|
|
208
|
+
.card { min-width: 0; padding: 12px; }
|
|
209
|
+
.data-table { table-layout: fixed; }
|
|
210
|
+
.data-table td, .data-table th { overflow-wrap: anywhere; }
|
|
211
|
+
.data-table th:first-child { width: 27%; }
|
|
212
|
+
.data-table th:nth-child(2) { width: 37%; }
|
|
213
|
+
.data-table .bar-cell { width: auto; overflow: hidden; }
|
|
214
|
+
.bar { max-width: 100%; }
|
|
215
|
+
.toggle.active { background: var(--prof-hot); color: var(--prof-hot-ink); }
|
|
216
|
+
.chip.active { border-color: var(--prof-hot); }
|
|
217
|
+
#search:focus { outline: 1px solid var(--prof-hot); outline-offset: 1px; }
|
|
218
|
+
@media (max-width: 600px) {
|
|
219
|
+
body { padding: 12px; }
|
|
220
|
+
.summary-cards { gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
221
|
+
.data-table td { padding: 7px 4px; font-size: 11px; }
|
|
222
|
+
.data-table th { padding: 6px 4px; font-size: 10px; }
|
|
223
|
+
.data-table th:last-child, .data-table .bar-cell { display: none; }
|
|
224
|
+
}
|
|
225
|
+
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }`;
|
|
226
|
+
/** Flamegraph-specific CSS on top of the shared profiler design system. */
|
|
227
|
+
const FLAMEGRAPH_CSS = `${profiler_styles_1.PROFILER_CSS_VARS}${profiler_styles_1.PROFILER_CSS_RESET}${profiler_styles_1.PROFILER_CSS_HEADING}${profiler_styles_1.PROFILER_CSS_CARDS}${profiler_styles_1.PROFILER_CSS_TABLE}${FLAMEGRAPH_LAYOUT_CSS}
|
|
228
|
+
h1 .accent { color: var(--prof-critical); }
|
|
229
|
+
.data-table .pct { font-weight: 500; min-width: 56px; text-align: right; }
|
|
230
|
+
.bar.critical { background: var(--prof-critical); }
|
|
231
|
+
.bar.hot { background: var(--prof-hot); }
|
|
232
|
+
.bar.warm { background: var(--prof-warm); }
|
|
233
|
+
.bar.cool { background: var(--prof-cool); }
|
|
234
|
+
.file-link { color: var(--prof-text-secondary); font-size: 12px; }
|
|
235
|
+
.file-link:hover { color: var(--prof-text); text-decoration: underline; }
|
|
236
|
+
.flame-hero {
|
|
237
|
+
background: var(--prof-surface); border: 1px solid var(--prof-border);
|
|
238
|
+
border-radius: 8px; padding: 12px; margin-bottom: 8px;
|
|
239
|
+
}
|
|
240
|
+
.flame-hero img { display: block; width: 100%; height: auto; border-radius: 4px; }
|
|
241
|
+
.action-link {
|
|
242
|
+
display: inline-block; margin-top: 12px; padding: 8px 16px;
|
|
243
|
+
background: var(--prof-bg); border: 1px solid var(--prof-border);
|
|
244
|
+
border-radius: 6px; color: var(--prof-text);
|
|
245
|
+
font-size: 13px; cursor: pointer; font-family: inherit;
|
|
246
|
+
}
|
|
247
|
+
.action-link:hover { border-color: var(--prof-critical); color: var(--prof-critical); }
|
|
248
|
+
.action-link + .action-link { margin-left: 8px; }`;
|
|
249
|
+
/** The run's totals, filled in by the script. */
|
|
250
|
+
const SUMMARY_CARDS_HTML = `
|
|
251
|
+
<div class="summary-cards">
|
|
252
|
+
<div class="card"><div class="label">Samples</div><div class="value" id="total-samples">0</div></div>
|
|
253
|
+
<div class="card"><div class="label">Duration</div><div class="value" id="duration">0s</div></div>
|
|
254
|
+
<div class="card"><div class="label">Functions</div><div class="value" id="fn-count">0</div></div>
|
|
255
|
+
<div class="card"><div class="label">Hot Lines</div><div class="value" id="line-count">0</div></div>
|
|
256
|
+
</div>`;
|
|
257
|
+
/** The hot function and hot line tables, and the trace actions under them. */
|
|
258
|
+
const HOT_TABLES_HTML = `
|
|
259
|
+
<h2>Hot Functions</h2>
|
|
260
|
+
<table class="data-table">
|
|
261
|
+
<thead><tr><th>Function</th><th>Location</th><th>Total %</th><th>Self %</th><th></th></tr></thead>
|
|
262
|
+
<tbody id="fn-body"></tbody>
|
|
263
|
+
</table>
|
|
264
|
+
<h2>Hot Lines</h2>
|
|
265
|
+
<table class="data-table">
|
|
266
|
+
<thead><tr><th>Location</th><th>%</th><th>Samples</th><th></th></tr></thead>
|
|
267
|
+
<tbody id="line-body"></tbody>
|
|
268
|
+
</table>
|
|
269
|
+
<div id="trace-actions"></div>`;
|
|
270
|
+
/** Build the body HTML with the flame graph hero, summary cards and tables. */
|
|
271
|
+
function flamegraphBody(svgDataUri, sampledBody = "") {
|
|
272
|
+
return `
|
|
273
|
+
${(0, profiler_styles_1.brandHeading)((0, ids_1.brand)(), "PROFILER")}${SUMMARY_CARDS_HTML}${sampledBody}${(0, flamegraph_artifact_1.flamegraphHeroHtml)(svgDataUri)}${HOT_TABLES_HTML}`;
|
|
274
|
+
}
|
|
275
|
+
/** The result as script constants; profiled-program strings are embedded inert ([PROF-UI-WEBVIEW]). */
|
|
276
|
+
function flamegraphDataScript(result) {
|
|
277
|
+
return `
|
|
278
|
+
const vscode = globalThis.profilerVsCodeApi || (globalThis.profilerVsCodeApi = acquireVsCodeApi());
|
|
279
|
+
const hotFunctions = ${(0, profiler_webview_1.embedJson)(result.hotFunctions)};
|
|
280
|
+
const hotLines = ${(0, profiler_webview_1.embedJson)(result.hotLines)};
|
|
281
|
+
const totalSamples = ${String(result.totalSamples)};
|
|
282
|
+
const duration = ${String(result.duration)};
|
|
283
|
+
const outputFile = ${(0, profiler_webview_1.embedJson)(result.outputFile)};
|
|
284
|
+
const flamegraphFile = ${(0, profiler_webview_1.embedJson)(result.flamegraphPath ?? "")};
|
|
285
|
+
const cpuProfileFile = ${(0, profiler_webview_1.embedJson)(result.cpuProfilePath ?? "")};`;
|
|
286
|
+
}
|
|
287
|
+
/** The summary cards, the hero's open button and the heat classes the tables use. */
|
|
288
|
+
const SUMMARY_SCRIPT = `
|
|
289
|
+
document.getElementById('total-samples').textContent = String(totalSamples);
|
|
290
|
+
document.getElementById('duration').textContent = duration < 1 ? (duration * 1000).toFixed(0) + 'ms' : duration < 60 ? duration.toFixed(1) + 's' : (duration / 60).toFixed(1) + 'm';
|
|
291
|
+
document.getElementById('fn-count').textContent = String(hotFunctions.length);
|
|
292
|
+
document.getElementById('line-count').textContent = String(hotLines.length);
|
|
293
|
+
const openSvgButton = document.getElementById('open-flame-svg');
|
|
294
|
+
if (openSvgButton) {
|
|
295
|
+
openSvgButton.onclick = () => vscode.postMessage({ type: 'openFlamegraphSvg', file: flamegraphFile });
|
|
296
|
+
}
|
|
297
|
+
function heatClass(pct) {
|
|
298
|
+
if (pct >= 20) return 'critical';
|
|
299
|
+
if (pct >= 10) return 'hot';
|
|
300
|
+
if (pct >= 5) return 'warm';
|
|
301
|
+
return 'cool';
|
|
302
|
+
}`;
|
|
303
|
+
/** The hot function and hot line rows, each navigating to its source. */
|
|
304
|
+
const TABLES_SCRIPT = `
|
|
305
|
+
const fnBody = document.getElementById('fn-body');
|
|
306
|
+
for (const fn of hotFunctions) {
|
|
307
|
+
const tr = document.createElement('tr');
|
|
308
|
+
// A frame the runtime could not place (a framework method) has no file: it
|
|
309
|
+
// is listed by name, with no link to nowhere.
|
|
310
|
+
const placed = fn.file !== undefined;
|
|
311
|
+
if (placed) {
|
|
312
|
+
tr.onclick = () => vscode.postMessage({ type: 'navigateToSource', file: fn.file, line: fn.line });
|
|
313
|
+
}
|
|
314
|
+
// fn.name/fn.file come from the profiled (possibly third-party) program —
|
|
315
|
+
// escape before innerHTML. This also renders synthetic frames like
|
|
316
|
+
// <module>/<lambda> literally instead of as broken HTML elements.
|
|
317
|
+
tr.innerHTML = [
|
|
318
|
+
'<td>' + escapeHtml(fn.name) + '</td>',
|
|
319
|
+
placed ? '<td class="file-link">' + escapeHtml(basename(fn.file)) + ':' + fn.line + '</td>' : '<td></td>',
|
|
320
|
+
'<td class="pct">' + fn.percentage.toFixed(1) + '%</td>',
|
|
321
|
+
'<td class="pct">' + fn.selfPercentage.toFixed(1) + '%</td>',
|
|
322
|
+
'<td class="bar-cell"><div class="bar ' + heatClass(fn.percentage) + '" style="width:' + Math.max(4, fn.percentage * 2) + 'px"></div></td>',
|
|
323
|
+
].join('');
|
|
324
|
+
fnBody.appendChild(tr);
|
|
325
|
+
}
|
|
326
|
+
const lineBody = document.getElementById('line-body');
|
|
327
|
+
for (const line of hotLines) {
|
|
328
|
+
const tr = document.createElement('tr');
|
|
329
|
+
tr.onclick = () => vscode.postMessage({ type: 'navigateToSource', file: line.file, line: line.line });
|
|
330
|
+
tr.innerHTML = [
|
|
331
|
+
'<td class="file-link">' + escapeHtml(basename(line.file)) + ':' + line.line + '</td>',
|
|
332
|
+
'<td class="pct">' + line.percentage.toFixed(1) + '%</td>',
|
|
333
|
+
'<td>' + line.samples + '</td>',
|
|
334
|
+
'<td class="bar-cell"><div class="bar ' + heatClass(line.percentage) + '" style="width:' + Math.max(4, line.percentage * 2) + 'px"></div></td>',
|
|
335
|
+
].join('');
|
|
336
|
+
lineBody.appendChild(tr);
|
|
337
|
+
}`;
|
|
338
|
+
/** The raw trace and speedscope buttons, offered only for artifacts that exist. */
|
|
339
|
+
const TRACE_ACTIONS_SCRIPT = `
|
|
340
|
+
const section = document.getElementById('trace-actions');
|
|
341
|
+
function traceAction(label, title, type, file) {
|
|
342
|
+
const button = document.createElement('button');
|
|
343
|
+
button.className = 'action-link';
|
|
344
|
+
button.textContent = label;
|
|
345
|
+
button.title = title;
|
|
346
|
+
button.onclick = () => { vscode.postMessage({ type, file }); };
|
|
347
|
+
section.appendChild(button);
|
|
348
|
+
}
|
|
349
|
+
if (cpuProfileFile) {
|
|
350
|
+
traceAction('Open Trace in VS Code Viewer', 'Open the raw .cpuprofile in the built-in trace viewer (self/total time table)', 'openCpuProfile', cpuProfileFile);
|
|
351
|
+
}
|
|
352
|
+
if (outputFile) {
|
|
353
|
+
traceAction('Open in Speedscope (external)', 'Open speedscope.app with the profile loaded automatically', 'openSpeedscope', outputFile);
|
|
354
|
+
}`;
|
|
355
|
+
/** Build the complete results-panel HTML for the profiler webview. */
|
|
356
|
+
async function buildFlamegraphHtml(result) {
|
|
357
|
+
const [svgDataUri, view] = await Promise.all([(0, flamegraph_artifact_1.loadFlamegraphSvgDataUri)(result.flamegraphPath), (0, sampled_view_1.sampledView)(result)]);
|
|
358
|
+
const sampled = (0, sampled_view_1.sampledParts)(view);
|
|
359
|
+
return (0, profiler_webview_1.buildWebviewDocument)({
|
|
360
|
+
title: `${(0, ids_1.brand)()} Profiler`,
|
|
361
|
+
css: `${sampled.css}${FLAMEGRAPH_CSS}`,
|
|
362
|
+
body: flamegraphBody(svgDataUri, sampled.body),
|
|
363
|
+
script: `${profiler_styles_1.PROFILER_JS_UTILS}${flamegraphDataScript(result)}${SUMMARY_SCRIPT}${TABLES_SCRIPT}${TRACE_ACTIONS_SCRIPT}${sampled.script}`,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
//# sourceMappingURL=profiler-flamegraph-html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-flamegraph-html.js","sourceRoot":"","sources":["../../src/profiler-flamegraph-html.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAA2D;AAC3D,+DAAqF;AACrF,+BAAmC;AACnC,MAAY,MAAM,mCAAe;AACjC,qCAAkC;AAClC,uCAAsC;AACtC,mDAA6G;AAE7G,uDAQ2B;AAC3B,yDAK4B;AAG5B,6DAAiE;AAAxD,+HAAA,wBAAwB,OAAA;AAEjC,mEAAmE;AACnE,8EAA8E;AAE9E,wEAAwE;AACxE,MAAM,iBAAiB,GAAG,8BAA8B,CAAC;AACzD,MAAM,YAAY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BACrB,IAAA,4BAAS,EAAC,MAAM,CAAC,UAAU,CAAC;6BACxB,IAAA,4BAAS,EAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC;6BACtC,IAAA,4BAAS,EAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC,GAAG,CAAC;AACvE,CAAC;AAED,qFAAqF;AACrF,MAAM,cAAc,GAAG;;;;;;;;;;;;;;MAcjB,CAAC;AAEP,yEAAyE;AACzE,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiChB,CAAC;AAEP,mFAAmF;AACnF,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;MAevB,CAAC;AAEP,sEAAsE;AAC/D,KAAK,8BAA8B,MAAqB;IAC7D,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAA,8CAAwB,EAAC,MAAM,CAAC,cAAc,CAAC,EAAE,IAAA,0BAAW,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACrH,MAAM,OAAO,GAAG,IAAA,2BAAY,EAAC,IAAI,CAAC,CAAC;IACnC,OAAO,IAAA,uCAAoB,EAAC;QAC1B,KAAK,EAAE,GAAG,IAAA,WAAK,GAAE,WAAW;QAC5B,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,cAAc,EAAE;QACtC,IAAI,EAAE,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC;QAC9C,MAAM,EAAE,GAAG,mCAAiB,GAAG,oBAAoB,CAAC,MAAM,CAAC,GAAG,cAAc,GAAG,aAAa,GAAG,oBAAoB,GAAG,OAAO,CAAC,MAAM,EAAE;KACvI,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared formatting for the live profiling readouts (sample count, elapsed
|
|
3
|
+
* time). Used by both the status-bar item (profiler-status.ts) and the Python
|
|
4
|
+
* Processes panel chrome (process-reactivity.ts) so the two surfaces always
|
|
5
|
+
* speak the same numbers — one place to change "12.3K samples (4s)".
|
|
6
|
+
*/
|
|
7
|
+
/** Sample count as `500` or `12.3K`. */
|
|
8
|
+
export declare function formatSampleCount(sampleCount: number): string;
|
|
9
|
+
/** Elapsed profiling time as `4s` or `1.5m`. */
|
|
10
|
+
export declare function formatProfileDuration(seconds: number): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Implements [PROF-UI-STATE]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
3
|
+
/**
|
|
4
|
+
* Shared formatting for the live profiling readouts (sample count, elapsed
|
|
5
|
+
* time). Used by both the status-bar item (profiler-status.ts) and the Python
|
|
6
|
+
* Processes panel chrome (process-reactivity.ts) so the two surfaces always
|
|
7
|
+
* speak the same numbers — one place to change "12.3K samples (4s)".
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.formatSampleCount = formatSampleCount;
|
|
11
|
+
exports.formatProfileDuration = formatProfileDuration;
|
|
12
|
+
/** Seconds per minute — threshold for switching from "Ns" to "N.Mm" display. */
|
|
13
|
+
const SECONDS_PER_MINUTE = 60;
|
|
14
|
+
/** Threshold for switching from a raw count to "N.NK" display. */
|
|
15
|
+
const KILO_THRESHOLD = 1000;
|
|
16
|
+
/** Sample count as `500` or `12.3K`. */
|
|
17
|
+
function formatSampleCount(sampleCount) {
|
|
18
|
+
return sampleCount >= KILO_THRESHOLD
|
|
19
|
+
? `${(sampleCount / KILO_THRESHOLD).toFixed(1)}K`
|
|
20
|
+
: String(sampleCount);
|
|
21
|
+
}
|
|
22
|
+
/** Elapsed profiling time as `4s` or `1.5m`. */
|
|
23
|
+
function formatProfileDuration(seconds) {
|
|
24
|
+
return seconds < SECONDS_PER_MINUTE
|
|
25
|
+
? `${seconds.toFixed(0)}s`
|
|
26
|
+
: `${(seconds / SECONDS_PER_MINUTE).toFixed(1)}m`;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=profiler-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-format.js","sourceRoot":"","sources":["../../src/profiler-format.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE;;;;;GAKG;;;;AAEH,gFAAgF;AAChF,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,kEAAkE;AAClE,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,wCAAwC;AACxC,2BAAkC,WAAmB;IACnD,OAAO,WAAW,IAAI,cAAc;QAClC,CAAC,CAAC,GAAG,CAAC,WAAW,GAAG,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QACjD,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC1B,CAAC;AAED,gDAAgD;AAChD,+BAAsC,OAAe;IACnD,OAAO,OAAO,GAAG,kBAAkB;QACjC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAC1B,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-on-launch and the cooperative in-process sampler injection.
|
|
3
|
+
*/
|
|
4
|
+
import type { ProfilerStore as Store } from "./store";
|
|
5
|
+
/**
|
|
6
|
+
* Tell the user, once, that a profiling launch runs to completion with their
|
|
7
|
+
* breakpoints disabled, or a Run & Profile silently never stops at a breakpoint
|
|
8
|
+
* the gutter still shows armed (ux-6). Only fires when breakpoints are set.
|
|
9
|
+
*/
|
|
10
|
+
export declare function notifyBreakpointsSuppressedForProfiling(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Auto-start for a freshly launched debug session under one progress
|
|
13
|
+
* notification with stage messages; the status bar spins until the live sample
|
|
14
|
+
* counter takes over, so a click is never followed by silence ([PROF-UI-STATE]).
|
|
15
|
+
*/
|
|
16
|
+
export declare function startProfilerOnLaunch(store: Store, debugSessionId: string): Promise<void>;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Implements [PROF-UI-STATE], [PROF-CPU-COOPERATIVE]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
3
|
+
/**
|
|
4
|
+
* Profile-on-launch and the cooperative in-process sampler injection.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.notifyBreakpointsSuppressedForProfiling = notifyBreakpointsSuppressedForProfiling;
|
|
41
|
+
exports.startProfilerOnLaunch = startProfilerOnLaunch;
|
|
42
|
+
const vscode = __importStar(require("vscode"));
|
|
43
|
+
const ids_1 = require("./ids");
|
|
44
|
+
const dap_evaluate_1 = require("./dap-evaluate");
|
|
45
|
+
const failure_1 = require("./failure");
|
|
46
|
+
const progress_ops_1 = require("./progress-ops");
|
|
47
|
+
const profiler_launch_1 = require("./profiler-launch");
|
|
48
|
+
const server_command_1 = require("./server-command");
|
|
49
|
+
const profiler_session_core_1 = require("./profiler-session-core");
|
|
50
|
+
/** Ack printed by the injected cooperative sampler ([PROF-CPU-COOPERATIVE]). */
|
|
51
|
+
const COOPERATIVE_ACK = "__LSPPROF_CPU_ACK__";
|
|
52
|
+
/** Shown once per session: a profiling launch neutralises breakpoints (ux-6). */
|
|
53
|
+
let breakpointSuppressionNoticeShown = false;
|
|
54
|
+
/**
|
|
55
|
+
* Tell the user, once, that a profiling launch runs to completion with their
|
|
56
|
+
* breakpoints disabled, or a Run & Profile silently never stops at a breakpoint
|
|
57
|
+
* the gutter still shows armed (ux-6). Only fires when breakpoints are set.
|
|
58
|
+
*/
|
|
59
|
+
function notifyBreakpointsSuppressedForProfiling() {
|
|
60
|
+
if (breakpointSuppressionNoticeShown || vscode.debug.breakpoints.length === 0) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
breakpointSuppressionNoticeShown = true;
|
|
64
|
+
void vscode.window.showInformationMessage(`${(0, ids_1.brand)()}: Profiling run — your breakpoints are disabled so the program runs to completion. Launch without profiling to debug with breakpoints.`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Auto-start for a freshly launched debug session under one progress
|
|
68
|
+
* notification with stage messages; the status bar spins until the live sample
|
|
69
|
+
* counter takes over, so a click is never followed by silence ([PROF-UI-STATE]).
|
|
70
|
+
*/
|
|
71
|
+
async function startProfilerOnLaunch(store, debugSessionId) {
|
|
72
|
+
store.profilerStarting();
|
|
73
|
+
try {
|
|
74
|
+
await (0, progress_ops_1.withUserProgress)((0, profiler_session_core_1.cpuStartTitle)(), async (report) => {
|
|
75
|
+
// On macOS, task ports are gated behind entitled debuggers, so a runtime that can
|
|
76
|
+
// only be sampled from outside is sampled by its cooperative in-process
|
|
77
|
+
// sampler, injected at the entry pause ([PROF-CPU-COOPERATIVE]). A runtime
|
|
78
|
+
// that samples itself, such as .NET over EventPipe, attaches as anywhere.
|
|
79
|
+
if (process.platform === "darwin" && cpuIsCooperativeEverywhere(store)) {
|
|
80
|
+
await startCooperativeProfileOnLaunch(store, report);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
await attachOnLaunch(store, debugSessionId, report);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
(0, profiler_session_core_1.settleStart)(store);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Wait for the debuggee's PID, which arrives with the DAP `process` event, then attach to it. */
|
|
91
|
+
async function attachOnLaunch(store, debugSessionId, report) {
|
|
92
|
+
report("Waiting for the program to start…");
|
|
93
|
+
const ready = await (0, profiler_launch_1.waitForDebuggeePid)(store, debugSessionId);
|
|
94
|
+
const pid = store.getDebuggeeProcessId(debugSessionId);
|
|
95
|
+
const client = store.client.value;
|
|
96
|
+
const starting = () => store.profiler.value.cpu === "starting";
|
|
97
|
+
if (ready && pid !== undefined && client?.isRunning() === true && starting()) {
|
|
98
|
+
report("Attaching the sampler…");
|
|
99
|
+
await (0, profiler_session_core_1.attachToDebuggee)(store, client, { pid, launching: starting });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** Whether every runtime the server advertises CPU for injects a cooperative sampler. */
|
|
103
|
+
function cpuIsCooperativeEverywhere(store) {
|
|
104
|
+
const runtimes = (store.capabilities.value?.runtimes ?? []).filter((runtime) => runtime.cpu !== undefined);
|
|
105
|
+
return runtimes.length > 0 && runtimes.every((runtime) => runtime.cpu?.cooperative === true);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* CPU profiling for a debug-launched session with no task ports and no
|
|
109
|
+
* elevation prompt: inject the in-process sampler at the `stopOnEntry` pause.
|
|
110
|
+
*/
|
|
111
|
+
async function startCooperativeProfileOnLaunch(store, report) {
|
|
112
|
+
const client = store.client.value;
|
|
113
|
+
if (client?.isRunning() !== true) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
report("Waiting for the program to pause at entry…");
|
|
117
|
+
const frameId = await (0, dap_evaluate_1.waitForStoppedFrame)();
|
|
118
|
+
if (frameId === null) {
|
|
119
|
+
warnCooperativeEntryMissing();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
await injectCooperativeSamplerSafely(store, { client, frameId, report });
|
|
123
|
+
}
|
|
124
|
+
/** Tell the user why the sampler could not be injected. */
|
|
125
|
+
function warnCooperativeEntryMissing() {
|
|
126
|
+
vscode.window.showWarningMessage(`${(0, ids_1.brand)()}: The debuggee did not pause at entry, so the profiler could not be injected.`);
|
|
127
|
+
}
|
|
128
|
+
/** Run the injection and turn a failure into the shared failure report. */
|
|
129
|
+
async function injectCooperativeSamplerSafely(store, context) {
|
|
130
|
+
try {
|
|
131
|
+
await injectCooperativeSampler(store, context);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
(0, failure_1.reportFailure)("Cooperative profile start", error);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Evaluate the sampler script at the entry pause, resume, then adopt its sample stream. */
|
|
138
|
+
async function injectCooperativeSampler(store, context) {
|
|
139
|
+
const requested = await requestCooperativeScript(context);
|
|
140
|
+
if (requested === undefined) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
context.report("Injecting the in-process sampler…");
|
|
144
|
+
const ack = await (0, dap_evaluate_1.evaluateInDebugSession)(requested.script.script, context.frameId);
|
|
145
|
+
await vscode.commands.executeCommand("workbench.action.debug.continue");
|
|
146
|
+
if (ack?.includes(COOPERATIVE_ACK) !== true) {
|
|
147
|
+
vscode.window.showWarningMessage(`${(0, ids_1.brand)()}: Could not inject the in-process CPU sampler.`);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
await startCooperativeStream(store, context, requested);
|
|
151
|
+
}
|
|
152
|
+
/** Ask the server for the injection script, or undefined when it answered without one. */
|
|
153
|
+
async function requestCooperativeScript(context) {
|
|
154
|
+
const sampleRate = (0, profiler_session_core_1.samplerSettings)().sample_rate;
|
|
155
|
+
const script = await (0, server_command_1.executeServerCommand)(context.client, profiler_session_core_1.CPU_CMD.cooperativeScript, { sample_rate: sampleRate });
|
|
156
|
+
return script?.script === undefined ? undefined : { script, sampleRate };
|
|
157
|
+
}
|
|
158
|
+
/** Attach the in-process sample stream and adopt the session it starts. */
|
|
159
|
+
async function startCooperativeStream(store, context, requested) {
|
|
160
|
+
context.report("Starting the sample stream…");
|
|
161
|
+
const raw = await (0, server_command_1.executeServerCommand)(context.client, profiler_session_core_1.CPU_CMD.cooperativeAttach, { sample_file: requested.script.sample_file, sample_rate: requested.sampleRate });
|
|
162
|
+
if (store.profiler.value.cpu === "active") {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
(0, profiler_session_core_1.adoptSession)(store, raw, (result) => `${(0, ids_1.brand)()}: Profiling current file (PID ${String(result.pid)}, in-process sampler)`);
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=profiler-launch-cooperative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-launch-cooperative.js","sourceRoot":"","sources":["../../src/profiler-launch-cooperative.ts"],"names":[],"mappings":";AAAA,0F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AAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for the "profile on launch" flow: deciding whether a freshly
|
|
3
|
+
* started debug session should be auto-profiled, and waiting for the
|
|
4
|
+
* debuggee's PID to land. Stateless — the session flow stays in profiler.ts.
|
|
5
|
+
*/
|
|
6
|
+
import * as vscode from "vscode";
|
|
7
|
+
import type { ProfilerStore as Store } from "./store";
|
|
8
|
+
/**
|
|
9
|
+
* Whether a freshly started debug session should be auto-profiled: either its
|
|
10
|
+
* launch configuration asked for it (`profileOnLaunch: true`, set by the
|
|
11
|
+
* metric-explicit "Run & Profile CPU (Current File)" entry point — #82) or the
|
|
12
|
+
* user enabled the global `<section>.profiler.profileOnLaunch` setting.
|
|
13
|
+
*/
|
|
14
|
+
export declare function shouldProfileOnLaunch(session: Pick<vscode.DebugSession, "type" | "configuration">): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve once the debuggee's PID for `sessionId` is known (captured from the
|
|
17
|
+
* DAP `process` event into the store), or after a bounded wait. Returns whether
|
|
18
|
+
* the PID became available. Used by the "Profile on Launch" auto-attach so it
|
|
19
|
+
* doesn't fire before debugpy reports the process.
|
|
20
|
+
*/
|
|
21
|
+
export declare function waitForDebuggeePid(store: Store, sessionId: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Send a CPU start for a program the debugger just launched. The adapter
|
|
24
|
+
* reports the PID before the program's runtime has opened its diagnostics
|
|
25
|
+
* endpoint, so while `pending()` holds and for up to the startup timeout an
|
|
26
|
+
* `UNSUPPORTED_RUNTIME` refusal means "not yet" and the start is sent again
|
|
27
|
+
* ([PROF-UI-PROCESSES]). Any other error, or the same one later, is final.
|
|
28
|
+
*/
|
|
29
|
+
export declare function startWhenRuntimeReady<Value>(send: () => Promise<Value>, pending: () => boolean): Promise<Value>;
|