Skip to content

Reuse FileExcluder instances in IgnoredError::shouldIgnore()#6055

Closed
staabm wants to merge 1 commit into
phpstan:2.2.xfrom
staabm:re-use
Closed

Reuse FileExcluder instances in IgnoredError::shouldIgnore()#6055
staabm wants to merge 1 commit into
phpstan:2.2.xfrom
staabm:re-use

Conversation

@staabm

@staabm staabm commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

A fresh FileExcluder was constructed for every (error, ignore entry with a path) pair - each construction normalizes the path, runs a preg_match and stats the filesystem via is_file/is_dir. With a large baseline this ran tens of thousands of times per run. Memoize the excluder per working directory + path.

picked from https://github.com/phpstan/phpstan-src/commits/worktree-spx-perf-hunt/

A fresh FileExcluder was constructed for every (error, ignore entry
with a path) pair - each construction normalizes the path, runs a
preg_match and stats the filesystem via is_file/is_dir. With a large
baseline this ran tens of thousands of times per run. Memoize the
excluder per working directory + path.
@staabm staabm closed this Jul 16, 2026
@staabm

staabm commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

I had a workload which is marginally slow on IgnoredError::shouldIgnore but this patch does not fix it

@staabm
staabm deleted the re-use branch July 16, 2026 08:20
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