Skip to content

Blink: scan Doctrine annotations lazily - #276

Merged
TomasVotruba merged 1 commit into
ecsphp:mainfrom
gnutix:perf/doctrine-lazy-scan
Nov 4, 2026
Merged

TomasVotruba merged 1 commit into
ecsphp:mainfrom
gnutix:perf/doctrine-lazy-scan

Conversation

@gnutix

@gnutix gnutix commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem: at each @ in a docblock, daCreateFromDocComment ran 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: daScanner returns 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

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
gnutix force-pushed the perf/doctrine-lazy-scan branch from 7534e1d to e4b686b Compare November 4, 2026 17:37
@gnutix gnutix changed the title Blink: scan Doctrine annotations lazily, not to the end of the docblock Blink: scan Doctrine annotations lazily Nov 4, 2026
@TomasVotruba
TomasVotruba merged commit e67ef14 into ecsphp:main Nov 4, 2026
20 of 21 checks passed
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