Repository navigation
Generate direct bindEachChild traversal to avoid ForEachChild closures - #65799
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
… closures
Binder.bindEachChild previously called node.ForEachChild(b.bindFunc),
paying an indirect closure call on every child across the AST.
Generate (*Binder).bindEachChild from tools/scripts/tsc/ast.json in
bindchildren_generated.go matching (*ast.Node).ForEachChild order,
remove b.bindFunc, and replace doWithConditionalBranches indirect calls
with direct bindWithConditionalBranches.
benchstat (-pgo=off, parent vs commit, n=6):
goos: linux
goarch: amd64
│ old │ new │
│ sec/op │ sec/op vs base │
Tsc/vscode 6.537 ± 2% 6.535 ± 1% ~ (p=0.699 n=6)
Tsc/mui-docs 3.889 ± 2% 3.916 ± 1% ~ (p=0.240 n=6)
geomean 5.042 5.059 +0.32%
│ old │ new │
│ B-rss │ B-rss vs base │
Tsc/vscode 4.735Gi ± 2% 4.752Gi ± 2% ~ (p=0.818 n=6)
Tsc/mui-docs 2.151Gi ± 7% 2.166Gi ± 5% ~ (p=1.000 n=6)
geomean 3.191Gi 3.209Gi +0.54%
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change to generated direct child-binding calls.
No open issues 🎉
1 file not reviewed
tsc/internal/binder/bindchildren_generated.go: Generated file
What changed in this PR
This PR replaces callback-based child traversal in the compiler binder with generated direct calls to reduce dispatch overhead while preserving traversal order.
Changes:
- Generate direct child-binding calls from the AST schema.
- Remove the binder’s stored closure and unused boolean returns.
- Replace indirect conditional-branch calls with direct binding calls.
| File | Description |
|---|---|
tsc/internal/binder/binder.go |
Removes callback plumbing and adds direct binding helpers. |
tsc/internal/binder/bindchildren_generated.go |
Adds generated child traversal matching ForEachChild order. |
tools/scripts/tsc/generate-go-ast.ts |
Generates and registers the binder traversal output. |
Review effort: Balanced
Member
|
TypeScript Bot (@typescript-bot) perf test this faster |
Contributor
Contributor
|
Anders Hejlsberg (@ahejlsberg) 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.
Binder.bindEachChildpreviously callednode.ForEachChild(b.bindFunc), paying an indirect closure call on every child across the AST.Generate
(*Binder).bindEachChildmatching(*ast.Node).ForEachChildorder, removeb.bindFunc(the last held closure), and replacedoWithConditionalBranchesindirect calls with directbindWithConditionalBranches.