perf(lsp): reuse the declaration sites and the implementation index across keystrokes #174
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/10-language-server-sites-index"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #10
A keystroke in a body no longer declares the sites and collects the implementation index of the whole program.
prepareBodies(checker/check.trb): the first keystroke over a front builds a checker with the sites and the implementations of every module but the document's. A module whose collection read the document's (generic parameters, signatures, aliases,Selfor a const argument of one of its symbols) is withheld too, and the round starts over. The state is unusable, and the keystroke builds everything as before, where collection asked a question about traits.checkBodiesOver: a keystroke starts from a copy of that checker, puts the refreshed front's symbols of the document in place (the symbols the refresh appended are moved behind the checker's own, with the document's type-position names), declares the withheld modules' sites from the current text and collects the index again from the first withheld module, in program order, so every implementation id and candidate order equals a whole build (collectModule,addCollectedinimplementation.trb).Front.preparedkeeps it for one document;refreshedFrontdrops it for any other changed file, and every front built from scratch (outline change, change on disk, the run limit) starts without it.checkTypes,preparedChecker,torb checkandtorb buildare unchanged; the server log line of a keystroke now says how many modules it declared.Tests (
compiler/tests/language-server.test.trb, group "A keystroke in a body keeps the sites and the index of every other module"): the second keystroke over 3+ modules declares 1 of N; an outline change and a disk change drop the kept state; a run from the kept state over a module withtype ... with, anextend, a call of another module's trait implementation, a derivedShowand an extending reader module finds the same diagnostics, resolutions, dispatches and expression types ascheckBodiesWithin, and the kept checker holds no derived implementation.Docs (
docs/design/LANGUAGE-SERVER.mdsections 7 and 15) follow with the measurement on the CI-built binaries.Checklist for
d3bf996(CI combined status: success; the skipped jobs are the non-linux-x64 runners and release packaging, not triggered for this change):checkBodiesWithin(type withwith,extend, a trait implementation of another module, a derivedShow, an extending reader module that gets withheld) incl. "kept checker holds no derived implementation".checkBodiesWithinwhen collection asked trait questions) is conservative; the copy-not-undo approach keeps the kept checker clean; symbol moving (movedSymbol) is consistent with the refreshed front, andpreparedsurvives onlyrefreshedFrontfor the same module.checkTypes,preparedChecker,torb check/builduntouched.LANGUAGE-SERVER.mdsections 7 and 15 updated with the decision, the copy-vs-undo cost and the measurement from CI-built binaries; pdisc green.Non-blocking:
Checker.unsitedConstantsis appended per lowering call without de-duplication and read withList.containsper watched symbol incountRead; a set or a dedupe on append would keep that linear if it ever grows.