perf: resolve dependency directories without Node's module resolver - #276
Conversation
|
Warning Review limit reachedNext included review available in 13 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe dependency resolver now walks ChangesDependency Discovery Optimization
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to Dependency discovery is optimized while preserving the tested package-resolution and skill-discovery behavior. No current merge-blocking risk was identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 3 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
🧪 Generate unit tests (beta)
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. Comment |
53c5f79 to
f7a1e23
Compare
|
View your CI Pipeline Execution ↗ for commit c8bda69
☁️ Nx Cloud last updated this comment at |
commit: |
f7a1e23 to
a48cb72
Compare
a48cb72 to
1ad4b25
Compare
`resolveDepDir` used `createRequire().resolve('<dep>/package.json')` for
every dependency edge in the scan. Node's resolver evaluates export maps,
reads the nearest package.json, and realpaths each path segment per call;
in a pnpm monorepo that was two thirds of `intent list` time.
Replace it with the plain `node_modules` ancestor walk the function
already used as a fallback (skipping `node_modules/node_modules` like
Node does), collapsing a symlinked match with one lstat and one native
realpath. Discovered packages and their roots are unchanged.
Also resolve a package's real root once per package in skill discovery
instead of once per skill file.
1ad4b25 to
c8bda69
Compare
Summary
First of a three-PR perf stack (this → lazy scan path → bundled deps).
resolveDepDircalledcreateRequire().resolve('<dep>/package.json')for every dependency edge in the scan. Node's resolver evaluates export maps, reads the nearestpackage.json, and realpaths every path segment per call. A CPU profile ofintent listat this repo's root (pnpm monorepo, 438 package.json reads) put 624 of ~940 ms inside that call, withlstatandinternalModuleStatas the top self-time entries.This PR:
node_modulesancestor walk the function already used as a fallback. It skipsnode_modules/node_modulesancestors like Node does and collapses a symlinked match (pnpm virtual store, workspace links) with onelstatplus one nativerealpath.readSkillEntrydid three realpath calls per skill).resolveDepDircovering nested, hoisted, scoped, virtual-store sibling, symlinked, and missing cases.Measurements (Windows 11, warm cache, import + run of
main(['list']))example/start-basic(npm, 7 pkgs / 24 skills)intent list --jsonoutput onexample/start-basicis byte-identical to main, and--debugstats (package.json read count) are unchanged at the repo root.Summary by CodeRabbit
Performance
intent listrunning approximately 30% faster in pnpm monorepos.Bug Fixes