Skip to content

perf(ci): persist V8 compile cache across test jobs#6009

Merged
killagu merged 4 commits into
nextfrom
feat/ci-node-compile-cache
Jun 28, 2026
Merged

perf(ci): persist V8 compile cache across test jobs#6009
killagu merged 4 commits into
nextfrom
feat/ci-node-compile-cache

Conversation

@killagu

@killagu killagu commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What

Enable Node's on-disk V8 compile cache (NODE_COMPILE_CACHE) for the three test jobs (test, test-egg-bin, test-egg-scripts) and persist it with actions/cache:

  • Job-level env.NODE_COMPILE_CACHE: ${{ runner.temp }}/node-compile-cache so the value is inherited by vitest workers and any forked child processes, not just the top-level process.
  • A Cache Node compile cache step (pinned actions/cache@0057852… # v4, the same pin already used for the utoo store) keyed node-compile-cache-${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }} with graduated restore-keys, so the cache survives within a run (shared across processes) and across runs.

typecheck is intentionally excluded — it runs tsgo/oxlint/tsdown (Rust), not Node module execution, so there is nothing for the V8 compile cache to help.

Safety: Node validates each cache entry by source hash + Node version, so a stale restored entry is simply ignored (cache miss → recompile + rewrite). The change is low-risk and fully reversible.

Honest measurement (please validate on CI before marking ready)

Opened as draft because the local benefit I could measure is ~0 and the CI/Windows benefit is unverified:

  • On macOS/arm64, an A/B/C micro-benchmark of the egg-bin fork bootstrap (a full egg-bin test run, which populates 1346 cache files / 7.7 MB) showed no measurable speedup — warm-cache runs landed inside the no-cache noise band (20.3–22.4s), and were marginally slower due to flushCompileCache write overhead on exit.
  • Reason: per-fork wall time is dominated by the oxc transform and module import (transform 1.51s + import 1.56s of a 2.9s run), plus process spawn — and the compile cache only caches the V8 compilation of already-transpiled JS, not the transform itself.
  • The case for keeping it rests on the CI runners being much slower at exactly the V8-compile + file-read work the cache removes (x64 ubuntu, and especially Windows) than an M-series Mac. That is plausible but unmeasured here. On Windows there is even a downside risk: a cache hit adds an extra file read per module (source + cache blob), and every file open is scanned by Defender, so it could be neutral or negative.

How to validate: compare the test-job step durations run-over-run (the existing Report parallelism metrics job already surfaces CI timing), and/or check cache hit-rate in the Actions cache UI. Keep if it helps a platform; drop the env+step if not.

Scope note

This does not touch tools/egg-bin/test/coffee.ts, which forks the egg-bin CLI ~109× with a freshly-built env that does not pass NODE_COMPILE_CACHE through — so the compile cache does not currently reach those forks. That (and the Windows test-egg-bin slowdown generally) is being investigated separately on a Windows machine and is out of scope for this PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved CI build and test performance by enabling a Node.js compile-cache mechanism for relevant test jobs.
  • Tests
    • Ensured compile-cache tests run with a clean environment by resetting related cache settings before each test.
    • Made the subscription interval/cron test more reliable in CI by increasing the wait time before log-based assertions.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: f1889ed
Status: ✅  Deploy successful!
Preview URL: https://8a804420.egg-v3.pages.dev
Branch Preview URL: https://feat-ci-node-compile-cache.egg-v3.pages.dev

View logs

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4488636b-f520-4f0e-b07e-a0abe85559b9

📥 Commits

Reviewing files that changed from the base of the PR and between 4600f08 and f1889ed.

📒 Files selected for processing (1)
  • plugins/schedule/test/subscription.test.ts

📝 Walkthrough

Walkthrough

Adds Node.js compile cache support to three GitHub Actions CI jobs, clears compile-cache env vars before manifest tests, and makes one subscription test wait longer on CI.

Changes

Node Compile Cache CI and Test Isolation

Layer / File(s) Summary
CI compile cache steps for test jobs
.github/workflows/ci.yml
Adds cache and NODE_COMPILE_CACHE export steps to the test, test-egg-bin, and test-egg-scripts jobs.
Test env cleanup for compile cache
packages/core/test/loader/manifest.test.ts
Adds beforeEach to clear NODE_COMPILE_CACHE, NODE_COMPILE_CACHE_PORTABLE, and NODE_DISABLE_COMPILE_CACHE before each compile-cache test.
CI-aware subscription delay
plugins/schedule/test/subscription.test.ts
Changes the subscription test delay to 10 seconds on CI and 5 seconds otherwise before log assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • eggjs/egg#5855: Introduces the compile-cache behavior and env vars that this PR’s test cleanup is aligned with.

Suggested reviewers

  • jerryliang64
  • fengmk2

🐇 I cached my hops in little jars,
and waited longer under CI stars.
Clean env, fresh tests, logs in line,
three jobs now compile just fine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: persisting the V8 compile cache across CI test jobs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ci-node-compile-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@socket-security

socket-security Bot commented Jun 28, 2026

Copy link
Copy Markdown

Dependency limit exceeded — report not shown.

This pull request scan exceeded the 10,000-dependency limit applied to this scan, so the results are incomplete and may be inaccurate. To avoid reporting false positives, Socket has not posted a report.

Upgrade your plan to raise the dependency limit and get complete reports, or view the partial scan in the dashboard.

Socket is always free for open source. If this is a non-commercial open source project, contact us to request a free Team account.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: f1889ed
Status: ✅  Deploy successful!
Preview URL: https://ba5977da.egg-cci.pages.dev
Branch Preview URL: https://feat-ci-node-compile-cache.egg-cci.pages.dev

View logs

Set NODE_COMPILE_CACHE on the test, test-egg-bin and test-egg-scripts
jobs and restore/save that directory with actions/cache, so Node's V8
compile cache survives within a run (shared by vitest workers and forked
child processes) and across runs. Internally the cache is keyed by source
hash + Node version, so stale restored entries are safely ignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@killagu killagu force-pushed the feat/ci-node-compile-cache branch from f913829 to d1ac887 Compare June 28, 2026 01:53
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.94%. Comparing base (92c47ea) to head (f1889ed).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #6009   +/-   ##
=======================================
  Coverage   81.94%   81.94%           
=======================================
  Files         677      677           
  Lines       20651    20651           
  Branches     4099     4099           
=======================================
+ Hits        16922    16923    +1     
  Misses       3215     3215           
+ Partials      514      513    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

killagu and others added 2 commits June 28, 2026 10:04
enableCompileCache() intentionally respects an externally-set
NODE_COMPILE_CACHE (early-returns), so the new job-wide CI NODE_COMPILE_CACHE
made the 'set env vars' assertion read the CI path instead of the auto-set
.egg/compile-cache path. Clear the ambient compile-cache env vars in a
beforeEach so these tests exercise the auto-set path from a clean slate; the
existing afterEach restores them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@killagu killagu marked this pull request as ready for review June 28, 2026 08:48
Copilot AI review requested due to automatic review settings June 28, 2026 08:48

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

The `cluster - subscription` test forks an egg cluster (agent + 1 worker)
and asserts the `interval` (4000ms) and `cron` (*/5s) schedules each log at
least once. It only waited `sleep(5000)`, leaving ~1s of slack for the
forked agent/worker boot + IPC + log flush. On busy CI runners (notably
Windows, which is not skipped here unlike schedule-plugin/safe-timers) the
task occasionally fires zero times in the window, producing the flaky
`expected 0 to be greater than or equal to 1`.

Widen the CI wait to 10s, matching the existing `customTypeError.test.ts`
mitigation, so the 4000ms interval reliably fires at least once.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@killagu killagu merged commit a2f553e into next Jun 28, 2026
27 checks passed
@killagu killagu deleted the feat/ci-node-compile-cache branch June 28, 2026 11:18
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