Skip to content

perf(cli): Enable Node.js module compile cache for faster startup#1181

Merged
yamadashy merged 1 commit intomainfrom
perf/enable-compile-cache
Feb 24, 2026
Merged

perf(cli): Enable Node.js module compile cache for faster startup#1181
yamadashy merged 1 commit intomainfrom
perf/enable-compile-cache

Conversation

@yamadashy
Copy link
Copy Markdown
Owner

@yamadashy yamadashy commented Feb 24, 2026

Enable V8 compile cache via module.enableCompileCache() in the CLI entry point to speed up startup by caching compiled bytecode across runs.

  • Available on Node.js >= 22.8.0, gracefully skipped on older versions
  • Can be disabled via NODE_DISABLE_COMPILE_CACHE env var
  • Benchmark results (--version, 50 runs each, sequential):
Mean σ Min Max
with compile cache 151.4ms ±8.2ms 139.5ms 182.3ms
without compile cache 167.4ms ±12.5ms 153.8ms 213.4ms

~10% startup improvement with zero downside.

Reference: https://nodejs.org/api/module.html#module-compile-cache

Checklist

  • Run npm run test
  • Run npm run lint

Open with Devin

Enable V8 compile cache via module.enableCompileCache() to speed up
CLI startup by caching compiled bytecode across runs.

Benchmarks show ~10% improvement in startup time (148ms vs 165ms).
Available on Node.js >= 22.8.0, gracefully skipped on older versions.
Can be disabled via NODE_DISABLE_COMPILE_CACHE env var.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @yamadashy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a significant performance optimization for the CLI by activating the Node.js module compile cache. By leveraging V8's ability to cache compiled JavaScript bytecode, the change aims to reduce application startup times, providing a faster and more efficient user experience without introducing any regressions or requiring user configuration.

Highlights

  • Node.js Module Compile Cache Enabled: The V8 compile cache has been enabled via module.enableCompileCache() in the CLI entry point. This change aims to speed up startup by caching compiled bytecode across runs.
  • Compatibility and Control: This feature is available on Node.js versions 22.8.0 and newer, and is gracefully skipped on older versions. Users can disable it by setting the NODE_DISABLE_COMPILE_CACHE environment variable.
  • Performance Improvement: Benchmark results indicate approximately a 10% improvement in startup time, with no identified downsides.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • bin/repomix.cjs
    • Added conditional logic to enable the Node.js module compile cache at the application's entry point.
    • Included a try-catch block to gracefully handle potential errors during cache enablement.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59094bf and 90e31a3.

📒 Files selected for processing (1)
  • bin/repomix.cjs

📝 Walkthrough

Walkthrough

A Node.js compile cache enablement block is added to the entry point. The code conditionally enables the compile cache feature by checking for module availability and environment configuration before the existing startup logic executes.

Changes

Cohort / File(s) Summary
Node.js Compile Cache Initialization
bin/repomix.cjs
Adds Node.js compile cache enablement at startup. Requires the node:module, checks for enableCompileCache availability and NODE_DISABLE_COMPILE_CACHE environment variable, then invokes the cache setup within error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: enabling Node.js module compile cache for CLI performance improvement.
Description check ✅ Passed The description covers the purpose, Node.js version requirements, environment variable control, and includes benchmark data demonstrating the improvement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch perf/enable-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 and usage tips.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a performance improvement by enabling the Node.js module compile cache, which should speed up CLI startup. The implementation is sound, with checks for feature availability and an option to disable it via an environment variable. My only suggestion is to enhance debuggability by logging any errors encountered when enabling the cache, but only in verbose mode to avoid unnecessary output for users.

Comment on lines +8 to +10
} catch {
// Ignore errors
}
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.

medium

Silently ignoring errors in the catch block can make debugging difficult if enableCompileCache() fails for an unexpected reason (e.g., file system permissions). While this feature is a non-critical performance optimization, it would be beneficial to log the error when in verbose mode. This provides visibility for debugging why the cache isn't working, without adding noise for regular users.

  } catch (error) {
    if (process.argv.includes('--verbose')) {
      console.warn('Warning: Failed to enable Node.js compile cache:', error);
    }
  }

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: 90e31a3
Status: ✅  Deploy successful!
Preview URL: https://2250f336.repomix.pages.dev
Branch Preview URL: https://perf-enable-compile-cache.repomix.pages.dev

View logs

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.14%. Comparing base (59094bf) to head (90e31a3).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1181   +/-   ##
=======================================
  Coverage   87.14%   87.14%           
=======================================
  Files         115      115           
  Lines        4310     4310           
  Branches      998      998           
=======================================
  Hits         3756     3756           
  Misses        554      554           

☔ View full report in Codecov by Sentry.
📢 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.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Feb 24, 2026

Code Review — PR #1181

perf(cli): Enable Node.js module compile cache for faster startup

Overall Assessment

Clean, minimal change that enables V8 compile cache for ~10% startup improvement with no downside. The implementation is well-guarded with feature detection and error handling. Looks good to merge.

Observations

Strengths:

  • Feature detection via nodeModule.enableCompileCache check ensures backward compatibility with Node.js < 22.8.0
  • Try-catch prevents any startup failure from a non-critical optimization
  • Zero-config — uses the default temp directory, no user setup needed
  • Benchmark data in the PR description is thorough and convincing
Minor Suggestion (non-blocking)

Redundant NODE_DISABLE_COMPILE_CACHE check:

The explicit !process.env.NODE_DISABLE_COMPILE_CACHE guard on line 5 is not strictly necessary. According to the Node.js docs, when NODE_DISABLE_COMPILE_CACHE=1 is set, enableCompileCache() already handles it gracefully — it returns { status: compileCacheStatus.DISABLED } without throwing. The try-catch would cover any edge case regardless.

That said, the explicit check does make the intent clearer to readers and avoids even calling the function unnecessarily, so keeping it is perfectly fine. It's a matter of style preference.

Premortem Analysis

Scenario Risk Mitigation
Cache corruption (e.g., disk full, interrupted write) Low Node.js handles cache miss gracefully — falls back to uncached compilation
Stale cache after Node.js upgrade Low V8 invalidates caches that don't match the engine version
Disk space usage from cached bytecode Negligible Cache is stored in OS temp directory, cleaned by OS policies
Unexpected behavior in CI/testing environments Low NODE_DISABLE_COMPILE_CACHE env var provides an escape hatch

CI Status

All Linux and most cross-platform checks are passing. Some Windows and macOS jobs are still in progress but the completed ones (including Windows Node 25.x, macOS Node 22.x) passed successfully.

Verdict

LGTM. The change is minimal, well-guarded, and provides a measurable improvement. No blocking issues.

@yamadashy yamadashy merged commit 04d0577 into main Feb 24, 2026
59 checks passed
@yamadashy yamadashy deleted the perf/enable-compile-cache branch February 24, 2026 15:34
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.

1 participant