feat: pre-warm environment manager caches during activation and background refresh#1307
Open
eleanorjboyd wants to merge 2 commits intomicrosoft:mainfrom
Open
feat: pre-warm environment manager caches during activation and background refresh#1307eleanorjboyd wants to merge 2 commits intomicrosoft:mainfrom
eleanorjboyd wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to speed up environment discovery by “pre-warming” caches early: triggering PET/native discovery immediately and forcing initial manager environment lists to populate before initial environment selection runs.
Changes:
- Start a background PET refresh as soon as
NativePythonFinderImplis constructed to warm the native cache. - During activation, pre-fetch (
getEnvironments('all')) from the system and venv environment managers before applying initial environment selection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/managers/common/nativePythonFinder.ts |
Triggers an early background refresh to warm PET/native discovery cache. |
src/extension.ts |
Adds activation-time pre-warm calls to system/venv managers prior to initial environment selection. |
Comments suppressed due to low confidence (1)
src/extension.ts:559
- Same issue as above:
getEnvironmentManager(...)?.getEnvironments('all').catch(...)will fail type-checking and can throw at runtime if the manager is undefined. Ensure the.catch(...)is only invoked when a Promise is returned (e.g.,?.getEnvironments('all')?.catch(...)or by using a conditional /Promise.resolve()fallback).
envManagers
.getEnvironmentManager(VENV_MANAGER_ID)
?.getEnvironments('all')
.catch(() => {}),
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.
Managers don't scan on registration-
initialize()only runs when a consumer first callsgetEnvironments()making the whole discovery process lengthly. Every step is sequential and lazy. On a large filesystem or slow disk this is 10–30 seconds of real time with the user watching an empty interpreter picker.The Python extension avoids this by starting discovery in the
NativePythonFinderImplconstructor, so results begin streaming before other exts makes its first call.