Skip to content

ci: extract the node_modules cache in parallel parts - #345838

Merged
Logan Ramos (lramos15) merged 4 commits into
mainfrom
ci/node-modules-cache-unpack
Nov 3, 2026
Merged

Logan Ramos (lramos15) merged 4 commits into
mainfrom
ci/node-modules-cache-unpack

Conversation

@lramos15

@lramos15 Logan Ramos (lramos15) commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Part of an effort to get the required PR checks under 10 minutes. Every test job restores the node_modules cache, and today's restore step takes about 72s on Windows, 44s on macOS and 22s on Linux. Most of the Windows time is spent unpacking one ~1 GB 7z archive into ~175k files with a single 7-Zip process.

Changes

  • cache.sh and cache.ps1 split the node_modules file list into 8 parts (splitList.ts), which they archive and extract in parallel. Each part is a contiguous range of the list, weighted by size plus a per-file cost. Formats and flags are unchanged: tar+zstd -3 on Linux and macOS, 7-Zip -mx3 on Windows.
  • extract still restores the single node-modules.tzst / cache.7z of existing caches. So build/.cachesalt is not bumped, and nothing gets invalidated. The new format takes effect when pr-node-modules.yml next saves a cache, for example after the next dependency change on main.
  • listNodeModules.ts is unchanged, since the Azure pipelines use it too.

Benchmark

The benchmark ran on the PR runners against the real main caches, using the temporary workflow in the earlier commits, which this PR now removes. Each variant extracted into an empty folder, as the PR jobs do. On macOS it extracted in place because the runner's disk is small.

Runner One archive (today) This PR (8 parts) Size
Windows 8-core, 7-Zip 63.9s 26.9s 1051 → 1052 MB
Linux 8-core, tar+zstd 8.8s 6.1s 1024 → 1222 MB
macOS 5-core, tar+zstd (in place) 21.0–30.0s 14.9–21.0s 1175 → 1184 MB

All variants restored the same number of entries (175,033 on Windows). Other variants measured on Windows:

  • tar+zstd in 8 parts: 35.6s, 1323 MB
  • 7-Zip in 4 parts: 70.5s
  • 7-Zip in 16 parts: no better than 8
  • uncompressed 7z: no faster to extract, and 5 GB

Expected savings are about 37s per Windows job. The saving is part of every Windows job's setup, so it shortens the slowest jobs too. Linux and macOS save a few seconds. Archiving in parallel took ~97s on Windows, and only the cache-warming jobs on main archive.

Validation

  • Local macOS round trip (archive, delete node_modules, extract): the file and link listing is identical. Old single-archive caches still extract identically, and a missing archive fails.
  • On the CI runners, cache.sh/cache.ps1 archive + extract restored all entries on Linux, macOS and Windows (cache-scripts rows of the benchmark).
  • actionlint and eslint are clean.

Measures how long the PR runners take to extract the node_modules cache as one archive, as today, and as several parts extracted in parallel. To be removed before merging.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 15:46

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.

🟡 Changes recommended

Concurrent archive/extraction processes can corrupt recovery after a failure, and Windows pipelines can hide command failures, allowing incomplete restores to contaminate subsequent measurements.

2 open issues
What changed in this PR

This draft adds temporary benchmarks to evaluate whether parallel archive extraction can reduce node_modules cache restore time in VS Code’s PR checks. It does not yet change production cache handling.

Changes:

  • Compare existing archives with weighted, multipart 7z and tar/zstd variants.
  • Measure archive creation, extraction, size, and entry counts, and publish summary tables.
  • Run benchmarks on Windows, Linux, and macOS PR runners after a cache hit.
File Description
.github/​workflows/​node_modules_cache/​bench.ts Implements archive splitting, parallel benchmarks, recovery, and result reporting.
.github/​workflows/​bench-node-modules-cache.yml Adds cross-platform benchmark jobs, including Windows Dev Drive setup.

Review effort: Balanced

One tar or 7-Zip process extracts the 173k files of the node_modules cache about twice as slowly as several in parallel. Split the archive into 8 parts of about the same extraction time, archive and extract them in parallel, and still extract the single archive of the caches saved before.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ary)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On the Windows runners, extracting the node_modules cache into an empty folder took 64s as one 7-Zip archive and 27s as 8 parts in parallel. Linux went from 8.8s to 6.1s.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lramos15
Logan Ramos (lramos15) merged commit b93007d into main Nov 3, 2026
99 of 100 checks passed
@lramos15
Logan Ramos (lramos15) deleted the ci/node-modules-cache-unpack branch November 3, 2026 21:00
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 3, 2026
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.

3 participants