Skip to content

perf(prepush): share pro-test npm and vite caches across worktrees - #6853

Merged
koala73 merged 1 commit into
mainfrom
perf/prepush-pro-test-cache-6766
Aug 17, 2026
Merged

perf(prepush): share pro-test npm and vite caches across worktrees#6853
koala73 merged 1 commit into
mainfrom
perf/prepush-pro-test-cache-6766

Conversation

@koala73

@koala73 koala73 commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

A fresh worktree that tripped the pro-test freshness gate used to spend ~55s on npm ci + vite build before it even compared public/pro/. After this change the same gate still fails a stale marketing bundle, but the install and Vite cache are shared across worktrees instead of being paid again on every checkout.

Closes #6766.

What changed

npm ci at the hook's admission-leased install site and in worktree bootstrap now passes --prefer-offline against the existing /tmp/worldmonitor-npm-cache. Bootstrap also seeds pro-test/node_modules (copy/npm ci, never a node_modules symlink — that path is known-broken here).

Vite's default node_modules/.vite is linked at hook time to a lockfile-sharded directory under the same git-common-dir that #6846 uses for admission, so every worktree of the same repo and lockfile shares one cache. Concurrent hook builds take a flock on that directory.

pro-test/vite.config.ts is intentionally untouched. Editing it would put pro-test/ in the branch delta, fire this same gate, and force a public/pro/ rebuild. On this machine a clean rebuild of current main already produces different hashed assets than the committed production bytes — a pre-existing drift, not something this cache change should ship.

Measurements

Issue report (curious-frolicking-kite, 2026-08-16):

step cold warm
pro-test npm ci 23.6s skipped
pro-test npm run build 31.3s 7.1s
total 54.9s 7.1s

This worktree (Node 24.19, after npm ci --prefer-offline):

step result
pro-test npm ci --prefer-offline 40.7s (tarball extract; no network when cache is warm)
vite build first run 22.5s
vite build second run 21.8s
two concurrent vite builds both exit 0, byte-identical outputs (42 files)
cacheDir vs default output identical
full generate-product-config + npm run build 28.8s; this machine's hashed assets still differ from committed public/pro/ (pre-existing)

The ≤20s first-push target is the bootstrap-seeded path: pro-test/node_modules is already present, so the hook skips npm ci and only rebuilds. Production vite build did not write a cacheDir on this machine, so the 31s→7s warm number from the issue is likely OS page cache + an already-installed tree more than a Vite dep-optimize hit.

Test plan

  • Hook fixture: missing pro-test/node_modules runs npm ci --prefer-offline
  • Hook fixture: a pro-test/node_modules symlink is refused and does not run npm ci
  • Hook fixture: .vite is a link into wm-vite-cache/pro-test-<hash>; node_modules itself is not a symlink
  • Hook fixture: reverting one byte of committed public/pro/index.html still fails with the existing stale-bundle error
  • Bootstrap dry-run seeds pro-test and includes --prefer-offline
  • Bootstrap refuses a node_modules symlink instead of following it
  • Cache resolver: env override, lockfile shard, same lockfile → same path, missing git → fallback
  • Two concurrent Vite builds, outputs hashed equal
  • Gate trigger list and git diff paths unchanged
  • Rebased onto fix(prepush): bound concurrent heavy gates #6846; root npm ci stays under the admission lease

Known Residuals

  • pro-test/vite.config.ts does not set cacheDir. The hook shares Vite's default cache directory instead, so this PR does not have to rebuild public/pro/.
  • Dedicated multi-persona ce-code-review did not finish (reviewer hung). Orchestrator reviewed correctness, gate regressions, and the symlink landmine locally.

Post-Deploy Monitoring & Validation

No additional operational monitoring required. This only changes the local pre-push hook and worktree bootstrap. Production /pro bytes are not in the diff; a stale committed bundle still fails the same hook error.


Compound Engineering
Grok

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Ready Ready Preview Aug 17, 2026 12:32pm

Request Review

Fresh worktrees paid ~55s on the pro-test freshness gate: npm ci
extracted tarballs even when they were already in the shared cache,
and each worktree rebuilt without a shared Vite cache.

npm ci --prefer-offline now uses that cache at both hook sites and
during worktree bootstrap, which also seeds pro-test/node_modules.
Vite's default cacheDir is linked to a lockfile-sharded path under
git-common-dir — a .vite link, never a node_modules symlink.
Concurrent hook builds flock the shared cache. The freshness check
and its trigger list are unchanged.
@koala73
koala73 force-pushed the perf/prepush-pro-test-cache-6766 branch from 0e269ac to 27a9c90 Compare August 17, 2026 12:26
@koala73
koala73 merged commit 3973688 into main Aug 17, 2026
32 checks passed
@koala73
koala73 deleted the perf/prepush-pro-test-cache-6766 branch August 17, 2026 18:36
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.

perf(prepush): pro-test costs 55s cold in every fresh worktree — share the npm and vite caches

1 participant