Skip to content

Comments

Share package.json cache and skip collecting failed lookup locations in auto-imports#2855

Open
andrewbranch wants to merge 2 commits intomicrosoft:mainfrom
andrewbranch:auto-import-shared-packagejson-cache
Open

Share package.json cache and skip collecting failed lookup locations in auto-imports#2855
andrewbranch wants to merge 2 commits intomicrosoft:mainfrom
andrewbranch:auto-import-shared-packagejson-cache

Conversation

@andrewbranch
Copy link
Member

#2780 shows a lot of allocations going to package.json parsing. I can't repro myself, but based on the profile and the report that the problem started after #2502, I think this is probably it. The failed lookup locations are also not used by auto-imports, so that should be an additional small win. I tried invoking completions in a file in Signal-Desktop as a random benchmark, and this brought total allocs down from 0.78 GB to 0.75 GB. Not huge, but maybe there's a pathological case I haven't been able to repro. Worth a try!

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

This PR targets reducing memory allocations in the auto-import pipeline by reusing a shared package.json parse cache across resolver instances and by skipping collection of lookup-location metadata that auto-imports don’t consume. This fits into the TypeScript-Go language server’s performance work, particularly around module resolution during completion/auto-import indexing.

Changes:

  • Add module.ResolverOptions + NewResolverWithOptions to allow sharing a packagejson.InfoCache and disabling lookup-location collection.
  • Gate recording of failedLookupLocations/affectingLocations behind a resolver option to avoid unnecessary allocations.
  • Update auto-import registry building to create one shared package.json cache and pass it into all module resolvers used during extraction/indexing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/module/resolver.go Adds resolver options, shared package.json cache support, and conditional lookup-location recording.
internal/ls/autoimport/util.go Threads resolver options through the auto-import module resolver helper.
internal/ls/autoimport/registry.go Creates and reuses a shared package.json cache for auto-import indexing resolvers; enables skipping lookup locations.

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.

1 participant