Skip to content

perf(fmt): reuse compiled gitignore rules and release traversal state - #590

Merged
chenjiahan merged 4 commits into
mainfrom
chenjiahan/reuse-gitignore-compilation
Oct 22, 2026
Merged

chenjiahan merged 4 commits into
mainfrom
chenjiahan/reuse-gitignore-compilation

Conversation

@chenjiahan

@chenjiahan chenjiahan commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Motivation

Monorepos often repeat the same .gitignore contents across packages. rs fmt currently compiles each copy independently and leaves native matcher cleanup to garbage collection.

Changes

Share compiled rules by exact contents using Arc<Gitignore>, while keeping each directory's matching state independent. Explicitly release compiled rules and directory caches after traversal, including failure paths, once all concurrent traversals have settled.

Benchmarked on a large monorepo with 56,583 formatted files and 258 .gitignore sources (60 unique contents), using Node.js 22.16.0, 8 workers, no format cache, and the same patched Prettier 3.9.10 in both variants:

Metric Before After
File discovery, median of 8 fresh processes 420.9 ms 358.2 ms
Matcher live allocations before cleanup 37.9 MiB 12.8 MiB
Whole-repository check, median of 10 fresh processes 16.75 s 16.73 s

Discovery is 14.9% faster; whole-repository timings are effectively unchanged within run-to-run variation. Allocation tracking confirms explicit cleanup releases matcher data to the same level as dropping the matcher. With 258 distinct contents, the cache adds about 114 KiB.

Validation: Rust and formatting-related tests passed, along with lint, type, and format checks. All 59,817 discovery requests, 38,556 replayed native call results, and existing benchmark diagnostics match the baseline.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T02:49:47.542301Z 2c65523 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0a5e53a
Status:🚫  Build failed.

View logs

@chenjiahan
chenjiahan enabled auto-merge (squash) October 22, 2026 03:09
@chenjiahan
chenjiahan merged commit 5fe9881 into main Oct 22, 2026
4 of 5 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/reuse-gitignore-compilation branch October 22, 2026 03:10
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