Repository navigation
perf(build): skip unnecessary work and reclaim Vite caches - #29479
Conversation
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
1570cba to
72d7f50
Compare
1c436ba to
2930fb3
Compare
2930fb3 to
cdf8448
Compare
cdf8448 to
72316ac
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
676fa5f5-7aff-4fd8-8a39-00a383f74315
📥 Commits
Reviewing files that changed from the base of the PR and between 1c436bab70919466d66e9e252c8280787380d810 and 72316ac.
📒 Files selected for processing: 5
config/scripts/electron-vite-development-config.test.tsconfig/scripts/electron-vite-output-contract.test.tsconfig/scripts/reclaim-vite-caches.test.mjsconfig/scripts/vite-cache-activity.mjselectron.vite.config.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
|
|
||
| export async function retainViteCache(cacheRoot) { | ||
| const usage = join(cacheRoot, VITE_CACHE_USAGE_DIRECTORY) | ||
| const owner = join(usage, `${VITE_CACHE_HOST_ID}-${process.pid}-${randomUUID()}`) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Release owner markers when Vite restarts.
Each retention creates a new owner marker. On restart, Vite calls _closeServer('restart') and bypasses the server.close wrapper in config/build-plugins/vite-cache-retention.ts. The previous marker remains associated with a live PID, so cleanup cannot reclaim its cache if the restarted server uses another cache directory. Release ownership through Vite’s closeServer hook for both restart and shutdown. (raw.githubusercontent.com)
ELI5
Ordinary dev and build commands skip unnecessary work automatically. Development main-process compilation uses less memory, and agents sharing a dependency install stop invalidating each other’s Vite cache.
What Changed
pnpm reclaim-space: preview or remove tracked caches unused for 30 days. Dev servers record their use and process ownership; cleanup retains active, recent, foreign-host, and unverifiable caches. Startup and cleanup use the same short maintenance lock, without a persistent heartbeat.Why
These changes remove work from existing commands. Lazy loading preserves TypeScript’s configuration parsing and watcher recovery; separate cache directories prevent different worktree roots and desktop/web settings from repeatedly invalidating a cache inside shared
node_modules. Tracking cache use makes the disk cost reclaimable without treating an old directory timestamp as proof that a running server is idle.Linked Issue
Follow-up to #29345.
Visual Proof
N/A — build configuration only; no application UI or interaction changes.
Testing
Linux, Node 24.22.0, Bun 1.4.3; all tests used
ORCA_BACKGROUND_LAUNCH=1.pnpm tcpnpm tc:nodeafter the cleanup addition and final config integration.git diff --check.pnpm build:web.Local medians, with the original configurations and changed configurations run in alternating order, using the same source tree and default concurrency:
Six fresh config loads per side with the final retention plugin; two dev-main and two full builds per side before the retention addition. Electron and web production builds were checked again with the final plugin. Full-build speed and memory did not improve reliably in this small sample. Cache collision avoidance was verified through configuration resolution; its performance benefit was not benchmarked across concurrent worktrees.
Review
Checked development/production config resolution, watch recovery and cleanup, and cache packaging exclusions. Cache paths use Node path resolution and work in folder workspaces too. Repository-wide cleanup follows the existing local Git-worktree scope and runs only on the execution host; folder workspaces without Git have no repository sweep. Unknown or pre-tracking caches are retained. No runtime or remote protocol changes.
Agent skill upstream boundary
Notes
Local validation was on Linux. macOS/Windows checks remain for CI.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)The complete test suite and packaged builds are covered by CI; the focused checks and normal JavaScript builds above passed locally. After the final rebase, full typecheck, root Oxlint, and anti-slop checks passed. Local
pnpm lintreaches existing mobile import-cycle warnings with mobile dependencies installed; CI runs that audit before the mobile install, as documented in the workflow.The full PR Checks workflow passed on commit
72316ac6fbfa3fda15df134421a5d77ca5f2ed6f, including the aggregate gate, all five unit shards, static analysis/typecheck, relay integration, and Linux/Windows packaging. Linux packaging passed after retrying a hidden-renderer test timeout.