Repository navigation
fix(lsp): let the session hold its server weakly - #837
Conversation
The server owns its session and the session held two `Arc<Server>` (its project client and npm executor), so a dropped in-process server never freed the session, its snapshots or its programs. The session now gets a `SessionClient(Weak<Server>)` that forwards while the server is alive and does nothing after, like the logger. Ported from Effect-TS/tsgo's tsrs patch 102. Co-authored-by: Mattia Manzati <mattia.manzati@gmail.com>
ae016a1 to
6ab09d5
Compare
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
Performance change vs mainWorkflow run · main Clef gate: Running benchmarks because the decision was unavailable (crates/tsrs_lsp/src/server.rs: patch exceeds the Clef context limit (4215 bytes)). Release builds in fast mode (TSRS_FAST=1) with Hyperfine 2 hardware counters. After warming each binary, alternating main/PR pairs measure wall time at both the fast preset's default checker count and with --singleThreaded, with ten pairs per configuration by default. Instructions come from the single-threaded runs; peak RSS comes from the default-count runs.
Negative means the PR used less; positive means it used more. Deltas are medians of paired PR/main ratios for wall time and instructions. Single-threaded runs reduce scheduling noise; shared CI machines can still add noise to wall time. Measured medians (main → PR)
|
|
@Boshen small leak fix for ready for a look |
the lsp server owns its session, and the session held two
Arc<Server>back (its project client and npm executor). so a server dropped without a shutdown request never freed the session, its snapshots or its programs. that hits every in-process server: the tsrs_lsp integration tests (lsptestutil never sends shutdown) and a future napi build.the session now gets a private
SessionClient(Weak<Server>)that forwards while the server is alive and does nothing after, same as the logger already does. the new test fails on main and passes here.one change in the binary: if an editor closes stdin without sending shutdown,
tsrs --lspnow frees the session right before exiting instead of just exiting.ported from effect's tsrs patch, mattia is co-author on the commit:
numbers on macOS, debug test profile:
with a shutdown first, main already frees almost everything (about 0.2 MiB per cycle), so the fourslash job wont move much. the suite also passes with
TSRS_ARENA_POISON=1, which matters since tests never freed these sessions and programs before.part of #646 (leaks through repeated LSP lifecycles)