Compiler: producer-expr index + comment-interval cache for big-file compiles (#16077)#16412
Open
PurHur wants to merge 1 commit into
Open
Compiler: producer-expr index + comment-interval cache for big-file compiles (#16077)#16412PurHur wants to merge 1 commit into
PurHur wants to merge 1 commit into
Conversation
This was referenced Jul 5, 2026
…ompiles (#16077). Two lint/compile hotspots on 15-30k-line files, found by sampling the lintScript pass after the frontend fixes landed: - findCfgProducerExprForOperand re-walked every seen CFG block tree twice per lookup. Measured on lib/Compiler.php: 929 lookups, 88% returning null after a full scan. Now an incremental index over the seen set answers exact hits O(1), and a global "cfg var roots with any candidate" set proves the null case without scanning; only true root-match lookups (1 per file measured) fall back to the legacy scan. Blocks are re-indexed when their child count changes; misses self-heal through the fallback (its non-exact arm still matches exact producers first). PHP_COMPILER_PRODUCER_INDEX_LEGACY=1 restores the scan. - SourcePreprocessor\PropertyHooks::isOffsetInComment rescanned the class body from byte 0 for every $var occurrence — O(vars x body), 70% of lint samples on lib/VM.php. Now one pass per body builds sorted comment intervals (exact legacy boundary semantics), binary searched per probe. PHP_COMPILER_COMMENT_SCAN_LEGACY=1 restores the per-offset scan. Measured in the pinned container (lint end-to-end, output identical to legacy on lib/VM.php, lib/Compiler.php, lib/JIT.php, ext/standard/VmString.php): lib/VM.php 2m50s -> 40s lib/Compiler.php 1m49s -> 1m11s Includes bootstrap inventory/profile regen for the method-count drift. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
64b5f9f to
d0230d3
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.
Two lint/compile hotspots on 15–30k-line files, found by SIGALRM sampling of the lintScript pass after the frontend fixes:
findCfgProducerExprForOperandre-walked every seen CFG block tree twice per lookup — measured 929 lookups on lib/Compiler.php, 88% returning null after a full scan. Now an incremental index over the seen set answers exact hits O(1) and a global "roots with any candidate" set proves the null case without scanning; only true root-matches (1 per file measured) fall back to the legacy scan. Blocks re-index when their child count changes; index misses self-heal through the fallback. Kill switch:PHP_COMPILER_PRODUCER_INDEX_LEGACY=1.PropertyHooks::isOffsetInCommentrescanned the class body from byte 0 per$varprobe — O(vars×body), 70% of samples on lib/VM.php. Now one scan per body builds sorted comment intervals (exact legacy boundary semantics documented in-code), binary-searched per probe. Kill switch:PHP_COMPILER_COMMENT_SCAN_LEGACY=1.Measured (pinned container, end-to-end lint)
Verified
check-aot-build-smoke.shrc=0 (build+run+VM-differential) — unlike the Speed up inventory lint: opt-in fast frontend patches + parallel cached bin/lint.php (#16077) #16394 vendor paths, these are safe for compiles: results are equivalence-checked, not just order-stablemake north-star5-verify-fastOK (spine link + gen-0 cold boot)🤖 Generated with Claude Code