perf(lsp): take the facts before a rename from the check the workspace made #195
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/172-rename-checks-once"
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 #172
What
Project(projects.trb) keeps the last run that checked each file whole: a round of the workspace check (stepWorkspace), the check of open documents (finishCheck), and the check before a rename.Project.generationcounts the changes of what the modules see of each other;bump()drops every kept run, andkeeprefuses a run that began in an older generation.refresh. A front built from scratch does not move it: the facts a rename compares are places, not ids.Project.keptChecksOfaccepts a kept run for a file where the file has the text the run read and every other file of the run's front has the same text or one whose bodies alone changed (mappingBetween); the places of such files are moved with the mapping (keysOfRun,ModuleFacts.moved).server.trb) takes the kept runs at its first step, after the batch it came with, checks before the edits only the files no kept run holds for (RenameSearch.unkept), and always checks every file after them. Files are taken in their order, so a refusal names the same file as before. A log line counts the checks of each rename.LanguageServer.keepsChecksturns the kept runs off for the differential tests.docs/design/LANGUAGE-SERVER.mdsection 10 records the design and the measurement; the bullet of section 15 on a rename of a name many files have is removed (second commit).Why
A rename of a name many files have checked all of them twice. After the workspace check, the check before the edits already exists for every file nobody changed since.
Tests
New group "A rename takes what its files were from the last checks" in
compiler/tests/language-server.test.trb:0 file(s) before its edits and 11 after them;$/cancelRequeststops the rename before its edits and after them.The existing rename tests and
tests/lsp/*.expectedare unchanged. Locally: the two rename groups pass in the VM,torb format --checkis clean on the touched files.Measurement
The repository's own workspace (763 files),
ModuleIdofcompiler/src/semantics/module.trbrenamed toModuleKeyafter the workspace check (71 files have the name, 476 edits in 69), with thetorbCI built formain(34db9908) and the one CI built for this PR, sessions taken by turns on an 8-core EPYC Milan machine under a load of 20-25:The memory cost: the kept rounds stay beside the run after the edits, +117 MiB at the peak of the session.
Checklist (head
3272b13):$/cancelRequestin both phases. Existing rename tests andtests/lsp/*.expectedunchanged. CI green for this head (tier A/B, bootstrap, gates, pdisc).movesSince, otherwise the run is unusable). Generation bumps cover opened-with-other-text, unviewed or checking document change, close with changes, watched file change and interface change. Kept runs are taken at the rename's first step, after its batch. Files are still walked in order, so refusals name the same file.Non-blocking:
dropUnusedRunsrescans all kept modules on everykeep/forget; O(files) per document change is fine now, but a refcount per run would be cheaper on very large workspaces.