Repository navigation
Compare names before symbols when matching flow references - #64868
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
Narrowing a reference walks back through every assignment and
variable declaration on its flow path, and asks whether each one
assigns the reference. For a declaration target that meant loading
the declaration's symbol and looking up its late-bound and merged
symbols, which is mostly cache misses on unrelated symbols. In long
functions this dominated flow analysis.
A declaration's symbol is named by its identifier, so a reference
with a different name can never match it. Comparing names first
skips the symbol work for nearly every unrelated declaration.
--checkers 4, n=8, default GC settings:
│ before │ after │
│ sec/op │ sec/op vs base │
Tsc/bluesky 2.767 ± 1% 2.752 ± 2% ~ (p=0.314 n=8)
Tsc/sentry 10.78 ± 2% 10.76 ± 2% ~ (p=0.701 n=8)
Tsc/t3code-server 13.50 ± 4% 12.57 ± 1% -6.85% (p=0.000 n=8)
geomean 7.384 7.194 -2.58%
│ before │ after │
│ rss-B │ rss-B vs base │
Tsc/bluesky 1.183Gi ± 2% 1.181Gi ± 3% ~ (p=0.878 n=8)
Tsc/sentry 3.549Gi ± 6% 3.481Gi ± 5% ~ (p=0.721 n=8)
Tsc/t3code-server 2.880Gi ± 2% 2.849Gi ± 2% ~ (p=0.279 n=8)
geomean 2.296Gi 2.271Gi -1.06%
│ before │ after │
│ heap-B │ heap-B vs base │
Tsc/bluesky 934.5Mi ± 0% 934.8Mi ± 0% +0.04% (p=0.031 n=8)
Tsc/sentry 2.608Gi ± 0% 2.608Gi ± 0% ~ (p=0.505 n=8)
Tsc/t3code-server 2.301Gi ± 0% 2.302Gi ± 0% ~ (p=0.328 n=8)
geomean 1.763Gi 1.763Gi +0.03%
Member
Author
|
TypeScript Bot (@typescript-bot) perf test this faster |
Contributor
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped optimization preserves matching behavior, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Optimizes flow-reference matching in the native TypeScript checker by avoiding symbol lookups for unrelated declarations.
Changes:
- Rejects variable declarations and binding elements with different identifier names before resolving symbols.
- Preserves symbol-based matching for remaining cases.
| File | Description |
|---|---|
tsc/internal/checker/flow.go |
Adds an early name check when matching declaration targets. |
Review effort: Balanced
Contributor
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This branch has not been deployed
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.
Narrowing a reference walks back through every assignment and variable declaration on its flow path, and asks whether each one assigns the reference. For a declaration target that meant loading the declaration's symbol and looking up its late-bound and merged symbols, which is mostly cache misses on unrelated symbols. In long functions this dominated flow analysis.
A declaration's symbol is named by its identifier, so a reference with a different name can never match it. Comparing names first skips the symbol work for nearly every unrelated declaration.
--checkers 4,n=8, default GC settings: