Repository navigation
Resolve repeat imports inline in filesParser.start - #65801
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
Large projects import the same resolved files tens of thousands of
times, and filesParser.start previously allocated task data and queued
a goroutine for every repeat import.
When a path already has fully loaded task data at equal or lower depth
with an uncontended mutex, record the existing task inline and skip
queuing a job.
benchstat (-pgo=off, parent vs commit, n=6):
goos: linux
goarch: amd64
│ old │ new │
│ sec/op │ sec/op vs base │
Tsc/vscode 6.434 ± 2% 6.515 ± 1% ~ (p=0.065 n=6)
Tsc/mui-docs 3.923 ± 1% 3.917 ± 3% ~ (p=0.589 n=6)
geomean 5.024 5.052 +0.55%
│ old │ new │
│ B-rss │ B-rss vs base │
Tsc/vscode 4.850Gi ± 4% 4.651Gi ± 0% -4.10% (p=0.004 n=6)
Tsc/mui-docs 2.205Gi ± 6% 2.215Gi ± 8% ~ (p=0.818 n=6)
geomean 3.270Gi 3.210Gi -1.85%
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the repeat-import optimization.
No open issues 🎉
What changed in this PR
Optimizes repeat-import handling in the compiler’s filesParser.start to reduce task allocations and queued work in large projects.
Changes:
- Reuses fully loaded tasks inline when depth, package identity, and mutex checks permit.
- Preserves the existing queued path when those checks fail.
| File | Description |
|---|---|
tsc/internal/compiler/filesparser.go |
Adds a guarded fast path for already-loaded imports. |
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.
Large projects import the same resolved files tens of thousands of times, and
filesParser.startpreviously allocated task data and queued a goroutine for every repeat import.When a path already has fully loaded task data at equal or lower depth with an uncontended mutex, record the existing task inline and skip queuing a job.
Saves a bit of time and memory in vscode.