Skip to content

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

Closed
killagu wants to merge 1 commit into
eggjs:nextfrom
killagu:feat/ci-node-compile-cache
Closed

perf(ci): persist V8 compile cache across test jobs#6008
killagu wants to merge 1 commit into
eggjs:nextfrom
killagu: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 the test pipeline’s caching so repeated runs can reuse compiled artifacts more effectively.
    • This should help speed up automated checks and make CI runs more efficient.

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>
@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

📝 Walkthrough

Walkthrough

Three CI jobs (test, test-egg-bin, test-egg-scripts) each gain a job-level NODE_COMPILE_CACHE environment variable and a new actions/cache step that restores and saves the V8 Node compile cache directory, keyed by OS, Node version, and package manifests.

Changes

CI Node Compile Cache

Layer / File(s) Summary
NODE_COMPILE_CACHE env and cache steps
.github/workflows/ci.yml
All three test jobs add a NODE_COMPILE_CACHE env pointing to runner.temp/node-compile-cache and a preceding actions/cache step with OS+Node+manifest-based keys.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • eggjs/egg#6006: Adds the utoo package store cache steps to the same three CI jobs in the same workflow file.

Poem

🐇 Hop hop, cache away!
V8 compiled bytes preserved each day,
The rabbit stashes code with glee,
No recompile for you or me.
Workflows faster, tests take flight! 🚀

🚥 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 clearly summarizes the main CI performance change: persisting the V8 compile cache across 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 unit tests (beta)
  • Create PR with unit tests

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

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.

@killagu killagu marked this pull request as ready for review June 28, 2026 01:45
Copilot AI review requested due to automatic review settings June 28, 2026 01:45

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 89-94: runner.temp is not valid in jobs.<job>.env, so update the
job-level NODE_COMPILE_CACHE definition in the CI workflow to use
github.workspace or move it into step-level env instead. Make the same
adjustment in the other two job-level env blocks that currently reference
runner.temp, and keep the change aligned with the existing cache setup around
NODE_COMPILE_CACHE.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8a84655-2604-40fe-9325-b894ed9fc24b

📥 Commits

Reviewing files that changed from the base of the PR and between 6900383 and f913829.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Comment thread .github/workflows/ci.yml
Comment on lines +89 to +94
env:
# Persisted V8 compile cache (restored/saved by the "Cache Node compile
# cache" step). Set at job level so vitest workers and any forked child
# processes inherit NODE_COMPILE_CACHE.
NODE_COMPILE_CACHE: ${{ runner.temp }}/node-compile-cache

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.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

runner.temp isn't available in jobs.<job>.env.
Use ${{ github.workspace }} here, or move this to step-level env, and apply the same fix to the other two job-level blocks.

🧰 Tools
🪛 actionlint (1.7.12)

[error] 93-93: context "runner" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "secrets", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 89 - 94, runner.temp is not valid in
jobs.<job>.env, so update the job-level NODE_COMPILE_CACHE definition in the CI
workflow to use github.workspace or move it into step-level env instead. Make
the same adjustment in the other two job-level env blocks that currently
reference runner.temp, and keep the change aligned with the existing cache setup
around NODE_COMPILE_CACHE.

@killagu

killagu commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #6009. CI did not trigger here because this branch was on my fork (killagu/egg) and the PR modifies .github/workflows/ci.yml — GitHub won't run a workflow whose own file is changed by a fork PR. Re-opened from a same-repo branch in #6009.

@killagu killagu closed this Jun 28, 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.

2 participants