Skip re-checking files unaffected by a type change#2235
Open
tk0miya wants to merge 1 commit into
Open
Conversation
a6e3296 to
57fc8df
Compare
Steep re-type-checks every source file and re-validates every signature
file on each change. This adds incremental re-checking: a file is
re-processed only when the change could actually affect its diagnostics,
and otherwise its cached result is reused.
The decision combines two sets:
* The referencing side ("Refs"). While type-checking a source file we
collect the RBS type names it touches (Steep::TypeNameReferences); while
validating a signature file we collect the names the validator touches
(Signature::Validator#referenced_type_names). The set is a sound
over-approximation of the file's real dependencies.
* The changed side. The signature service computes the closure of type
names whose definition changed in an update (last_changed_type_names),
expanding over descendants (inheritance/mixin), nested declarations, and
type alias dependencies.
A file is re-checked only when its referenced set intersects the changed
set. The need-to-recheck is recorded on the cached file (an `outdated`
flag) rather than per job, so it survives even when a file's re-check is
deferred across cycles. SourceFile gains referenced_type_names/outdated,
and a new SignatureFile holds the per-file validation diagnostics, refs
and outdated flag on the signature side.
Soundness for newly introduced types: a file with an unresolved reference
(e.g. a constant whose declaration does not exist yet) has an incomplete
reference set, so it is always re-checked until the reference resolves.
This keeps the rbs-inline workflow correct, where a `.rb` file is checked
before its generated `.rbs` exists, leaving the type it defines unresolved
until the signature appears.
https://claude.ai/code/session_017Dsb3STHRZuLYYvgyXrBRG
57fc8df to
ffa94cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Steep re-type-checks every source file and re-validates every signature file on each change. This adds incremental re-checking: a file is re-processed only when the change could actually affect its diagnostics, and otherwise its cached result is reused.
The decision combines two sets:
The referencing side ("Refs"). While type-checking a source file we collect the RBS type names it touches (Steep::TypeNameReferences); while validating a signature file we collect the names the validator touches (Signature::Validator#referenced_type_names). The set is a sound over-approximation of the file's real dependencies.
The changed side. The signature service computes the closure of type names whose definition changed in an update (last_changed_type_names), expanding over descendants (inheritance/mixin), nested declarations, and type alias dependencies.
A file is re-checked only when its referenced set intersects the changed set. The need-to-recheck is recorded on the cached file (an
outdatedflag) rather than per job, so it survives even when a file's re-check is deferred across cycles. SourceFile gains referenced_type_names/outdated, and a new SignatureFile holds the per-file validation diagnostics, refs and outdated flag on the signature side.Soundness for newly introduced types: a file with an unresolved reference (e.g. a constant whose declaration does not exist yet) has an incomplete reference set, so it is always re-checked until the reference resolves. This keeps the rbs-inline workflow correct, where a
.rbfile is checked before its generated.rbsexists, leaving the type it defines unresolved until the signature appears.This optimization reduces the incremental type-check durations (2.63s -> 1.38s) for kaigonrails/conference-app.
Before (2.0.0):
After: