Skip to content

perf(fmt): optimize root gitignore matching - #166

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/gitignore-root-matcher-fast-path
Aug 4, 2026
Merged

perf(fmt): optimize root gitignore matching#166
chenjiahan merged 1 commit into
mainfrom
chenjiahan/gitignore-root-matcher-fast-path

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

Most projects only have a root .gitignore, but formatting discovery still walked every path segment and performed matcher map lookups for each candidate. This PR directly uses the root matcher when it is the only loaded matcher, while retaining layered matching as soon as a nested .gitignore is present.

Benchmark

discoverFmtPaths("packages") with 10,001 candidate files (representative path depth: 7), only a root .gitignore, Node.js v24.12.0 on macOS arm64. Median of 20 runs after 5 warmups:

Before After
End-to-end discovery 144.50 ms 94.68 ms

This reduces discovery time by 34.5%, a 1.53× speedup.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 95ccf7e
Status: ✅  Deploy successful!
Preview URL: https://c773727a.rstack-cli.pages.dev
Branch Preview URL: https://chenjiahan-gitignore-root-ma.rstack-cli.pages.dev

View logs

@chenjiahan
chenjiahan merged commit 26c6c5a into main Aug 4, 2026
4 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/gitignore-root-matcher-fast-path branch August 4, 2026 00:02
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