Skip to content

module: do not split a portable compile cache by uid - #65293

Open
codebytere wants to merge 1 commit into
nodejs:mainfrom
codebytere:compile-cache-portable-tag
Open

module: do not split a portable compile cache by uid#65293
codebytere wants to merge 1 commit into
nodejs:mainfrom
codebytere:compile-cache-portable-tag

Conversation

@codebytere

Copy link
Copy Markdown
Member

A portable compile cache is meant to be reused wherever the same module layout is found. One shape of that is a cache generated once, at build time, and shipped read-only with an application for whoever runs it. On platforms with uids the cache subdirectory is suffixed with the uid of the user who created it ($NODE_VERSION-$ARCH-$CACHE_DATA_VERSION_TAG-$UID), so such a cache is only ever found by that one user; the split exists so users sharing a writable directory do not trip over each other's file permissions.

This omits the uid suffix in portable mode only. A user who cannot write to the directory still reads it, and a failed write is only a cache miss (Persist already logs and skips a temp file it cannot create). Non-portable caches keep the suffix.

Docs updated for portable and NODE_COMPILE_CACHE_PORTABLE; test-compile-cache-api-portable now asserts the tag directory name.

Context: an Electron application generating its main-process cache at package time and shipping it beside its app.asar (module.enableCompileCache({ directory, portable: true }) at launch); measured on that app, the shipped cache roughly halves the launch bundle's load time, but with the uid in the tag it is only found by users whose uid matches the build machine's.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Aug 14, 2026
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.34%. Comparing base (bc813a7) to head (cdb9ccf).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65293      +/-   ##
==========================================
+ Coverage   90.32%   90.34%   +0.01%     
==========================================
  Files         751      751              
  Lines      249960   250332     +372     
  Branches    47204    47316     +112     
==========================================
+ Hits       225774   226160     +386     
- Misses      15564    15566       +2     
+ Partials     8622     8606      -16     
Files with missing lines Coverage Δ
src/compile_cache.cc 79.21% <100.00%> (+0.12%) ⬆️

... and 41 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

A portable compile cache is meant to be reused wherever the same module
layout is found, which includes being generated once (at build time,
say) and shipped read-only with an application for whoever runs it. On
platforms with uids the cache subdirectory is suffixed with the uid of
the user who created it, so such a cache is only ever found by that one
user. Omit the suffix in portable mode: a user who cannot write to the
directory still reads it, and a failed write is only a cache miss.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants