Skip to content

Commit

Permalink
perf(es/parser): Remove unnecessary check (#9102)
Browse files Browse the repository at this point in the history
**Description:**

We can skip some checks for error recovery.
  • Loading branch information
kdy1 authored Jun 25, 2024
1 parent 03a0d90 commit 2a490ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ jobs:
swc-exec-cache-${{ matrix.settings.crate }}
- name: Run cargo test
if: matrix.settings.crate != 'swc_plugin_runner' && matrix.settings.crate != 'swc_ecma_minifier' && matrix.settings.crate != 'swc_core' && matrix.settings.crate != 'swc_ecma_quote' && matrix.settings.crate != 'swc_cli' && matrix.settings.crate != 'binding_core_wasm'
if: matrix.settings.crate != 'swc_plugin_runner' && matrix.settings.crate != 'swc_ecma_parser' && matrix.settings.crate != 'swc_ecma_minifier' && matrix.settings.crate != 'swc_core' && matrix.settings.crate != 'swc_ecma_quote' && matrix.settings.crate != 'swc_cli' && matrix.settings.crate != 'binding_core_wasm'
run: |
cargo test -p ${{ matrix.settings.crate }}
Expand Down Expand Up @@ -699,6 +699,11 @@ jobs:
run: |
cargo test -p swc_ecma_minifier --features concurrent
- name: Run cargo test (swc_ecma_parser)
if: matrix.settings.crate == 'swc_ecma_parser'
run: |
cargo test -p swc_ecma_parser --features verify
- name: Run cargo test (all features)
if: matrix.settings.crate == 'swc_ecma_parser' || matrix.settings.crate == 'swc_ecma_loader'
run: |
Expand Down
5 changes: 5 additions & 0 deletions crates/swc_ecma_parser/src/parser/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ impl Context {
}
}

