Repository navigation
Look up known directory symlinks by ancestor path - #65802
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.
🟡 Changes recommended
Exact lookup can miss known symlinks when drive-root casing differs on a case-sensitive host, preventing source-backed declarations from resolving when the package root itself is not symlinked. Separately, publishing a directory entry before the HasAnyDirectory flag allows concurrent resolvers to reject a source-backed declaration, and cachedvfs can retain that false result.
2 open issues
What changed in this PR
Optimizes known-symlink checks used to resolve project-reference declarations through source files.
Changes:
- Adds an atomic flag to track whether directory symlinks exist.
- Replaces full-map scans with direct ancestor-path lookups.
| File | Description |
|---|---|
tsc/internal/symlinks/knownsymlinks.go |
Tracks directory-symlink presence with an atomic flag. |
tsc/internal/compiler/projectreferencedtsfakinghost.go |
Uses the flag and ancestor lookups instead of scanning all symlinks. |
Review effort: Balanced
| onFileExists(realFileOrDirectory) | ||
| // If it contains node_modules check if any ancestor directory is a known symlink | ||
| for dir := fileOrDirectoryPath.Parent(); ; { | ||
| if knownDirectoryLink, ok := knownDirectoryLinks.Load(dir); ok && knownDirectoryLink != nil { |
Comment on lines
+71
to
+74
| cache.directories.Store(symlinkPath, realDirectory) | ||
| if realDirectory != nil { | ||
| cache.hasDirectories.Store(true) | ||
| } |
Checking whether a node_modules path falls under a known symlink
previously called Size() and Range() across every known directory
symlink on each probe.
Track whether any directory symlinks exist with an atomic bool and walk
parent PathKey ancestors directly in the directory map.
benchstat (-pgo=off, parent vs commit, n=6):
goos: linux
goarch: amd64
│ old │ new │
│ sec/op │ sec/op vs base │
Tsc/vscode 6.515 ± 1% 6.390 ± 3% ~ (p=0.065 n=6)
Tsc/mui-docs 3.917 ± 3% 3.883 ± 2% ~ (p=0.310 n=6)
geomean 5.052 4.981 -1.39%
│ old │ new │
│ B-rss │ B-rss vs base │
Tsc/vscode 4.651Gi ± 0% 4.845Gi ± 4% +4.17% (p=0.026 n=6)
Tsc/mui-docs 2.215Gi ± 8% 2.199Gi ± 6% ~ (p=0.818 n=6)
geomean 3.210Gi 3.264Gi +1.70%
Jake Bailey (jakebailey)
force-pushed
the
fast-pr/known-symlinks-ancestor
branch
from
December 4, 2026 23:13
723dd6c to
e773f94
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.


Checking whether a node_modules path falls under a known symlink previously called
Size()andRange()across every known directory symlink on each probe.Track whether any directory symlinks exist with an atomic bool and walk parent ancestors directly in the directory map.