Fix/clean unused components performance#2030
Merged
DerManoMann merged 3 commits intoJun 29, 2026
Merged
Conversation
Replace the O(n*m) AnnotationTrait-based removal with direct recursive removal via Analysis::removeAnnotation(), and use isset() instead of in_array() for ref lookups. This eliminates the expensive full-tree traversal that occurred for every removed component. Adds a performance regression test (composer performance) that asserts cleanup overhead stays below 1.5x of base generation time. Benchmarked: 1000 schemas, 500 unused — old code: 313s, new code: 5s. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The recurseCleanup flag was a no-op — AnnotationTrait::removeAnnotation always collected the full subtree regardless, and traversal of the root SplObjectStorage didn't depend on the flag for removal. Migrates PathFilter to use Analysis::removeAnnotation() for consistency with other processors, and removes the AnnotationTrait dependency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both CleanUnusedComponents and PathFilter had identical local implementations. Move the shared method into AnnotationTrait, replacing the old collectAnnotations/traverseAnnotations/removeAnnotation methods that are no longer used. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
217e454 to
966be6a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CleanUnusedComponentswith directAnalysis::removeAnnotation()callsremoveAnnotationRecursive()into shared AnnotationTraitFixes #1792, fixes #1739
Test plan