Repository navigation
Blink: scan Doctrine annotations lazily - #276
Merged
Merged
Conversation
At each "@" in a docblock, the doc lexer scanned the rest of the docblock but used only a few tokens, which is quadratic on a large docblock. It now stops where the annotation ends. The output is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gnutix
force-pushed
the
perf/doctrine-lazy-scan
branch
from
November 4, 2026 17:37
7534e1d to
e4b686b
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.
Problem: at each
@in a docblock,daCreateFromDocCommentran the doc lexer over the rest of the docblock, then used only the tokens up to the end of that annotation. That is quadratic in the docblock's size.Change:
daScannerreturns one token at a time, so the scan stops where the loop stops. The regex has no anchors and never matches an empty string, so the tokens are the same.Result: on a private 8.8k-file codebase, the four DoctrineAnnotation rules go from 4.7 s to 0.5 s. One generated file with a 118 KB docblock goes from 2.6 s to 0.2 s.
Tests: existing tests pass, and the private codebase still has 0 diffs. The old and new parser give the same tokens on 110k docblocks.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y1vvcRhpVMjWLC4U5j78Xp