Repository navigation
fix(php): index the single-file LSP type registry - #2702
Merged
Merged
Conversation
cbm_run_php_lsp never finalized its type registry, so every lookup during single-file resolution scanned the stdlib plus every definition of the file linearly: O(lookups x definitions), quadratic in the size of one file. The cross-file path already indexes its registry. The registry is now finalized with first-registered semantics (the first registration of a duplicate QN wins), which keeps exactly the answers of the linear scan, and re-indexed once after trait flattening adds methods. The index lives in a scratch arena that dies with the call. A test-only work ceiling (CBM_LSP_WORK_CEILING_HIT, seam builds only) lets the work-counter test stop a reverted, unbounded loop deterministically instead of hanging the runner; product builds have no ceiling. Signed-off-by: Martin Vogel <[email protected]>
Signed-off-by: Martin Vogel <[email protected]>
…egistry-finalize Signed-off-by: Martin Vogel <[email protected]>
This was referenced Oct 19, 2026
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.
What
cbm_run_php_lsp(the single-file PHP LSP pass) never finalized its type registry. Every lookup during single-file resolution therefore scanned the stdlib plus every definition of the file linearly: O(lookups × definitions), quadratic in the size of one file. The cross-file path (cbm_run_php_lsp_cross) already indexes its registry.The registry is now finalized with first-registered semantics (
index_first_registered), and re-indexed once after trait flattening registers more methods:A test-only work ceiling (
CBM_LSP_WORK_CEILING_HIT, compiled in seam builds only) lets the work-counter test stop a reverted, unbounded loop deterministically instead of hanging the runner. Product builds have no ceiling, so it can never decide graph content.Evidence
L6-y-fbd9a2ae(this fix + the trait-method index + the iterative C# walker), all of which preserve output. This PR's code is unchanged from that build.CBM_LSP_WORK, deterministic, no clock),phplsp_single_file_lookup_work_is_linear_f12, 1,000 → 2,000 chained classes (gate: ratio ≤ 2.5):Suites run locally:
php_lsp,parallel,pipeline,complexity,incremental: 927 passed.Lint:
internal/cbm/lsp/is outside CI'sLINT_SRCS/LINT_HDRS, so I ran the gates directly on the changed files:php_lsp.c(redundantInitializationofqualified, about line 4311). It is in existing code outside this diff, so I left it untouched.