Skip to content

Reduce matching allocations and skip unrelated ignore rules - #30

Merged
andrew merged 3 commits into
mainfrom
perf-literal-suffix
Sep 13, 2026
Merged

Reduce matching allocations and skip unrelated ignore rules#30
andrew merged 3 commits into
mainfrom
perf-literal-suffix

Conversation

@andrew

@andrew andrew commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Common path matches now avoid heap allocation, rules from unrelated directory scopes are skipped as groups, and directory walks reuse parent checks and discard rules after leaving a subtree. Basename patterns also avoid scanning earlier path components. The public API is unchanged.

Local benchmarks show zero allocations for common matches, about 27% fewer allocated bytes when loading 1,000 scoped rules, and about 14% fewer allocated bytes for a wide directory walk. Timing results remain noisy, with some runs reporting regressions, so these figures describe allocation reductions only.

Adds benchmarks for construction, path depth, rule ordering, sibling scopes, wildcard shapes, parallel matching, and traversal, plus Git conformance coverage for nested walks and tests for deep paths, concurrent matching, and interleaved scopes. Documents how to collect benchmark samples and clarifies parent-directory exclusion.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved blocking issues were identified.

Pull request overview

Optimizes gitignore matching and directory traversal while preserving the public API.

Changes:

  • Groups scoped rules and skips unrelated scopes.
  • Reduces matching allocations and reuses parent checks.
  • Adds benchmarks, conformance coverage, concurrency tests, and documentation.
File summaries
File Description
README.md Documents matching semantics and benchmark methodology.
performance_test.go Adds performance, concurrency, and traversal tests.
gitignore.go Implements grouped matching and traversal optimizations.
gitignore_bench_test.go Adds literal-match benchmarks.
conformance_test.go Adds nested-walk conformance coverage.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@andrew
andrew force-pushed the perf-literal-suffix branch from 78300c9 to 4e5369e Compare September 13, 2026 00:37
@andrew
andrew merged commit e35f1a8 into main Sep 13, 2026
7 checks passed
@andrew
andrew deleted the perf-literal-suffix branch September 13, 2026 00:38
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.

2 participants