Skip to content

Add --debug-address flag for debug and profiling of the LSP#4437

Merged
emcfarlane merged 4 commits intomainfrom
ed/lspProfile
Apr 17, 2026
Merged

Add --debug-address flag for debug and profiling of the LSP#4437
emcfarlane merged 4 commits intomainfrom
ed/lspProfile

Conversation

@emcfarlane
Copy link
Copy Markdown
Contributor

Add --debug-address flag to buf lsp serve that starts a debug HTTP server (similar to gopls's --debug flag). When set, it serves a browsable debug UI with:

  • Server info and build details
  • Memory stats (runtime.MemStats)
  • pprof endpoints (goroutines, heap, allocs, block, mutex)

Usage: start the LSP with --debug-address=localhost:0 and find the assigned port in the LSP logs. Open the address in a browser to inspect server state, memory usage, goroutines, and collect CPU/heap profiles to help debug issues.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 17, 2026, 3:42 PM

@emcfarlane
Copy link
Copy Markdown
Contributor Author

Screenshot 2026-04-08 at 6 01 35 PM Screenshot 2026-04-08 at 6 01 31 PM Screenshot 2026-04-08 at 6 01 27 PM Screenshot 2026-04-08 at 6 01 25 PM

Screenshots of the different views (and the familiar /debug/pprof handler).

Copy link
Copy Markdown
Member

@doriable doriable left a comment

Choose a reason for hiding this comment

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

This looks good to me, and I think that it will help us gather some better stats on the LSP. We can also iterate on this over time.

As for the flags, I was debating whether we wanted a default behaviour, e.g. --debug-address="", but this emulates the behaviour of gopls and other similar tooling, so I think having the user provide, at minimum, localhost:0 makes sense to me.

Approving ahead of merge conflict resolution.

@emcfarlane emcfarlane merged commit 233aed7 into main Apr 17, 2026
10 checks passed
@emcfarlane emcfarlane deleted the ed/lspProfile branch April 17, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants