Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

Runtime tracing, flight recording - #3627

Closed
Jake Bailey (jakebailey) wants to merge 13 commits into
mainfrom
jabaile/go-runtime-trace
Closed

Jake Bailey (jakebailey) wants to merge 13 commits into
mainfrom
jabaile/go-runtime-trace

Conversation

@jakebailey

Copy link
Copy Markdown
Member

This adds Go runtime/trace support, including flight recording. Traces are integrated into the VS Code extension, similarly to pprof profiling.

I've added trace points in various places, and plumbed context around a bit.

Copilot AI review requested due to automatic review settings April 27, 2026 21:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Go runtime/trace integration (including a flight recorder) to tsgo, and wires capture/control into the LSP + the preview VS Code extension to make runtime tracing accessible similarly to existing pprof tooling.

Changes:

  • Introduces internal/runtimetrace to manage process-lifetime runtime tracing and flight-recorder snapshots (env-driven + SIGUSR1 on Unix).
  • Plumbs context.Context through checker/program APIs and adds trace regions/log events across compiler, parser, resolver, project system, and LSP request handling.
  • Adds new LSP custom requests + VS Code extension commands to start/snapshot/stop the flight recorder.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
internal/transformers/tstransforms/importelision_test.go Updates test program stub + checker creation to pass context.Context.
internal/testrunner/compiler_runner.go Passes t.Context() into ForEachCheckerParallel for tracing-friendly APIs.
internal/runtimetrace/runtimetrace.go New session management for runtime trace + flight recorder via env vars, snapshot-on-stop, Unix signal hook.
internal/runtimetrace/recorder.go New FlightRecorder wrapper around runtime/trace flight recorder APIs (start/snapshot/stop).
internal/runtimetrace/api.go New helpers for trace regions/tasks and safe/unsafe logging conventions.
internal/runtimetrace/signal_unix.go Unix SIGUSR1 handler to trigger a flight snapshot.
internal/runtimetrace/signal_other.go Non-Unix no-op signal handler implementation.
internal/project/snapshot.go Adds trace region around snapshot cloning.
internal/project/session.go Adds trace region around snapshot updates.
internal/project/project.go Adapts program binding call to new context-aware BindSourceFiles.
internal/project/checkerpool.go Threads ctx into checker creation in the project checker pool.
internal/parser/parser.go Adds trace region + trace log events to parsing entrypoint.
internal/module/resolver.go Adds trace region + trace log events to module resolution entrypoint.
internal/lsp/server.go Adds per-request trace tasks/logging and new handlers for flight recorder control.
internal/lsp/lsproto/lsp_generated.go Generated protocol additions for flight recorder requests/params/results.
internal/lsp/lsproto/_generate/generate.mts Adds generator specs for flight recorder protocol structures/requests.
internal/ls/autoimport/util.go Makes checker pool acquisition context-aware and threads ctx into checker creation.
internal/ls/autoimport/registry.go Updates checker creation/usage to pass ctx and handle canceled acquisition.
internal/ls/autoimport/aliasresolver.go Updates BindSourceFiles signature for ctx-aware checker.Program.
internal/execute/tsc.go Adds trace regions around compilation entrypoints.
internal/compiler/program.go Adds trace regions/logging in binding/diagnostics/emit, and threads ctx through checker pool APIs.
internal/compiler/fileloader.go Adds trace region around program file processing.
internal/compiler/emitter.go Adds trace region/logging for emit and adds additional transformer regions.
internal/compiler/checkerpool.go Threads ctx into checker creation and adds trace region/logging around checker pool init.
internal/checker/checker_test.go Updates tests/bench to new ctx-aware BindSourceFiles/NewChecker.
internal/checker/checker.go Makes Program.BindSourceFiles ctx-aware and adds trace regions/logging in checker creation + file checking.
cmd/tsgo/main.go Starts/stops runtime tracing session for the tsgo process lifetime.
_extension/src/session.ts Adds VS Code commands for start/snapshot/stop flight recorder and context key wiring.
_extension/src/client.ts Adds client methods to call new custom LSP flight recorder requests.
_extension/package.json Registers new extension commands and enablement conditions.
.golangci.yml Updates depguard rules to forbid direct runtime/trace usage outside internal/runtimetrace and adjusts linter exclusions.

Comment thread internal/lsp/server.go Resolved
Comment thread internal/runtimetrace/runtimetrace.go Resolved
Comment thread internal/runtimetrace/runtimetrace.go Resolved
Comment thread internal/compiler/emitter.go Resolved
Comment thread internal/ls/autoimport/util.go Resolved
@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) added the No linked issue This PR doesn't say what bug it fixes label Jun 8, 2026
@jakebailey

Copy link
Copy Markdown
Member Author

This is not going to happen before the repo move, closing an will do another day.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

No linked issue This PR doesn't say what bug it fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants