Repository navigation
Add string-literal fast path in CompareTypes - #65803
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
CompareTypes previously fell through the full type-comparison dispatch
even when both operands were string literal types. Short-circuit
string-literal pairs directly with a string comparison.
benchstat (-pgo=off, parent vs commit, n=6):
goos: linux
goarch: amd64
│ old │ new │
│ sec/op │ sec/op vs base │
Tsc/vscode 6.248 ± 2% 6.192 ± 2% ~ (p=0.240 n=6)
Tsc/mui-docs 3.732 ± 2% 3.742 ± 3% ~ (p=0.699 n=6)
geomean 4.829 4.814 -0.32%
│ old │ new │
│ B-rss │ B-rss vs base │
Tsc/vscode 4.576Gi ± 2% 4.546Gi ± 3% ~ (p=0.589 n=6)
Tsc/mui-docs 2.174Gi ± 4% 2.177Gi ± 4% ~ (p=1.000 n=6)
geomean 3.154Gi 3.146Gi -0.27%
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues with the string-literal comparison fast path.
No open issues 🎉
What changed in this PR
Adds a fast path for string-literal comparisons in the compiler’s CompareTypes function.
Changes:
- Compares unaliased string literals directly by value.
- Preserves type-ID ordering when string values match.
| File | Description |
|---|---|
tsc/internal/checker/utilities.go |
Bypasses general comparison dispatch for unaliased string-literal pairs. |
Review effort: Balanced
Member
Author
|
TypeScript Bot (@typescript-bot) perf test this faster |
Contributor
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.
CompareTypespreviously fell through the full type-comparison dispatch even when both operands were string literal types. Short-circuit string-literal pairs directly with a string comparison.