perf(nav): reduce code-rank path canonicalization and membership overhead - #12
Draft
ClaudiuCeia with Copilot wants to merge 2 commits into
Draft
ClaudiuCeia with Copilot wants to merge 2 commits into
ClaudiuCeia with Copilot wants to merge 2 commits into
Conversation
- Replace Array.includes with Set in createService target-file deduplication - Export createCachedBoundaryChecker from service.ts for per-run path canonicalization caching (each distinct path resolved via realpathSync at most once per rankCode call) - Use createCachedBoundaryChecker in rankCode / collectReferenceStats - Add createCodeRankFixture helper to bench/suites/fixtures.ts - Add nav/code-rank benchmark group to bench/suite.ts - Add createCachedBoundaryChecker unit tests in service.test.ts - Add symlink filtering and canonical-path deduplication tests in code-rank.test.ts
Copilot
AI
changed the title
[WIP] Optimize code-rank path and membership checks
perf(nav): reduce code-rank path canonicalization and membership overhead
Jul 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each
rankCoderun was callingrealpathSyncon every reference file path — including repeats — and usingArray.includesfor O(n²) target deduplication increateService.Changes
packages/nav/src/service.tsfileNames.includes(resolved)→fileNameSet.has(resolved), making target membership O(1) after setupcreateCachedBoundaryChecker(boundary)(new export): returns a(path: string) => booleanclosure backed by aMapcache — each distinct path hitsrealpathSyncat most once per checker lifetimepackages/nav/src/code-rank/rank.tsisWithinBoundarychecker perrankCodecall; passes it intocollectReferenceStatsas a plain predicatecollectReferenceStatssignature drops theboundaryobject in favor of(filePath: string) => boolean— simpler and cache-awareBenchmark
bench/suites/fixtures.ts: addscreateCodeRankFixture— hub-and-spoke TS workspace (one hub with N×M exports, N spoke files each calling their slice)bench/suite.ts: newnav/code-rankgroup benchmarking 50-file × 4-export fixtureTests
service.test.ts: unit tests forcreateCachedBoundaryChecker— inside paths, outside paths, symlinks resolving outside the boundarycode-rank.test.ts: symlinked files resolving outside the git boundary are excluded fromreferencingFiles; symbol deduplication produces no duplicate entries