#[cfg_attr(not(feature = "verify"), inline(always))]
pub fn is_reserved_word(self, word: &Atom) -> bool {
if !cfg!(feature = "verify") {
return false;
}

match &**word {
"let" => self.strict,
// SyntaxError in the module only, not in the strict.
Expand Down

1 comment on commit 2a490ad

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 2a490ad Previous: 719b7c5 Ratio
es/full/bugs-1 274143 ns/iter (± 2068) 276778 ns/iter (± 3156) 0.99
es/full/minify/libraries/antd 1770843326 ns/iter (± 98748223) 1829937761 ns/iter (± 88266673) 0.97
es/full/minify/libraries/d3 345276531 ns/iter (± 5055829) 346209924 ns/iter (± 2744131) 1.00
es/full/minify/libraries/echarts 1480442528 ns/iter (± 45192316) 1526345978 ns/iter (± 9298204) 0.97
es/full/minify/libraries/jquery 102464592 ns/iter (± 195744) 102583904 ns/iter (± 1441251) 1.00
es/full/minify/libraries/lodash 113855468 ns/iter (± 452200) 112997410 ns/iter (± 309944) 1.01
es/full/minify/libraries/moment 59637696 ns/iter (± 174198) 59403149 ns/iter (± 151718) 1.00
es/full/minify/libraries/react 18229911 ns/iter (± 395317) 18227562 ns/iter (± 35657) 1.00
es/full/minify/libraries/terser 279365061 ns/iter (± 4546804) 282564913 ns/iter (± 3735645) 0.99
es/full/minify/libraries/three 491016455 ns/iter (± 31203314) 476196955 ns/iter (± 16865498) 1.03
es/full/minify/libraries/typescript 3393840499 ns/iter (± 98976473) 3260671315 ns/iter (± 35004652) 1.04
es/full/minify/libraries/victory 800980942 ns/iter (± 58188335) 772710460 ns/iter (± 21178365) 1.04
es/full/minify/libraries/vue 151599100 ns/iter (± 2951580) 145760166 ns/iter (± 753008) 1.04
es/full/codegen/es3 61478 ns/iter (± 634) 60698 ns/iter (± 604) 1.01
es/full/codegen/es5 61521 ns/iter (± 390) 60505 ns/iter (± 334) 1.02
es/full/codegen/es2015 61521 ns/iter (± 446) 61214 ns/iter (± 520) 1.01
es/full/codegen/es2016 61579 ns/iter (± 814) 60309 ns/iter (± 456) 1.02
es/full/codegen/es2017 61087 ns/iter (± 494) 60472 ns/iter (± 579) 1.01
es/full/codegen/es2018 61499 ns/iter (± 867) 60912 ns/iter (± 426) 1.01
es/full/codegen/es2019 61579 ns/iter (± 740) 60834 ns/iter (± 545) 1.01
es/full/codegen/es2020 61228 ns/iter (± 462) 60607 ns/iter (± 362) 1.01
es/full/all/es3 156521218 ns/iter (± 482029) 159976950 ns/iter (± 799758) 0.98
es/full/all/es5 152283676 ns/iter (± 1031556) 154527716 ns/iter (± 519523) 0.99
es/full/all/es2015 112243916 ns/iter (± 987034) 112524727 ns/iter (± 766673) 1.00
es/full/all/es2016 110269929 ns/iter (± 461887) 112530449 ns/iter (± 850809) 0.98
es/full/all/es2017 109826433 ns/iter (± 716871) 111732846 ns/iter (± 861125) 0.98
es/full/all/es2018 107513673 ns/iter (± 440937) 109431538 ns/iter (± 1423490) 0.98
es/full/all/es2019 107123354 ns/iter (± 285768) 109011625 ns/iter (± 543836) 0.98
es/full/all/es2020 103882806 ns/iter (± 957883) 104981616 ns/iter (± 770644) 0.99
es/full/parser 424065 ns/iter (± 2162) 449897 ns/iter (± 2184) 0.94
es/full/base/fixer 15969 ns/iter (± 233) 16660 ns/iter (± 121) 0.96
es/full/base/resolver_and_hygiene 80471 ns/iter (± 148) 81075 ns/iter (± 192) 0.99
serialization of serde 253 ns/iter (± 10) 274 ns/iter (± 1) 0.92
css/minify/libraries/bootstrap 22283284 ns/iter (± 16641) 22807227 ns/iter (± 129879) 0.98
css/visitor/compare/clone 1384572 ns/iter (± 15300) 1371023 ns/iter (± 10457) 1.01
css/visitor/compare/visit_mut_span 1517963 ns/iter (± 18635) 1479899 ns/iter (± 19379) 1.03
css/visitor/compare/visit_mut_span_panic 1507455 ns/iter (± 1820) 1496268 ns/iter (± 43533) 1.01
css/visitor/compare/fold_span 2028365 ns/iter (± 9176) 1976961 ns/iter (± 16507) 1.03
css/visitor/compare/fold_span_panic 2148134 ns/iter (± 4570) 2077556 ns/iter (± 30208) 1.03
css/lexer/bootstrap_5_1_3 3450549 ns/iter (± 4128) 3423437 ns/iter (± 66351) 1.01
css/lexer/foundation_6_7_4 2808216 ns/iter (± 5629) 2783568 ns/iter (± 43110) 1.01
css/lexer/tailwind_3_1_1 538823 ns/iter (± 520) 517489 ns/iter (± 7367) 1.04
css/parser/bootstrap_5_1_3 15939884 ns/iter (± 37770) 15452744 ns/iter (± 373785) 1.03
css/parser/foundation_6_7_4 12783550 ns/iter (± 53641) 12713134 ns/iter (± 58324) 1.01
css/parser/tailwind_3_1_1 2527639 ns/iter (± 26830) 2481983 ns/iter (± 26468) 1.02
es/codegen/colors 748246 ns/iter (± 393907) 729202 ns/iter (± 390069) 1.03
es/codegen/large 2989696 ns/iter (± 1595304) 3166827 ns/iter (± 1698353) 0.94
es/codegen/with-parser/colors 38946 ns/iter (± 394) 38179 ns/iter (± 856) 1.02
es/codegen/with-parser/large 443490 ns/iter (± 4676) 422584 ns/iter (± 13473) 1.05
es/minify/libraries/antd 1412911649 ns/iter (± 27013873) 1421313307 ns/iter (± 21378219) 0.99
es/minify/libraries/d3 286866934 ns/iter (± 9681735) 284111545 ns/iter (± 2589655) 1.01
es/minify/libraries/echarts 1248799217 ns/iter (± 18601774) 1163275967 ns/iter (± 11067040) 1.07
es/minify/libraries/jquery 82237180 ns/iter (± 394437) 83288958 ns/iter (± 601701) 0.99
es/minify/libraries/lodash 103910801 ns/iter (± 150133) 104523179 ns/iter (± 980788) 0.99
es/minify/libraries/moment 47913824 ns/iter (± 301923) 48639778 ns/iter (± 207777) 0.99
es/minify/libraries/react 16124811 ns/iter (± 105334) 16281574 ns/iter (± 29179) 0.99
es/minify/libraries/terser 219033065 ns/iter (± 3506246) 220366644 ns/iter (± 2403946) 0.99
es/minify/libraries/three 364029084 ns/iter (± 3975554) 369481856 ns/iter (± 4612933) 0.99
es/minify/libraries/typescript 2714029136 ns/iter (± 20550635) 2760976268 ns/iter (± 26896063) 0.98
es/minify/libraries/victory 576507717 ns/iter (± 15582819) 575727172 ns/iter (± 6448690) 1.00
es/minify/libraries/vue 120623844 ns/iter (± 716282) 122072071 ns/iter (± 192301) 0.99
es/visitor/compare/clone 1727380 ns/iter (± 9630) 1752347 ns/iter (± 5567) 0.99
es/visitor/compare/visit_mut_span 2093150 ns/iter (± 17666) 2108286 ns/iter (± 20893) 0.99
es/visitor/compare/visit_mut_span_panic 2091264 ns/iter (± 41422) 2115495 ns/iter (± 35122) 0.99
es/visitor/compare/fold_span 2895607 ns/iter (± 36509) 2832010 ns/iter (± 37311) 1.02
es/visitor/compare/fold_span_panic 2878461 ns/iter (± 52139) 2872488 ns/iter (± 18483) 1.00
es/lexer/colors 8600 ns/iter (± 166) 8413 ns/iter (± 72) 1.02
es/lexer/angular 4242660 ns/iter (± 45611) 4108844 ns/iter (± 5321) 1.03
es/lexer/backbone 634806 ns/iter (± 6444) 630832 ns/iter (± 1656) 1.01
es/lexer/jquery 3652310 ns/iter (± 12108) 3540802 ns/iter (± 12556) 1.03
es/lexer/jquery mobile 5065001 ns/iter (± 87887) 5177567 ns/iter (± 9185) 0.98
es/lexer/mootools 2732413 ns/iter (± 22625) 2833891 ns/iter (± 4487) 0.96
es/lexer/underscore 530999 ns/iter (± 2115) 529177 ns/iter (± 3941) 1.00
es/lexer/three 15995206 ns/iter (± 24073) 15817901 ns/iter (± 50895) 1.01
es/lexer/yui 2666828 ns/iter (± 1772) 2697079 ns/iter (± 1610) 0.99
es/lexer/cal-com 12606957 ns/iter (± 24993) 12937387 ns/iter (± 87995) 0.97
es/lexer/typescript 90037076 ns/iter (± 323064) 95414903 ns/iter (± 333620) 0.94
es/parser/colors 22374 ns/iter (± 185) 23095 ns/iter (± 89) 0.97
es/parser/angular 11774123 ns/iter (± 130688) 12094716 ns/iter (± 101785) 0.97
es/parser/backbone 1808807 ns/iter (± 10622) 1827453 ns/iter (± 7817) 0.99
es/parser/jquery 9977179 ns/iter (± 62770) 10242795 ns/iter (± 193802) 0.97
es/parser/jquery mobile 15075052 ns/iter (± 93826) 16475802 ns/iter (± 351435) 0.91
es/parser/mootools 7778326 ns/iter (± 58810) 7905236 ns/iter (± 94545) 0.98
es/parser/underscore 1579882 ns/iter (± 9180) 1587779 ns/iter (± 14189) 1.00
es/parser/three 43855292 ns/iter (± 325533) 46389143 ns/iter (± 305047) 0.95
es/parser/yui 7284631 ns/iter (± 33329) 7331541 ns/iter (± 167678) 0.99
es/parser/cal-com 39400168 ns/iter (± 459533) 43826453 ns/iter (± 289193) 0.90
es/parser/typescript 269268106 ns/iter (± 2222613) 278385819 ns/iter (± 3735965) 0.97
es/preset-env/usage/builtin_type 138620 ns/iter (± 34139) 136183 ns/iter (± 33403) 1.02
es/preset-env/usage/property 17267 ns/iter (± 155) 16055 ns/iter (± 373) 1.08
es/resolver/typescript 101183183 ns/iter (± 3029684) 98642521 ns/iter (± 1943868) 1.03
es/fixer/typescript 80844256 ns/iter (± 5512422) 80892340 ns/iter (± 2774386) 1.00
es/hygiene/typescript 177790159 ns/iter (± 4541344) 177102584 ns/iter (± 4566930) 1.00
es/resolver_with_hygiene/typescript 305256076 ns/iter (± 3701160) 298117431 ns/iter (± 3172243) 1.02
es/visitor/base-perf/module_clone 57182 ns/iter (± 560) 57324 ns/iter (± 1711) 1.00
es/visitor/base-perf/fold_empty 60131 ns/iter (± 788) 60070 ns/iter (± 459) 1.00
es/visitor/base-perf/fold_noop_impl_all 60532 ns/iter (± 553) 59889 ns/iter (± 885) 1.01
es/visitor/base-perf/fold_noop_impl_vec 60625 ns/iter (± 397) 60574 ns/iter (± 249) 1.00
es/visitor/base-perf/boxing_boxed_clone 60 ns/iter (± 0) 61 ns/iter (± 0) 0.98
es/visitor/base-perf/boxing_unboxed_clone 47 ns/iter (± 0) 47 ns/iter (± 0) 1
es/visitor/base-perf/boxing_boxed 106 ns/iter (± 0) 107 ns/iter (± 0) 0.99
es/visitor/base-perf/boxing_unboxed 81 ns/iter (± 1) 82 ns/iter (± 0) 0.99
es/visitor/base-perf/visit_contains_this 2587 ns/iter (± 15) 2543 ns/iter (± 17) 1.02
es/base/parallel/resolver/typescript 2473882153 ns/iter (± 94735689) 2557212229 ns/iter (± 96086801) 0.97
es/base/parallel/hygiene/typescript 3208706867 ns/iter (± 45116114) 3236709812 ns/iter (± 44264728) 0.99
babelify-only 492281 ns/iter (± 8722) 487918 ns/iter (± 6270) 1.01
parse_and_babelify_angular 43520865 ns/iter (± 1542478) 43102047 ns/iter (± 926095) 1.01
parse_and_babelify_backbone 4376115 ns/iter (± 145997) 4352366 ns/iter (± 181996) 1.01
parse_and_babelify_jquery 28847516 ns/iter (± 256888) 28877310 ns/iter (± 338449) 1.00
parse_and_babelify_jquery_mobile 49677521 ns/iter (± 1055457) 51108422 ns/iter (± 1344672) 0.97
parse_and_babelify_mootools 26246212 ns/iter (± 409724) 26602204 ns/iter (± 514760) 0.99
parse_and_babelify_underscore 3675332 ns/iter (± 26785) 3649825 ns/iter (± 15537) 1.01
parse_and_babelify_yui 24229726 ns/iter (± 301427) 24034016 ns/iter (± 320185) 1.01
html/minify/document/css_spec 45652467 ns/iter (± 266621) 46372489 ns/iter (± 181888) 0.98
html/minify/document/github 18304852 ns/iter (± 243333) 18479955 ns/iter (± 130805) 0.99
html/minify/document/stackoverflow 16685324 ns/iter (± 245385) 17050927 ns/iter (± 415726) 0.98
html/minify/document_fragment/css_spec 44485143 ns/iter (± 102876) 45386400 ns/iter (± 145784) 0.98
html/minify/document_fragment/github 17945363 ns/iter (± 18221) 18140891 ns/iter (± 160601) 0.99
html/minify/document_fragment/stackoverflow 16447831 ns/iter (± 41622) 16771088 ns/iter (± 313322) 0.98
html/document/visitor/compare/clone 166422 ns/iter (± 1675) 166628 ns/iter (± 798) 1.00
html/document/visitor/compare/visit_mut_span 183013 ns/iter (± 1504) 184642 ns/iter (± 1167) 0.99
html/document/visitor/compare/visit_mut_span_panic 186995 ns/iter (± 4212) 188822 ns/iter (± 1009) 0.99
html/document/visitor/compare/fold_span 231411 ns/iter (± 966) 228804 ns/iter (± 757) 1.01
html/document/visitor/compare/fold_span_panic 279976 ns/iter (± 1170) 281851 ns/iter (± 1174) 0.99
html/document_fragment/visitor/compare/clone 166818 ns/iter (± 1502) 168128 ns/iter (± 1008) 0.99
html/document_fragment/visitor/compare/visit_mut_span 185199 ns/iter (± 1249) 185039 ns/iter (± 2085) 1.00
html/document_fragment/visitor/compare/visit_mut_span_panic 186838 ns/iter (± 1082) 186623 ns/iter (± 1539) 1.00
html/document_fragment/visitor/compare/fold_span 231924 ns/iter (± 1211) 235281 ns/iter (± 884) 0.99
html/document_fragment/visitor/compare/fold_span_panic 277517 ns/iter (± 1119) 285938 ns/iter (± 1337) 0.97
html/lexer/css_2021_spec 13031778 ns/iter (± 136567) 13088272 ns/iter (± 38406) 1.00
html/lexer/github_com_17_05_2022 5007351 ns/iter (± 13681) 5007225 ns/iter (± 14719) 1.00
html/lexer/stackoverflow_com_17_05_2022 4749850 ns/iter (± 7272) 4757381 ns/iter (± 6402) 1.00
html/parser/parser_document/css_2021_spec 26707697 ns/iter (± 65161) 25808521 ns/iter (± 291733) 1.03
html/parser/parser_document/github_com_17_05_2022 8874153 ns/iter (± 26085) 8593266 ns/iter (± 11346) 1.03
html/parser/parser_document/stackoverflow_com_17_05_2022 7828950 ns/iter (± 12698) 7503050 ns/iter (± 10099) 1.04
html/parser/parser_document_fragment/css_2021_spec 25363324 ns/iter (± 80014) 25615765 ns/iter (± 45698) 0.99
html/parser/parser_document_fragment/github_com_17_05_2022 8567242 ns/iter (± 9137) 8545040 ns/iter (± 6452) 1.00
html/parser/parser_document_fragment/stackoverflow_com_17_05_2022 7405995 ns/iter (± 4545) 7526367 ns/iter (± 17877) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.