purefunctor / purefunctor/purescript-iris
Keep LSP workspace preparation off the protocol loop
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 102
- Forks
- 11
- Avg merge
- 3h 30m
- Merged PRs (30d)
- 138
Description
Follow-up opportunity
Nonblocking architecture/performance follow-up from #505, verified at 429c883a. The prepared-workspace handoff is a useful boundary, but expensive preparation still runs synchronously on the protocol thread. This is confirmed by the call path; no large-workspace latency benchmark was run for this review.
Evidence
iris-lsp::startcreates a current-thread Tokio runtime.initializedandfinish_workspace_configurationcallapply_configuration_innerthrough synchronous router notification/event handlers incompiler-bin/iris-lsp/src/server.rs.apply_configuration_innerperforms discovery, source reconfiguration preparation, and initialbuild_initialbefore returning.discover_manualalso waits forstd::process::Command::output()synchronously.build_initial/query_packagewaits for Rayon package execution;query_packageat lines 330–341 drives queries through JavaScript generation. Parallel package work does not make the calling protocol handler asynchronous.- Introduced by package-scheduled LSP bootstrap, retained after workspace runtime encapsulation. The test
requests_are_cancelled_while_the_workspace_is_loadingchecks a waiting State directly, not protocol responsiveness while preparation is executing.
Why it matters
While a preparation handler is running, the main loop cannot service incoming requests, shutdown, or newer configuration messages. The existing waiting-state rejection and notification queue help while waiting for client configuration, but cannot run concurrently with synchronous preparation. Slow source commands can extend this indefinitely.
Bounded completion criteria
- Move discovery/initial compilation and source-reconfiguration preparation into owned background work; return results through a generation-tagged event and commit only a current result on the protocol thread.
- Preserve ordered pending notifications, open buffers, previous-workspace retention on preparation failure, and the existing distinction between preparation and delivery failure.
- Add a protocol E2E test with deterministically blocked preparation that proves the loop can respond before preparation is released, and that a superseded result cannot replace the newest configuration. Define shutdown cleanup for outstanding preparation/source-command work.
Duplicate check: searched open and closed issues for initialization, blocking, responsiveness, and configuration. Closed #47 concerns cancellation versus file locking, and closed #497 establishes workspace settings; neither covers asynchronous preparation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with compiler-bin/iris-lsp/src/lib.rs and server.rs, especially initialized, finish_workspace_configuration, and apply_configuration_inner; then inspect build_initial and query_package in compiler-bin/iris-build/src/compile.rs. Run the existing requests_are_cancelled_while_the_workspace_is_loading test before adding a protocol E2E test with blocked preparation. Done means the protocol loop remains responsive, superseded results are ignored, existing notification and workspace behavior is preserved, and shutdown cleans up outstanding work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, devtools, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100