Repository navigation
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
Adjusts the Oxc language server startup to scale Tower LSP request handling concurrency based on the machine’s available parallelism, aiming to improve throughput on higher-core systems without fully saturating the host.
Changes:
- Compute an effective concurrency target from
std::thread::available_parallelism()(with a small “leave headroom” heuristic). - Configure
tower_lsp_server::Serverwith.concurrency_level(...)instead of using the default.
Suppressed comments (1)
crates/oxc_language_server/src/lib.rs:64
available_parallelism()returns aNonZeroUsizeon success, soNonZero::getwon’t resolve here. Use|n| n.get()(orNonZeroUsize::get) to extract the usize.
let current_threads = std::thread::available_parallelism().map_or(1, NonZero::get);
6808abe to
b49f196
Compare
…ers to prevent deadlock (#25438) ## What this PR does Fixes the permanent language-server deadlock reported in #24955. `workspace/diagnostic/refresh` is a server-to-client *request*, and a spec-compliant client may re-pull `textDocument/diagnostic` from this same server before replying to it. Three notification handlers (`initialized`, `did_change_configuration`, `did_change_watched_files`) awaited that round-trip inside the handler itself, pinning one of the transport's concurrency slots (tower-lsp-server defaults to 4) for as long as the client took to reply. Four rapid watcher events — e.g. four saves of `.oxlintrc.json` or any `tsconfig*.json` in pull-diagnostic mode — pinned all four slots on handlers waiting for the client, while the client waited on diagnostic pulls the server could no longer service. Circular wait, no timeout, no recovery until the process is killed. The refresh is advisory — nothing consumes its result beyond logging a warning — so this PR detaches it: a new `Backend::spawn_diagnostic_refresh()` clones the client and spawns the round-trip, returning the handler's slot immediately. The server keeps answering requests with any number of refresh replies outstanding. This is the issue's first suggested fix; raising the concurrency level (#25153) only widens the window rather than closing it, as the issue notes. ## How it's tested `test_outstanding_diagnostic_refreshes_do_not_wedge_the_server` runs in the crate's existing wire-level `TestServer` harness — real LSP framing over duplex streams, the real `Server` at its real default concurrency of 4. It initializes in pull mode with dynamic watchers, fires four watched-file events, reads each resulting `workspace/diagnostic/refresh` request **without replying** (what a busy client looks like), then sends `shutdown` and requires a response within a 10s timeout. Verified both directions: against the previous code the test fails by timeout at exactly the reported wedge point; with the fix, the full crate suite passes (85/85). `cargo fmt` and `clippy --all-targets` are clean for the changed files. The only other change is adding tokio's `time` feature to dev-dependencies for the test's timeout. ## AI disclosure Investigated, implemented, and verified with AI assistance (Claude Code), per the contributing guide's disclosure policy. I traced the root cause to the transport's concurrency accounting, confirmed the circular wait matches the reporter's reproduction, and validated the fix with the deadlock-reproducing regression test above before submission. Co-authored-by: Alexander S. <[email protected]>
|
It seems we can close this as of #25438. |
|
@leaysgur sorry for not replies, I did not had time to create tests for concurrency level 1. Normally it should not change anything, but #25438 showed that communication channel can block itself. Even so #25438 fixed a problem, this PR could be improved performance in general, maybe we add a |
|
🙆🏻 Let’s reopen then. Can you update and finish? |
b49f196 to
42cdbc9
Compare
Co-authored-by: Copilot Autofix powered by AI <[email protected]> Signed-off-by: Alexander S. <[email protected]>
Signed-off-by: Yuji Sugiura <[email protected]>

The saturation is from personal feeling and did not get benchmarked.