Repository navigation
Sort symbols by precomputed file-index and position keys - #65808
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
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The symbol-sorting optimization has no active review issues.
No open issues 🎉
What changed in this PR
Optimizes symbol sorting in the TypeScript checker by precomputing file-index and position keys rather than resolving them during each comparison.
Changes:
- Adds packed sort keys with special values for missing symbols and declarations.
- Uses a stack buffer for small collections and a direct comparison for two symbols.
- Retains the existing comparator for equal keys.
| File | Description |
|---|---|
tsc/internal/checker/utilities.go |
Precomputes symbol sort keys and adds small-collection fast paths. |
Review effort: Balanced
Property sorting previously called GetSourceFileOfNode and looked up
fileIndexMap on every O(N log N) comparison inside compareSymbols.
Precompute a packed uint64 (fileIndex, pos) sort key per symbol once
before sorting in sortSymbols.
benchstat (-pgo=off, parent vs commit, n=6):
goos: linux
goarch: amd64
│ old │ new │
│ sec/op │ sec/op vs base │
Tsc/vscode 6.138 ± 3% 6.120 ± 2% ~ (p=0.589 n=6)
Tsc/mui-docs 3.728 ± 1% 3.696 ± 1% -0.86% (p=0.009 n=6)
geomean 4.783 4.756 -0.57%
│ old │ new │
│ B-rss │ B-rss vs base │
Tsc/vscode 4.641Gi ± 2% 4.625Gi ± 2% ~ (p=0.818 n=6)
Tsc/mui-docs 2.183Gi ± 9% 2.147Gi ± 4% ~ (p=0.310 n=6)
geomean 3.183Gi 3.152Gi -0.98%
Jake Bailey (jakebailey)
force-pushed
the
fast-pr/sort-symbols
branch
from
December 4, 2026 23:13
e3f4dc6 to
4b55ab5
Compare
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.
Property sorting previously called
GetSourceFileOfNodeand looked upfileIndexMapon every comparison insidecompareSymbols.Precompute a packed
uint64(fileIndex, pos)sort key per symbol once before sorting insortSymbols.