Skip to content

Delete failed lookup locations#3038

Merged
andrewbranch merged 3 commits intomicrosoft:mainfrom
andrewbranch:delete-lookup-locations
Mar 10, 2026
Merged

Delete failed lookup locations#3038
andrewbranch merged 3 commits intomicrosoft:mainfrom
andrewbranch:delete-lookup-locations

Conversation

@andrewbranch
Copy link
Member

Failed lookup locations store the module resolution failures for every import, but we never use that granular information—we dedupe at the per-project level in the LSP to form a small set of globs to watch and then match the watch events against the deduped set to invalidate the program. That leaves potentially quite a lot of useless strings in memory. In the LSP, we were already wrapping each program's CompilerHost in a thing that tracks every requested file during construction for file cache management, making failed lookup locations and affecting locations completely superfluous.

This saves 0.8% memory on tsgo vscode/src/tsconfig.json, but 22% memory in DefinitelyTyped-tools with every workspace package open.

Copilot AI review requested due to automatic review settings March 9, 2026 23:18
// this is a simple string prefix check.
func (p Path) ContainsPath(child Path) bool {
return ContainsPath(string(p), string(child), ComparePathsOptions{UseCaseSensitiveFileNames: true})
return p == child || len(child) > len(p) && strings.HasPrefix(string(child), string(p)) && (p[len(p)-1] == '/' || child[len(p)] == '/')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a drive-by optimization since watch glob building changed to operate over already-normalized tspath.Paths

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces memory use in the language server/project system by removing per-import module-resolution “lookup locations” tracking (failed/affecting locations) and instead relying on the existing compiler-host FS wrapper that already tracks files consulted during program construction.

Changes:

  • Remove FailedLookupLocations / AffectingLocations plumbing from module resolution results and resolver state.
  • Simplify project watch/invalidation logic to use the compiler host’s sourceFS.seenFiles tracking instead of stored lookup-location sets.
  • Update auto-import package entrypoint extraction types and adjust watch-path casing expectations in tests.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/tspath/path.go Optimizes Path.ContainsPath to a prefix-based check for canonicalized Path values.
internal/project/watch.go Reworks resolution-watch glob computation to take a SyncSet[tspath.Path] of seen paths.
internal/project/session_test.go Adjusts watcher glob matching expectation for case-insensitive canonicalized paths.
internal/project/session.go Removes updating/maintaining failed-lookup and affecting-location watches at the session level.
internal/project/projectcollectionbuilder.go Changes invalidation logic to rebuild programs when a changed path was “seen” by the host during program construction.
internal/project/project.go Collapses multiple project watchers into a single programFilesWatch based on sourceFS.seenFiles.
internal/module/types.go Removes LookupLocations from resolved module/type directive results.
internal/module/resolver.go Deletes lookup-location collection machinery; simplifies entrypoints API to return a slice directly.
internal/ls/autoimport/registry.go Updates entrypoint handling to match the resolver API change (slice-of-entrypoints).

@andrewbranch andrewbranch requested a review from jakebailey March 10, 2026 20:19
@andrewbranch andrewbranch added this pull request to the merge queue Mar 10, 2026
Merged via the queue into microsoft:main with commit 8c71b09 Mar 10, 2026
21 checks passed
@andrewbranch andrewbranch deleted the delete-lookup-locations branch March 10, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants