Skip to content

perf(cli): Propagate compile cache to child_process workers#1255

Merged
yamadashy merged 1 commit intomainfrom
perf/propagate-compile-cache-to-workers
Mar 20, 2026
Merged

perf(cli): Propagate compile cache to child_process workers#1255
yamadashy merged 1 commit intomainfrom
perf/propagate-compile-cache-to-workers

Conversation

@yamadashy
Copy link
Copy Markdown
Owner

@yamadashy yamadashy commented Mar 20, 2026

The existing enableCompileCache() in bin/repomix.cjs only applied to the main process. Tinypool child_process workers (defaultAction) were spawned without compile cache because NODE_COMPILE_CACHE env var was not set.

This PR captures the cache directory from enableCompileCache()'s return value and sets it as NODE_COMPILE_CACHE env var, so child_process workers inherit it at startup — before any ESM static imports are resolved.

Note: worker_threads workers (fileProcess, securityCheck, calculateMetrics) already benefit from the main process's enableCompileCache() call since they share the same V8 isolate.

Checklist

  • Run npm run test
  • Run npm run lint

🤖 Generated with Claude Code


Open with Devin

The existing enableCompileCache() in bin/repomix.cjs only applied to the
main process. Tinypool child_process workers (defaultAction) were spawned
without compile cache because NODE_COMPILE_CACHE env var was not set.

Capture the cache directory from enableCompileCache()'s return value and
set it as NODE_COMPILE_CACHE env var so child_process workers inherit it
at startup — before any ESM static imports are resolved.

Note: worker_threads workers (fileProcess, securityCheck, calculateMetrics)
already benefit from the main process's enableCompileCache() call since
they share the same V8 isolate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f2bc2244-d24e-4599-a3ba-11b5b6678866

📥 Commits

Reviewing files that changed from the base of the PR and between f0393f7 and e0971a1.

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

📝 Walkthrough

Walkthrough

The change modifies bin/repomix.cjs to capture the return value from nodeModule.enableCompileCache() and conditionally sets process.env.NODE_COMPILE_CACHE to the cache directory when not already set, enabling environment variable inheritance by child processes at startup.

Changes

Cohort / File(s) Summary
Compile Cache Configuration
bin/repomix.cjs
Captures the return value from enableCompileCache() and conditionally assigns the cache directory to process.env.NODE_COMPILE_CACHE if not already set, propagating compile cache location to child processes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: propagating compile cache to child_process workers, which is the primary objective of this performance optimization PR.
Description check ✅ Passed The description covers the problem (child_process workers lack compile cache), the solution (set NODE_COMPILE_CACHE env var), and includes the required checklist with completed items.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/propagate-compile-cache-to-workers

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.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 optimizes application performance by addressing an oversight in the Node.js compile cache implementation. Previously, only the main process benefited from the compile cache, leaving child_process workers to start without this optimization. The changes now correctly configure the environment to ensure these workers inherit the compile cache, leading to more efficient module loading and faster startup times across all worker types.

Highlights

  • Compile Cache Propagation: Extended Node.js compile cache functionality to child_process workers by capturing the cache directory and propagating it via the NODE_COMPILE_CACHE environment variable.
  • Performance Improvement: Ensured child_process workers, particularly those spawned by tinypool for defaultAction, now benefit from compile caching, which is critical for ESM static imports and improves startup performance.

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

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.

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.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 20, 2026

Code Review

Overall: Approve - Clean, minimal, and well-reasoned change.

Summary

This PR correctly propagates the compile cache directory to child_process workers by setting NODE_COMPILE_CACHE env var from the enableCompileCache() return value. The change is small (+7/-1), focused, and well-documented.

What's Good

  • Correct guard logic: The !process.env.NODE_COMPILE_CACHE check respects externally-set values, avoiding overwriting user configuration
  • Defensive null checks: result && result.directory safely handles cases where enableCompileCache() returns without a directory (e.g., status: 'failed')
  • Stays inside the existing try/catch: Any unexpected behavior from the return value is already caught
  • Clear comments explaining why this matters (ESM static imports in child_process workers)
  • Good commit message with context about worker_threads vs child_process distinction

Minor Observations

Details
  1. Node.js version compatibility: enableCompileCache() was added in Node.js v22.1.0 and the return type {status, directory, message} is stable. Since this code already guards on nodeModule.enableCompileCache existence, the new .directory access is safe on older Node versions too.

  2. result.status not checked: The code doesn't check result.status === 'enabled' before using result.directory. Per the Node.js docs, directory can be present even when status is 'already_enabled', which is actually fine — the directory is still valid in that case. No issue here.

  3. No test coverage: This is a bootstrap file (bin/repomix.cjs) that runs before any test infrastructure loads, so it's inherently difficult to unit test. The existing approach of no tests for this file is reasonable. The behavior can be verified manually by checking process.env.NODE_COMPILE_CACHE in a child worker.

Premortem Analysis

Details
Scenario Risk Mitigation
enableCompileCache() returns undefined on some Node version Low Guarded by result && result.directory
NODE_COMPILE_CACHE dir doesn't exist when child reads it Very Low Node.js handles this gracefully — cache misses are not errors
User sets NODE_COMPILE_CACHE externally to a different dir None The !process.env.NODE_COMPILE_CACHE guard preserves user preference
NODE_DISABLE_COMPILE_CACHE is set None Outer if already skips the entire block

No significant risks identified. This is a safe, backwards-compatible performance improvement.

LGTM — ready to merge.

🤖 Generated with Claude Code

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 improves performance by propagating the Node.js compile cache to child_process workers. The implementation correctly captures the cache directory from enableCompileCache() and sets the NODE_COMPILE_CACHE environment variable, allowing child processes to inherit and utilize the cache. The code is robust, with checks to ensure it only runs when caching is available and not explicitly disabled, and it safely handles potential errors. The change is well-contained and effectively addresses the issue of child processes not using the compile cache.

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

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

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: e0971a1
Status: ✅  Deploy successful!
Preview URL: https://529a2c82.repomix.pages.dev
Branch Preview URL: https://perf-propagate-compile-cache.repomix.pages.dev

View logs

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@f0393f7). Learn more about missing BASE report.
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1255   +/-   ##
=======================================
  Coverage        ?   87.18%           
=======================================
  Files           ?      115           
  Lines           ?     4324           
  Branches        ?     1002           
=======================================
  Hits            ?     3770           
  Misses          ?      554           
  Partials        ?        0           

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

@github-actions
Copy link
Copy Markdown
Contributor

⚡ Performance Benchmark

Packing the repomix repository with node bin/repomix.cjs

Runner PR main Diff
Ubuntu 2.52s (±0.01s) 2.54s (±0.03s) -0.02s (-0.8%)
macOS 1.37s (±0.13s) 1.39s (±0.11s) -0.02s (-1.5%)
Windows 3.05s (±0.04s) 3.02s (±0.04s) +0.03s (+1.0%)
Details
  • Warmup: 2 runs (discarded)
  • Measurement: 10 runs (median)
  • ±: IQR (Interquartile Range) — middle 50% of measurements spread
  • Workflow run

@yamadashy yamadashy merged commit 99fdc2b into main Mar 20, 2026
63 checks passed
@yamadashy yamadashy deleted the perf/propagate-compile-cache-to-workers branch March 20, 2026 16:31
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