Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(babel/compat): Improve performance of babelify #1626

Merged
merged 95 commits into from
May 6, 2021

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented May 1, 2021

Tasks

swc_babel_compat:

  • Optimize.

swc:

  • Improve performance related to comments.

Optimization history

After changing String to JsWord

test angular       ... bench: 120,380,604 ns/iter (+/- 7,231,423) = 5 MB/s
test babelify      ... bench:   1,393,920 ns/iter (+/- 486,892) = 7 MB/s
test backbone      ... bench:  16,793,729 ns/iter (+/- 1,859,636) = 3 MB/s
test jquery        ... bench: 103,489,686 ns/iter (+/- 7,214,542) = 2 MB/s
test jquery_mobile ... bench: 190,022,968 ns/iter (+/- 11,762,501) = 2 MB/s
test mootools      ... bench:  71,442,577 ns/iter (+/- 4,100,112) = 2 MB/s
test underscore    ... bench:  11,578,346 ns/iter (+/- 1,688,207) = 3 MB/s
test yui           ... bench:  73,401,094 ns/iter (+/- 4,572,728) = 4 MB/s

After removing useless clones.

test angular       ... bench:  75,740,646 ns/iter (+/- 5,321,871) = 9 MB/s
test babelify      ... bench:     788,769 ns/iter (+/- 98,940) = 13 MB/s
test backbone      ... bench:  10,443,560 ns/iter (+/- 1,164,215) = 5 MB/s
test jquery        ... bench:  66,282,313 ns/iter (+/- 7,183,684) = 4 MB/s
test jquery_mobile ... bench: 105,922,837 ns/iter (+/- 8,981,988) = 4 MB/s
test mootools      ... bench:  48,497,743 ns/iter (+/- 3,407,864) = 3 MB/s
test underscore    ... bench:   8,581,681 ns/iter (+/- 1,760,740) = 5 MB/s
test yui           ... bench:  43,636,221 ns/iter (+/- 3,281,859) = 7 MB/s

After merging code paths using generic

test angular       ... bench:  74,477,894 ns/iter (+/- 7,437,248) = 9 MB/s
test babelify      ... bench:     764,601 ns/iter (+/- 121,031) = 14 MB/s
test backbone      ... bench:  10,333,353 ns/iter (+/- 1,208,007) = 5 MB/s
test jquery        ... bench:  64,940,185 ns/iter (+/- 6,239,459) = 4 MB/s
test jquery_mobile ... bench: 103,639,448 ns/iter (+/- 7,312,483) = 4 MB/s
test mootools      ... bench:  47,135,533 ns/iter (+/- 4,149,281) = 3 MB/s
test underscore    ... bench:   8,223,502 ns/iter (+/- 1,473,473) = 5 MB/s
test yui           ... bench:  41,941,127 ns/iter (+/- 4,150,643) = 8 MB/s

After optimizing sourcemap operations of swc_common

test angular       ... bench:  71,530,903 ns/iter (+/- 6,676,043) = 10 MB/s
test babelify      ... bench:     727,873 ns/iter (+/- 104,247) = 14 MB/s
test backbone      ... bench:   9,742,245 ns/iter (+/- 1,531,072) = 6 MB/s
test jquery        ... bench:  63,753,373 ns/iter (+/- 5,143,951) = 4 MB/s
test jquery_mobile ... bench: 104,859,290 ns/iter (+/- 9,856,438) = 4 MB/s
test mootools      ... bench:  46,534,263 ns/iter (+/- 4,883,176) = 3 MB/s
test underscore    ... bench:   8,000,096 ns/iter (+/- 1,666,608) = 5 MB/s
test yui           ... bench:  41,394,018 ns/iter (+/- 4,096,623) = 8 MB/s

After reducing creationg of string using the new api

test angular       ... bench:  76,294,131 ns/iter (+/- 6,857,157) = 9 MB/s
test babelify      ... bench:     761,046 ns/iter (+/- 203,810) = 14 MB/s
test backbone      ... bench:  10,476,869 ns/iter (+/- 1,329,396) = 5 MB/s
test jquery        ... bench:  64,359,173 ns/iter (+/- 7,378,338) = 4 MB/s
test jquery_mobile ... bench: 102,256,810 ns/iter (+/- 9,824,814) = 4 MB/s
test mootools      ... bench:  45,769,665 ns/iter (+/- 3,651,325) = 3 MB/s
test underscore    ... bench:   7,989,858 ns/iter (+/- 1,444,150) = 5 MB/s
test yui           ... bench:  40,866,778 ns/iter (+/- 3,618,975) = 8 MB/s

After optimizing comment operations.

test angular       ... bench:  70,597,437 ns/iter (+/- 5,232,975) = 10 MB/s
test babelify      ... bench:     746,176 ns/iter (+/- 164,998) = 14 MB/s
test backbone      ... bench:   9,991,231 ns/iter (+/- 1,158,136) = 6 MB/s
test jquery        ... bench:  62,575,516 ns/iter (+/- 7,961,121) = 4 MB/s
test jquery_mobile ... bench: 100,782,152 ns/iter (+/- 8,935,520) = 4 MB/s
test mootools      ... bench:  45,443,780 ns/iter (+/- 3,365,737) = 3 MB/s
test underscore    ... bench:   7,676,725 ns/iter (+/- 1,539,086) = 5 MB/s
test yui           ... bench:  40,543,859 ns/iter (+/- 3,370,761) = 8 MB/s

After parallelizing at 16 (Stmt / ModuleItem)

test angular       ... bench:  48,842,568 ns/iter (+/- 4,468,933) = 14 MB/s
test babelify      ... bench:     739,406 ns/iter (+/- 59,612) = 14 MB/s
test backbone      ... bench:   8,026,579 ns/iter (+/- 420,012) = 7 MB/s
test jquery        ... bench:  43,572,668 ns/iter (+/- 3,550,682) = 6 MB/s
test jquery_mobile ... bench:  80,579,065 ns/iter (+/- 5,491,185) = 5 MB/s
test mootools      ... bench:  41,420,703 ns/iter (+/- 2,899,873) = 3 MB/s
test underscore    ... bench:   6,294,088 ns/iter (+/- 282,225) = 6 MB/s
test yui           ... bench:  38,877,714 ns/iter (+/- 2,635,799) = 8 MB/s

After updating rustc

test angular       ... bench:  47,982,607 ns/iter (+/- 4,717,277) = 14 MB/s
test babelify      ... bench:     697,951 ns/iter (+/- 90,836) = 15 MB/s
test backbone      ... bench:   7,803,192 ns/iter (+/- 624,180) = 7 MB/s
test jquery        ... bench:  42,665,607 ns/iter (+/- 4,048,595) = 6 MB/s
test jquery_mobile ... bench:  80,868,249 ns/iter (+/- 6,088,600) = 5 MB/s
test mootools      ... bench:  40,816,116 ns/iter (+/- 2,189,441) = 3 MB/s
test underscore    ... bench:   6,125,418 ns/iter (+/- 289,367) = 7 MB/s
test yui           ... bench:  38,198,975 ns/iter (+/- 2,428,404) = 8 MB/s

After using jemalloc

test angular       ... bench:  34,375,460 ns/iter (+/- 2,386,434) = 20 MB/s
test babelify      ... bench:     488,075 ns/iter (+/- 45,154) = 22 MB/s
test backbone      ... bench:   5,264,165 ns/iter (+/- 573,201) = 11 MB/s
test jquery        ... bench:  29,983,147 ns/iter (+/- 1,805,791) = 8 MB/s
test jquery_mobile ... bench:  49,249,437 ns/iter (+/- 2,625,456) = 9 MB/s
test mootools      ... bench:  29,492,723 ns/iter (+/- 2,126,989) = 5 MB/s
test underscore    ... bench:   4,238,421 ns/iter (+/- 320,107) = 10 MB/s
test yui           ... bench:  27,603,162 ns/iter (+/- 1,839,021) = 12 MB/s

After using copyless for boxes

test angular       ... bench:  33,790,241 ns/iter (+/- 2,123,525) = 21 MB/s
test babelify      ... bench:     497,054 ns/iter (+/- 58,993) = 21 MB/s
test backbone      ... bench:   5,209,823 ns/iter (+/- 550,537) = 11 MB/s
test jquery        ... bench:  29,559,234 ns/iter (+/- 1,742,346) = 9 MB/s
test jquery_mobile ... bench:  49,214,710 ns/iter (+/- 2,680,665) = 9 MB/s
test mootools      ... bench:  29,738,602 ns/iter (+/- 2,096,287) = 5 MB/s
test underscore    ... bench:   4,234,815 ns/iter (+/- 708,228) = 10 MB/s
test yui           ... bench:  27,570,892 ns/iter (+/- 1,885,246) = 12 MB/s

After using fxhash for comments.

test angular       ... bench:  31,653,049 ns/iter (+/- 2,234,914) = 22 MB/s
test babelify_only ... bench:     404,191 ns/iter (+/- 45,262) = 26 MB/s
test backbone      ... bench:   4,858,431 ns/iter (+/- 467,803) = 12 MB/s
test jquery        ... bench:  27,577,714 ns/iter (+/- 2,124,938) = 9 MB/s
test jquery_mobile ... bench:  45,780,071 ns/iter (+/- 2,254,891) = 9 MB/s
test mootools      ... bench:  27,561,764 ns/iter (+/- 959,586) = 5 MB/s
test underscore    ... bench:   3,941,828 ns/iter (+/- 649,169) = 11 MB/s
test yui           ... bench:  25,733,196 ns/iter (+/- 1,801,382) = 13 MB/s

After using ahash

test babelify_only                    ... bench:     608,587 ns/iter (+/- 724,437) = 17 MB/s
test parse_and_babelify_angular       ... bench:  32,331,065 ns/iter (+/- 1,527,210) = 22 MB/s
test parse_and_babelify_backbone      ... bench:   4,934,778 ns/iter (+/- 347,390) = 12 MB/s
test parse_and_babelify_jquery        ... bench:  28,162,852 ns/iter (+/- 1,565,345) = 9 MB/s
test parse_and_babelify_jquery_mobile ... bench:  46,670,964 ns/iter (+/- 1,742,944) = 9 MB/s
test parse_and_babelify_mootools      ... bench:  27,863,522 ns/iter (+/- 1,414,709) = 5 MB/s
test parse_and_babelify_underscore    ... bench:   3,973,752 ns/iter (+/- 350,331) = 10 MB/s
test parse_and_babelify_yui           ... bench:  26,188,477 ns/iter (+/- 1,363,907) = 12 MB/s

After using const rng of ahash

test babelify_only                    ... bench:     423,668 ns/iter (+/- 39,794) = 25 MB/s
test parse_and_babelify_angular       ... bench:  32,431,881 ns/iter (+/- 1,501,281) = 22 MB/s
test parse_and_babelify_backbone      ... bench:   5,019,902 ns/iter (+/- 418,990) = 11 MB/s
test parse_and_babelify_jquery        ... bench:  28,272,663 ns/iter (+/- 1,737,157) = 9 MB/s
test parse_and_babelify_jquery_mobile ... bench:  47,016,864 ns/iter (+/- 2,035,042) = 9 MB/s
test parse_and_babelify_mootools      ... bench:  28,305,270 ns/iter (+/- 1,417,147) = 5 MB/s
test parse_and_babelify_underscore    ... bench:   4,037,318 ns/iter (+/- 506,713) = 10 MB/s
test parse_and_babelify_yui           ... bench:  26,380,910 ns/iter (+/- 1,464,443) = 12 MB/s

@kdy1 kdy1 changed the title feat(node-swc): Babel plugin support feat(node-swc): Improve babelify May 3, 2021
@kdy1 kdy1 changed the title feat(node-swc): Improve babelify feat(node-swc): Improve performance of babelify May 3, 2021
@kdy1 kdy1 added this to the v1.2.55 milestone May 6, 2021
@kdy1 kdy1 changed the title feat(node-swc): Improve performance of babelify feat(babel/compat): Improve performance of babelify May 6, 2021
@kdy1 kdy1 marked this pull request as ready for review May 6, 2021 05:56
@kdy1 kdy1 merged commit 82ef06a into swc-project:master May 6, 2021
@kdy1 kdy1 deleted the babel branch May 6, 2021 05:56
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant