Checks run on a thread of their own

A check held up every request, because the compiler could run one
compilation at a time. It can now run each in a context of its own.

- A check runs on a checking thread, in Compilation.inNew. The thread
  reports a check to the thread that serves requests, which writes to the
  client.
- The outline, definitions, references, completion, signature help and
  formatting are answered while a check runs.
- A hover, a code action and bjolang/expandMacro are answered when the
  check of their file ends, with the results of the text as it stands.
  Other requests are served meanwhile.
- A file that changes again before its check starts is checked once.
- The tables that a check writes are concurrent dictionaries.
- Standard output is the protocol's; the console's output goes to standard
  error.
- smoke: with a check of 1.6 s running, an outline is answered in 0.1 s.

Needs the compiler at its commit "Diagnostics.captured collects the output
of its own context".

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-11-25 09:32:15 +01:00
parent c5acafd5dd
commit 5e4ac7d9aa
6 changed files with 273 additions and 49 deletions

View file

@ -176,10 +176,10 @@ let private read (env: Env) (file: string) (decls: TDecl list) : Index =
Fields = List.ofSeq fields }
/// Each file's index, from its last check.
let private byFile = Collections.Generic.Dictionary<string, Index>()
let private byFile = Collections.Concurrent.ConcurrentDictionary<string, Index>()
/// Each file's text as its last check read it: where an index's ranges are.
let private checkedTexts = Collections.Generic.Dictionary<string, string>()
let private checkedTexts = Collections.Concurrent.ConcurrentDictionary<string, string>()
/// The text of `path` its last check read, if it was checked.
let checkedText (path: string) : string option =