You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(walker): skip null checks for non-leaf node dispatch - #1824
In @swc-next/walker, nodeWalkers initializes every non-leaf AST node type to a concrete walk<Name> function, and compile() only overrides entries with walkEnter or walkLeave functions. Only leaf node types (those with no child fields) can be null in the walker table. Previously, the generated dispatchNode and concrete dispatch<Name> helpers still emitted a visit === null ? index : visit(...) branch for every node type, adding unnecessary bytecode and dead branches across ~130 non-leaf node types.
Changes
Updated tasks/ast_tools/src/generator/estree_visitor_keys.rs to invoke walkers.<Name>!(...) directly for non-leaf node types in dispatchNode (including the Identifier fast path) and concrete dispatch<Name> helpers, while keeping the visit === null guard for leaf node types.
Regenerated packages/walker/src/child-visitors.ts, reducing the built dist/child-visitors.js size from 165 KB to 149 KB (-9.7%).
Verified with @swc-next/walker build, strict TypeScript typecheck, and all 19 @swc-next/core walker tests passing. Local benchmarks show ~6.3% faster execution under --jitless on underscore-1.5.2.js and ~2.8% improvement on checker.ts under V8 JIT (other JIT fixtures within ±1% noise).
Median instruction counts from three processes, shown as compare / base in K (1,000), truncated to whole thousands. Percentages are rounded to at most three decimal places. Lower is better: 🟢 improvement, 🔴 regression, ⚪ unchanged or overlapping ranges (inconclusive).
JIT disabled (--jitless); predictable mode enabled (--predictable). Counts are not wall time. Exact counts, ranges and profiles are retained in artifacts.
Callgrind instruction counts (Ir) for the compare and base revisions. Values are shown as compare / base in K (1,000), truncated to whole thousands. Multi-part profiles use the part numbers from Gungraun and include an aggregated Total. New and Removed identify benchmarks that exist on only one side; the missing value is shown as a dash. Percentages are rounded to at most three decimal places. Lower is better: 🟢 improvement, 🔴 regression, ⚪ unchanged.
Formatter
Benchmark
Ir (K)
Change
formatter/angular
73,639 / 73,639
0% ⚪
formatter/astro_config
4,348 / 4,348
0% ⚪
formatter/backbone
11,034 / 11,034
0% ⚪
formatter/effect_schema_ast
23,717 / 23,717
0% ⚪
formatter/hono_types
16,031 / 16,031
0% ⚪
formatter/jquery_mobile
95,000 / 95,000
0% ⚪
formatter/mootools
47,050 / 47,050
0% ⚪
formatter/three
255,137 / 255,137
0% ⚪
formatter/typescript
1,427,687 / 1,427,687
0% ⚪
formatter/underscore
9,873 / 9,873
0% ⚪
formatter/yui
46,445 / 46,445
0% ⚪
markdown_formatter/biome_readme
287 / 287
0% ⚪
markdown_formatter/nix_changelog
4,706 / 4,706
0% ⚪
markdown_formatter/prettier_options
1,062 / 1,062
−0.002% 🟢
Generator
Benchmark
Ir (K)
Change
cal_com_tsx
49,266 / 49,266
0% ⚪
typescript
371,380 / 371,380
0% ⚪
Minifier
Benchmark
Ir (K)
Change
angular
19,086 / 19,086
0% ⚪
semantic
43 / 43
0% ⚪
typescript
385,746 / 385,748
0% ⚪
underscore
2,777 / 2,777
0% ⚪
Parser
Benchmark
Ir (K)
Change
markdown_parser/biome_readme
316 / 316
−0.002% 🟢
markdown_parser/nix_changelog
8,110 / 8,110
0% ⚪
markdown_parser/prettier_options
1,601 / 1,601
0% ⚪
parser/angular
7,971 / 7,971
0% ⚪
parser/backbone
1,267 / 1,267
0% ⚪
parser/cal_com_tsx
25,103 / 25,103
0% ⚪
parser/hono_types
2,898 / 2,898
0% ⚪
parser/jquery
6,668 / 6,668
0% ⚪
parser/jquery_mobile
10,304 / 10,304
0% ⚪
parser/mootools
5,499 / 5,499
0% ⚪
parser/three
32,274 / 32,274
0% ⚪
parser/typescript
162,356 / 162,356
0% ⚪
parser/underscore
1,131 / 1,131
0% ⚪
parser/yui
5,176 / 5,176
0% ⚪
Semantic
Benchmark
Ir (K)
Change
analyze/cal_com_tsx
15,945 / 15,945
0% ⚪
analyze/typescript
129,370 / 129,370
0% ⚪
analyze/typescript_checker
55,504 / 55,504
0% ⚪
syntax_check/cal_com_tsx
26,800 / 26,800
0% ⚪
syntax_check/typescript
178,137 / 178,137
0% ⚪
syntax_check/typescript_checker
70,140 / 70,140
0% ⚪
Transform
Benchmark
Ir (K)
Change
transform/excalidraw_app
34,246 / 34,246
0% ⚪
transform/hono_types
12,716 / 12,716
0% ⚪
transform/kitchen_sink
112,547 / 112,547
0% ⚪
transform/radix_ui_adoption
346 / 346
0% ⚪
transform/three
127,191 / 127,191
0% ⚪
transform_v1/excalidraw_app
76,378 / 76,398
−0.027% 🟢
transform_v1/hono_types
593 / 593
0% ⚪
transform_v1/kitchen_sink
146,212 / 146,202
+0.007% 🔴
transform_v1/radix_ui_adoption
612 / 612
0% ⚪
transform_v1/three
240,894 / 240,893
0% ⚪
Type strip
Benchmark
Ir (K)
Change
astro_config/Part 1
369 / 369
0% ⚪
astro_config/Part 2
158 / 158
0% ⚪
astro_config/Total
527 / 527
0% ⚪
effect_schema_ast/Part 1
2,985 / 2,985
0% ⚪
effect_schema_ast/Part 2
675 / 675
0% ⚪
effect_schema_ast/Total
3,661 / 3,661
0% ⚪
hono_types/Part 1
2,891 / 2,891
0% ⚪
hono_types/Part 2
112 / 112
0% ⚪
hono_types/Total
3,003 / 3,003
0% ⚪
Visit
Benchmark
Ir (K)
Change
traverse/cal_com_tsx
2,826 / 2,826
0% ⚪
traverse/typescript
25,822 / 25,822
0% ⚪
visit/cal_com_tsx
2,874 / 2,874
0% ⚪
visit/typescript
25,119 / 25,119
0% ⚪
visit_mut/cal_com_tsx
2,555 / 2,555
0% ⚪
visit_mut/typescript
24,288 / 24,288
0% ⚪
Benchmark results
gungraun::parser::bench_parser angular:(ANGULAR, Lang :: Js)
Baselines: |base
Instructions: 7971657|7971657 (No change)
gungraun::parser::bench_parser backbone:(BACKBONE, Lang :: Js)
Baselines: |base
Instructions: 1267593|1267593 (No change)
gungraun::parser::bench_parser jquery:(JQUERY, Lang :: Js)
Baselines: |base
Instructions: 6668819|6668819 (No change)
gungraun::parser::bench_parser jquery_mobile:(JQUERY_MOBILE, Lang :: Js)
Baselines: |base
Instructions: 10304129|10304129 (No change)
gungraun::parser::bench_parser mootools:(MOOTOOLS, Lang :: Js)
Baselines: |base
Instructions: 5499972|5499972 (No change)
gungraun::parser::bench_parser underscore:(UNDERSCORE, Lang :: Js)
Baselines: |base
Instructions: 1131858|1131858 (No change)
gungraun::parser::bench_parser three:(THREE, Lang :: Js)
Baselines: |base
Instructions: 32274998|32274998 (No change)
gungraun::parser::bench_parser yui:(YUI, Lang :: Js)
Baselines: |base
Instructions: 5176318|5176318 (No change)
gungraun::parser::bench_parser typescript:(TYPESCRIPT, Lang :: Js)
Baselines: |base
Instructions: 162356112|162356112 (No change)
gungraun::parser::bench_parser cal_com_tsx:(CAL_COM_TSX, Lang :: Tsx)
Baselines: |base
Instructions: 25103498|25103498 (No change)
gungraun::parser::bench_parser hono_types:(HONO_TYPES, Lang :: Ts)
Baselines: |base
Instructions: 2898683|2898683 (No change)
gungraun::parser::bench_markdown_parser biome_readme:(BIOME_README)
Baselines: |base
Instructions: 316308|316313 (-0.00158%) [-1.00002x]
gungraun::parser::bench_markdown_parser prettier_options:(PRETTIER_OPTIONS)
Baselines: |base
Instructions: 1601138|1601138 (No change)
gungraun::parser::bench_markdown_parser nix_changelog:(NIX_CHANGELOG)
Baselines: |base
Instructions: 8110561|8110561 (No change)
gungraun::semantic::bench_analyze typescript:(setup_program(TYPESCRIPT, Lang :: Js))
Baselines: |base
Instructions: 129370044|129370044 (No change)
gungraun::semantic::bench_analyze cal_com_tsx:(setup_program(CAL_COM_TSX, Lang :: Tsx))
Baselines: |base
Instructions: 15945131|15945131 (No change)
gungraun::semantic::bench_analyze typescript_checker:(setup_program(TYPESCRIPT_CHECKER, Lang :: Ts))
Baselines: |base
Instructions: 55504277|55504277 (No change)
gungraun::semantic::bench_syntax_check typescript:(setup_program(TYPESCRIPT, Lang :: Js))
Baselines: |base
Instructions: 178137980|178137980 (No change)
gungraun::semantic::bench_syntax_check cal_com_tsx:(setup_program(CAL_COM_TSX, Lang :: Tsx))
Baselines: |base
Instructions: 26800492|26800492 (No change)
gungraun::semantic::bench_syntax_check typescript_checker:(setup_program(TYPESCRIPT_CHECKER, Lang :: Ts))
Baselines: |base
Instructions: 70140112|70140112 (No change)
gungraun::generator::bench_generate typescript:(setup_generate(TYPESCRIPT, "typescript.js"))
Baselines: |base
Instructions: 371380549|371380549 (No change)
gungraun::generator::bench_generate cal_com_tsx:(setup_generate(CAL_COM_TSX, "cal.com.tsx"))
Baselines: |base
Instructions: 49266242|49266242 (No change)
gungraun::formatter::bench_formatter angular:(setup_formatter_program(ANGULAR, Lang :: Js))
Baselines: |base
Instructions: 73639427|73639427 (No change)
gungraun::formatter::bench_formatter backbone:(setup_formatter_program(BACKBONE, Lang :: Js))
Baselines: |base
Instructions: 11034832|11034832 (No change)
gungraun::formatter::bench_formatter jquery_mobile:(setup_formatter_program(JQUERY_MOBILE, Lang :: Js...
Baselines: |base
Instructions: 95000681|95000681 (No change)
gungraun::formatter::bench_formatter mootools:(setup_formatter_program(MOOTOOLS, Lang :: Js))
Baselines: |base
Instructions: 47050380|47050380 (No change)
gungraun::formatter::bench_formatter underscore:(setup_formatter_program(UNDERSCORE, Lang :: Js))
Baselines: |base
Instructions: 9873654|9873654 (No change)
gungraun::formatter::bench_formatter three:(setup_formatter_program(THREE, Lang :: Js))
Baselines: |base
Instructions: 255137088|255137088 (No change)
gungraun::formatter::bench_formatter yui:(setup_formatter_program(YUI, Lang :: Js))
Baselines: |base
Instructions: 46445990|46445990 (No change)
gungraun::formatter::bench_formatter typescript:(setup_formatter_program(TYPESCRIPT, Lang :: Js))
Baselines: |base
Instructions: 1427687024|1427687024 (No change)
gungraun::formatter::bench_formatter astro_config:(setup_formatter_program(ASTRO_CONFIG, Lang :: Ts)...
Baselines: |base
Instructions: 4348503|4348503 (No change)
gungraun::formatter::bench_formatter effect_schema_ast:(setup_formatter_program(EFFECT_SCHEMA_AST, Lang :...
Baselines: |base
Instructions: 23717670|23717670 (No change)
gungraun::formatter::bench_formatter hono_types:(setup_formatter_program(HONO_TYPES, Lang :: Ts))
Baselines: |base
Instructions: 16031474|16031474 (No change)
gungraun::formatter::bench_markdown_formatter biome_readme:(parse_markdown(BIOME_README))
Baselines: |base
Instructions: 287109|287109 (No change)
gungraun::formatter::bench_markdown_formatter prettier_options:(parse_markdown(PRETTIER_OPTIONS))
Baselines: |base
Instructions: 1062393|1062419 (-0.00245%) [-1.00002x]
gungraun::formatter::bench_markdown_formatter nix_changelog:(parse_markdown(NIX_CHANGELOG))
Baselines: |base
Instructions: 4706230|4706230 (No change)
gungraun::minifier::bench_minifier underscore:(setup_minifier(UNDERSCORE))
Baselines: |base
Instructions: 2777841|2777841 (No change)
gungraun::minifier::bench_minifier angular:(setup_minifier(ANGULAR))
Baselines: |base
Instructions: 19086688|19086688 (No change)
gungraun::minifier::bench_minifier typescript:(setup_minifier(TYPESCRIPT))
Baselines: |base
Instructions: 385746173|385748073 (-0.00049%) [-1.00000x]
gungraun::minifier::bench_minifier semantic:(setup_minifier(MINIFIER_SEMANTIC))
Baselines: |base
Instructions: 43050|43050 (No change)
gungraun::transform::bench_transform three:(setup_transform(THREE, "three-0.138.3.js"))
Baselines: |base
Instructions: 127191136|127191136 (No change)
gungraun::transform::bench_transform excalidraw_app:(setup_transform(EXCALIDRAW_APP, "App.tsx"))
Baselines: |base
Instructions: 34246665|34246665 (No change)
gungraun::transform::bench_transform radix_ui_adoption:(setup_transform(RADIX_UI_ADOPTION, "RadixUIAdopti...
Baselines: |base
Instructions: 346625|346625 (No change)
gungraun::transform::bench_transform hono_types:(setup_transform(HONO_TYPES, "hono-types.ts"))
Baselines: |base
Instructions: 12716830|12716830 (No change)
gungraun::transform::bench_transform kitchen_sink:(setup_transform(KITCHEN_SINK, "kitchen-sink.tsx")...
Baselines: |base
Instructions: 112547865|112547865 (No change)
gungraun::transform::bench_transform_v1 three:(setup_transform_v1(THREE, "three-0.138.3.js"))
Baselines: |base
Instructions: 240894308|240893354 (+0.00040%) [+1.00000x]
gungraun::transform::bench_transform_v1 excalidraw_app:(setup_transform_v1(EXCALIDRAW_APP, "App.tsx"))
Baselines: |base
Instructions: 76378666|76398932 (-0.02653%) [-1.00027x]
gungraun::transform::bench_transform_v1 radix_ui_adoption:(setup_transform_v1(RADIX_UI_ADOPTION, "RadixUIAdo...
Baselines: |base
Instructions: 612398|612398 (No change)
gungraun::transform::bench_transform_v1 hono_types:(setup_transform_v1(HONO_TYPES, "hono-types.ts"))
Baselines: |base
Instructions: 593506|593506 (No change)
gungraun::transform::bench_transform_v1 kitchen_sink:(setup_transform_v1(KITCHEN_SINK, "kitchen-sink.ts...
Baselines: |base
Instructions: 146212126|146202504 (+0.00658%) [+1.00007x]
gungraun::type_strip::bench_type_strip astro_config:(ASTRO_CONFIG, type_strip_options(Lang :: Ts))
## pid: 6637 thread: 1 part: 1 |pid: 6560 thread: 1 part: 1
Command:
/home/runner/work/_temp/gungraun-bin/head/gungraun|/home/runner/work/_temp/gungraun-bin/base/gungraun --gungraun-run d:d:000000 00006 00000 00000
Baselines: |base
Instructions: 369418|369418 (No change)
## pid: 6637 thread: 1 part: 2 |pid: 6560 thread: 1 part: 2
Command:
/home/runner/work/_temp/gungraun-bin/head/gungraun|/home/runner/work/_temp/gungraun-bin/base/gungraun --gungraun-run d:d:000000 00006 00000 00000
Instructions: 158362|158362 (No change)
## Total
Instructions: 527780|527780 (No change)
gungraun::type_strip::bench_type_strip effect_schema_ast:(EFFECT_SCHEMA_AST, type_strip_options(Lang :: Ts)...
## pid: 6638 thread: 1 part: 1 |pid: 6563 thread: 1 part: 1
Command:
/home/runner/work/_temp/gungraun-bin/head/gungraun|/home/runner/work/_temp/gungraun-bin/base/gungraun --gungraun-run d:d:000000 00006 00000 00001
Baselines: |base
Instructions: 2985998|2985998 (No change)
## pid: 6638 thread: 1 part: 2 |pid: 6563 thread: 1 part: 2
Command:
/home/runner/work/_temp/gungraun-bin/head/gungraun|/home/runner/work/_temp/gungraun-bin/base/gungraun --gungraun-run d:d:000000 00006 00000 00001
Instructions: 675715|675715 (No change)
## Total
Instructions: 3661713|3661713 (No change)
gungraun::type_strip::bench_type_strip hono_types:(HONO_TYPES, type_strip_options(Lang :: Ts))
## pid: 6639 thread: 1 part: 1 |pid: 6564 thread: 1 part: 1
Command:
/home/runner/work/_temp/gungraun-bin/head/gungraun|/home/runner/work/_temp/gungraun-bin/base/gungraun --gungraun-run d:d:000000 00006 00000 00002
Baselines: |base
Instructions: 2891267|2891267 (No change)
## pid: 6639 thread: 1 part: 2 |pid: 6564 thread: 1 part: 2
Command:
/home/runner/work/_temp/gungraun-bin/head/gungraun|/home/runner/work/_temp/gungraun-bin/base/gungraun --gungraun-run d:d:000000 00006 00000 00002
Instructions: 112005|112005 (No change)
## Total
Instructions: 3003272|3003272 (No change)
gungraun::visit::bench_visit typescript:(setup_program(TYPESCRIPT, Lang :: Js))
Baselines: |base
Instructions: 25119209|25119209 (No change)
gungraun::visit::bench_visit cal_com_tsx:(setup_program(CAL_COM_TSX, Lang :: Tsx))
Baselines: |base
Instructions: 2874310|2874310 (No change)
gungraun::visit::bench_visit_mut typescript:(setup_program(TYPESCRIPT, Lang :: Js))
Baselines: |base
Instructions: 24288597|24288597 (No change)
gungraun::visit::bench_visit_mut cal_com_tsx:(setup_program(CAL_COM_TSX, Lang :: Tsx))
Baselines: |base
Instructions: 2555855|2555855 (No change)
gungraun::visit::bench_traverse typescript:(setup_program(TYPESCRIPT, Lang :: Js))
Baselines: |base
Instructions: 25822582|25822582 (No change)
gungraun::visit::bench_traverse cal_com_tsx:(setup_program(CAL_COM_TSX, Lang :: Tsx))
Baselines: |base
Instructions: 2826624|2826624 (No change)
Gungraun result: Ok. 59 without regressions; 0 regressed; 0 filtered; 59 benchmarks finished in 93.5885s
This branch has not been deployed
No deployments
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
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.
Motivation
In
@swc-next/walker,nodeWalkersinitializes every non-leaf AST node type to a concretewalk<Name>function, andcompile()only overrides entries withwalkEnterorwalkLeavefunctions. Only leaf node types (those with no child fields) can benullin the walker table. Previously, the generateddispatchNodeand concretedispatch<Name>helpers still emitted avisit === null ? index : visit(...)branch for every node type, adding unnecessary bytecode and dead branches across ~130 non-leaf node types.Changes
tasks/ast_tools/src/generator/estree_visitor_keys.rsto invokewalkers.<Name>!(...)directly for non-leaf node types indispatchNode(including theIdentifierfast path) and concretedispatch<Name>helpers, while keeping thevisit === nullguard for leaf node types.packages/walker/src/child-visitors.ts, reducing the builtdist/child-visitors.jssize from 165 KB to 149 KB (-9.7%).@swc-next/walkerbuild, strict TypeScript typecheck, and all 19@swc-next/corewalker tests passing. Local benchmarks show ~6.3% faster execution under--jitlessonunderscore-1.5.2.jsand ~2.8% improvement onchecker.tsunder V8 JIT (other JIT fixtures within ±1% noise).