Skip to content

perf: minor render and file-collection optimizations - #156

Merged
konradmichalik merged 3 commits into
mainfrom
perf/micro-optimizations
Jul 28, 2026
Merged

perf: minor render and file-collection optimizations#156
konradmichalik merged 3 commits into
mainfrom
perf/micro-optimizations

Conversation

@konradmichalik

@konradmichalik konradmichalik commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Two small, safe optimizations from the performance review:

  • Exclude patterns: the file collector evaluated every exclude pattern for each file. It now short-circuits on the first match.
  • Path normalization: the result renderer resolved the working directory (getcwd() + realpath()) for every path while grouping issues. It now resolves it once per renderer instance.

Changes

  • src/FileDetector/Collector.phpmatchesAnyPattern() helper with early return
  • src/Result/AbstractValidationResultRenderer.php — cache the resolved working directory per instance

Summary by CodeRabbit

  • Bug Fixes
    • Improved file exclusion pattern matching for more consistent filtering.
    • Improved path normalization reliability by caching the resolved working directory during validation result rendering.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@konradmichalik, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 23 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ed9c64d9-fd33-4131-b81a-081a1d9cf39d

📥 Commits

Reviewing files that changed from the base of the PR and between 1f9a7bd and 020e492.

📒 Files selected for processing (1)
  • src/FileDetector/Collector.php
📝 Walkthrough

Walkthrough

The changes extract file exclusion matching into a short-circuiting helper and memoize current working-directory resolution in validation result renderers.

Changes

File exclusion matching

Layer / File(s) Summary
Exclude-pattern matching
src/FileDetector/Collector.php
collectFiles() now delegates exclusion checks to matchesAnyPattern(), which stops at the first matching pattern.

Working-directory resolution

Layer / File(s) Summary
Cached working-directory resolution
src/Result/AbstractValidationResultRenderer.php
normalizePath() uses a memoized resolvedCwd() helper that records successful and failed resolution results.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR’s two performance optimizations in file collection and result rendering.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/micro-optimizations

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@konradmichalik

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/FileDetector/Collector.php (1)

164-180: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Missing @param annotation for $basename.

The docblock annotates @param string[] $patterns but omits @param string $basename.

📝 Suggested fix
     /**
      * Returns true as soon as the basename matches any exclude pattern,
      * short-circuiting instead of evaluating every pattern.
      *
+     * `@param` string   $basename
      * `@param` string[] $patterns
      */
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/FileDetector/Collector.php` around lines 164 - 180, Add the missing
`@param string $basename` annotation to the docblock for `matchesAnyPattern`,
alongside the existing `$patterns` annotation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/FileDetector/Collector.php`:
- Around line 164-180: Add the missing `@param string $basename` annotation to
the docblock for `matchesAnyPattern`, alongside the existing `$patterns`
annotation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1fb91296-a3c6-4dc6-95bc-4f7315bf88b5

📥 Commits

Reviewing files that changed from the base of the PR and between c69ebc9 and 1f9a7bd.

📒 Files selected for processing (2)
  • src/FileDetector/Collector.php
  • src/Result/AbstractValidationResultRenderer.php

@konradmichalik
konradmichalik merged commit 125d787 into main Jul 28, 2026
26 checks passed
@konradmichalik
konradmichalik deleted the perf/micro-optimizations branch July 28, 2026 09:50
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