Skip to content

lsp-cli: daemon mode to keep language server alive between invocations #1

Description

@c3d4r

Problem

Each lsp-cli invocation spawns a fresh language server (e.g. gopls), waits for initialization, sends one request, and shuts down. The gopls startup cost is ~3 seconds per call, which adds up significantly when an agent makes 10+ navigation calls per task.

In our evaluation, Run B (lsp-cli) was 75% slower wall-clock than Run A (grep/read) despite using fewer tokens, primarily due to this overhead.

Proposal

Add a daemon mode that keeps the language server alive between invocations:

  • lsp-cli daemon start — start a background language server, listening on a Unix socket
  • lsp-cli daemon stop — shut it down
  • One-shot commands transparently connect to the daemon if running, otherwise fall back to spawning a fresh server

This is the same model gopls uses and would reduce per-call latency from ~3s to near-zero.

Impact

This is the single highest-impact improvement identified in the evaluation. With daemon mode, lsp-cli would be strictly faster than grep for semantic queries while also being more precise.

Design notes

  • Socket location: $XDG_RUNTIME_DIR/lsp-cli/<server>-<root-hash>.sock or similar
  • Auto-shutdown after idle timeout (e.g. 10 minutes)
  • One daemon per (server, workspace root) pair
  • The original design doc discusses this in Phase 4: docs/lsp-cli-design.md

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions