feat: bundle generated code cache into product - #336410
Draft
Robo (deepak1556) wants to merge 1 commit into
Draft
Robo (deepak1556) wants to merge 1 commit into
Robo (deepak1556) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Four moderate findings remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review tier: Lite (auto)
Findings: 2
Note
Copilot is running an experiment and ran this review at Lite.
Open (2)
What changed in this PR
Adds build-time Node.js compile caches for VS Code startup processes, packaged for portable read-only runtime use.
Changes:
- Enables caching across main, extension, shared, pty, and agent host processes.
- Adds cache generation, validation, readiness coordination, and tests.
- Updates bundling and universal macOS packaging.
| File | Reviewed change | Findings |
|---|---|---|
src/vs/workbench/api/node/extHostExtensionService.ts |
Signals extension-host cache readiness. | — |
src/vs/workbench/api/common/extHostExtensionService.ts |
Adds eager-extension lifecycle support. | — |
src/vs/platform/terminal/node/ptyHostMain.ts |
Signals pty-host readiness. | — |
src/vs/platform/agentHost/node/agentHostService.ts |
Exposes eager agent-host startup. | — |
src/vs/platform/agentHost/node/agentHostMain.ts |
Signals agent-host readiness. | — |
src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts |
Signals shared-process readiness. | — |
src/vs/code/electron-main/app.ts |
Coordinates startup and cache generation. | — |
src/vs/base/node/nodeCompileCache.ts |
Implements runtime cache handling and eager modules. | Moderate (1 vote): nested production bundle paths can make eager module paths invalid. |
src/mainImpl.ts |
Contains deferred main-process startup logic. | — |
src/main.ts |
Enables caching before startup loads. | — |
src/bootstrap-fork.ts |
Enables caches for utility processes. | — |
eslint.config.js |
Updates imports and layering restrictions. | — |
build/next/index.ts |
Bundles the deferred main implementation. | — |
build/lib/test/nodeCompileCache.test.ts |
Tests cache paths, targets, and validation. | — |
build/lib/nodeCompileCache.ts |
Generates and validates packaged caches. | Moderate (2 votes): inherited internal environment overrides can redirect generation outside the packaged cache directory. |
build/gulpfile.vscode.ts |
Integrates cache generation into packaging. | Moderate (1 vote): the legacy bundler can inline mainImpl, leaving its generated cache unused. |
build/darwin/create-universal-app.ts |
Copies caches into universal macOS applications. | Moderate (2 votes): copying only arm64 cache entries causes the x64 app to skip them. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const asarRelativePath = path.join('Contents', 'Resources', 'app', 'node_modules.asar'); | ||
| const outAppPath = path.join(buildDir, `VSCode-darwin-${arch}`, appName); | ||
| const productJsonPath = path.resolve(outAppPath, 'Contents', 'Resources', 'app', 'product.json'); | ||
| crossCopyPlatformDir(x64AppPath, arm64AppPath, path.join('Contents', 'Resources', 'app', 'node-compile-cache')); |
| delete env.NODE_COMPILE_CACHE_PORTABLE; | ||
| delete env.NODE_COMPILE_CACHE_READONLY; | ||
| delete env.NODE_DISABLE_COMPILE_CACHE; | ||
| delete env.VSCODE_DEV; |
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.

Today main, extension host, shared process, pty host, and agent host repeatedly parses and compiles its startup modules. This change moves that work to build time. CI launches the packaged application once, generates a compile cache for each process, and bundles the caches with the product. At runtime, caches are consumed in portable, read-only mode, so application resources are never modified.
Selective eager compilation is used for the core entry points and a small set of measured startup dependencies, retaining most of the benefit without eagerly compiling every loaded function.