Repository navigation
LSP: check only the edited unit when an edit changes nothing but bodies - #1542
Conversation
Replacing a unit invalidated everything importing it, transitively: an edit inside a function body of a package which 118 files of a large real map import re-checked 233 units, about 2 s per edit, although no other unit can see a body. An edit which changes nothing but the bodies of functions, constructors, destructors and init blocks is now moved into the unit of the model (BodyOnlyEdit): the new bodies, the new source positions of every node and the new parse information. Every node the importers resolved to stays, at its new position, so they keep their attributes and are not checked again; only the unit is, and its module instantiations survive that check, because the importers point into them. Bodies of modules (copied into users) and interfaces (a body decides abstractness), global initialisers, Jass and anything else count as declarations, as does a unit whose module uses did not all expand; any other change replaces the unit as before, and invalidates such a unit and what depends on it. Measured on that map, two alternating runs of five edits each: edit and reconcile 2177 ms median on master, 552 ms here; a compile reusing the check afterwards is unchanged within noise. BodyOnlyEditTests compares diagnostics and Lua with a build from scratch for edits in method, constructor and function bodies, errors in them, and the edits which must not be moved; the incremental model oracle moved 353 edits over 60 seeded sequences and matches its fresh builds over 200.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88a607b0c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… cleanly A module use with missing type arguments is reported while the module expands, but still gets an instantiation, so the size check let such a unit be edited in place and the kept instantiation never reported the error again. Each use must now name a module with as many type parameters as it passes. Every class using a module, in its unit or another, holds a copy of it with the module's positions, and the copies are kept; an edit which moved a module left them at the old lines. An edit of a unit is now made in place only when nothing in the modules it declares changes position.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a31b61d3a6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A body edit of A followed by a change of what A imports, before a reconciliation, left A edited in place while the change was propagated, so its importers were neither cleared nor made unchecked: they kept links into the replaced declarations until the reconciliation, and a run in between would use them. Only a changed unit edited in place, which neither imports nor declares an affected package nor has a config relative, is quiet now; one reached from an affected unit is affected, and so is what depends on it.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c1a5656bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…dit in place Both nodes keep the position of a token besides their own, which errors point at (AttrPos.getErrorPos of a super call); the transplant moved only their own positions.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c97eb037c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ines too A check which validated a unit edited in place took it out of the set, but what imports it still points into its module instantiations. A file synced from disk is checked by the sync, so the reconciliation after it found the unit no longer edited in place and checked every importer, and once importers were left out, it cleared the instantiations under them (a compile then failed on an instantiation without a parent). The unit now stays in the set until something invalidates it. Positions are offsets, and lines come from the line table of each parse: an edit which kept every offset in a module but moved its lines (one comment line becoming two of the same length) left the copies of the module at the old lines. Lines and columns are compared as well.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2055a9623
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…odule Both have a position of their own besides the node's, which a module copy keeps: a module whose closure moved only its arrow kept its bounds and every child's position, and was edited in place.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9b6ce991e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The cache is keyed by nodes and cleared by walking the unit; walked after the edit in place, it missed the replaced bodies, whose keys then kept them alive with every further edit.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d18ab56f7a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
retainCompilationUnits removed purged units from the model and the unchecked units but not from the units edited in place, which held every purged tree until a clean.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Replacing a unit in the language server's model invalidated everything that imports it, transitively. An edit inside a function body of a package that 118 files of a large real map import re-checked 233 units, about 2 s per edit, although no other unit can see a body.
This takes a different route from #1368. #1368 kept importers when a public-ABI hash was unchanged, but they then pointed at the replaced unit's tree. Here, an edit that changes nothing but bodies keeps the unit's tree itself.
What changes:
BodyOnlyEditdecides when an edit is body-only. It compares position-normalised copies of the old and the new unit, with these bodies blanked: functions, constructors, destructors and init blocks.A body-only edit is moved into the unit of the model:
Every node the importers resolved to stays, at its new position. The importers keep their attributes and are not checked again; only the edited unit is.
That unit's module instantiations survive its check, because the importers point into them. The instantiations' own positions follow the new
usepositions.The unit stays "edited in place" until something invalidates it, whether or not it has been checked since.
These count as declarations, so changing them replaces the unit as before:
An edit also takes the old path when:
When working out dependents, a changed unit edited in place doesn't affect its importers, unless:
Any other change to such a unit, or to something it depends on, invalidates it and its dependents as before.
The lookup cache is cleared for the unit before its old bodies leave the tree. Purged and removed units leave the in-place set.
Measured on that map: a model loaded once, then five body edits, two runs each, alternating branch and master.
The compile difference is within the noise of the shared machine.
Tests:
BodyOnlyEditTestscompares diagnostics and compiled Lua with a build from scratch after each edit. It covers:It also checks:
Every fix from the review loop has a test that failed before the fix.
IncrementalModelOracleTestswithINCREMENTAL_ORACLE_SEEDS=100: all 200 sequences match their fresh builds. A temporary counter showed 353 edits moved in place over the first 60 of them.ModelManagerTests,HoverTests,CompletionDocumentationTests,MapModelReuseTestsand everyde.peeeq.wurstio.languageserverclass pass.Only Windows was run.