Skip to content

feat: bundle generated code cache into product - #336410

Draft
Robo (deepak1556) wants to merge 1 commit into
mainfrom
robo/generate_code_cache_ci
Draft

Robo (deepak1556) wants to merge 1 commit into
mainfrom
robo/generate_code_cache_ci

Conversation

@deepak1556

Copy link
Copy Markdown
Collaborator

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.

@deepak1556 Robo (deepak1556) added this to the 1.139.0 milestone Sep 16, 2026
@deepak1556 Robo (deepak1556) self-assigned this Sep 16, 2026
Copilot AI balanced review requested due to automatic review settings September 16, 2026 12:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Medium severity

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;
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.

2 participants