Repository navigation
AST nodes as handles, offsets into areanas - #64698
Draft
Jake Bailey (jakebailey) wants to merge 22 commits into
Draft
Jake Bailey (jakebailey) wants to merge 22 commits into
Jake Bailey (jakebailey) wants to merge 22 commits into
Conversation
Replace nine nodeData interface methods with generated Kind-switch dispatchers to reduce interface method promotion and itab size.
This reverts commit 9baebce.
Replace large sparse Kind switches with byte-indexed dispatch tables and dense switches, while leaving small switches unchanged. Keep the concrete calls visible to escape analysis without restoring promoted interface methods. Add accessor correctness tests and fixture-based benchmarks covering both mixed nodes and nodes with populated accessor results.
Index generated accessor tables directly with the node kind. Invalid kinds now hit the normal Go bounds check rather than returning nil. Update accessor tests to use valid constructed nodes.
…patch-opt # Conflicts: # tsc/internal/ast/kind_stringer_generated.go
Keep the accessor benchmarks compatible with the rooted path types and filesystem case sensitivity API now used on main.
The pointer-based AST keeps most of its retained heap visible to the garbage collector. Source-file-relative handles and pointer-free records reduce that scan workload and retained memory without changing compiler or language-service behavior or the JavaScript AST wire format. The matched workload improves memory use, not navigation CPU time. Interleaved CPU samples are noisy and navigation remains slower. Benchstat CSV, generated-method foundation versus arena (six samples): ,baseline,,arena,,, ,sec/op,CI,sec/op,CI,vs base,P ASTArena/Parse-20,0.0031952075,130%,0.003543635,193%,~,p=0.589 n=6 ASTArena/Navigate-20,7.546e-05,67%,0.000139277,47%,+84.57%,p=0.041 n=6 ,baseline,,arena,,, ,B/op,CI,B/op,CI,vs base,P ASTArena/Parse-20,1.2868065e+06,0%,1.1690025e+06,0%,-9.15%,p=0.002 n=6 ASTArena/Navigate-20,0,0%,0,0%,~,p=1.000 n=6 ,baseline,,arena,,, ,allocs/op,CI,allocs/op,CI,vs base,P ASTArena/Parse-20,153,0%,141,1%,-7.84%,p=0.002 n=6 ASTArena/Navigate-20,0,0%,0,0%,~,p=1.000 n=6 ,baseline,,arena,,, ,live-B/file,CI,live-B/file,CI,vs base,P ASTArenaRetained-20,1.256137e+06,0%,902714.5,0%,-28.14%,p=0.002 n=6 ,baseline,,arena,,, ,scan-B/file,CI,scan-B/file,CI,vs base,P ASTArenaRetained-20,1.2549315e+06,0%,296259.5,0%,-76.39%,p=0.002 n=6 npx hereby validate --all passed with unchanged compiler baselines. Race/checkptr and 32-bit arena tests passed; the WASI AST tests compile.
Member
Author
|
TypeScript Bot (@typescript-bot) perf test this |
Contributor
|
Starting jobs; this comment will be updated as builds start and complete.
|
Storage invariants, compatibility constraints, experiments, and newly discovered races need to stay with the implementation so subsequent changes do not repeat the same mistakes. General contributor guidance is not the right place for branch-specific architectural details.
SourceFile owns mutable metadata and synchronization primitives even though ordinary AST nodes are value handles. Copying the file for a field access races with concurrent binding and cache initialization, including when the requested arena field itself is stable. The focused regression reproduces the race before the fix. Both exact race-enabled smoke commands and npx hereby validate --all now pass.
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.
WIP, this is unchecked slop
Built on top of #64063