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(es/minifier): Inline lazy inited vars #5737

Merged
merged 16 commits into from
Sep 8, 2022
Merged

Conversation

Austaras
Copy link
Member

@Austaras Austaras commented Sep 4, 2022

Description:

BREAKING CHANGE:

Related issue (if exists):
related #5559

@Austaras Austaras marked this pull request as draft September 4, 2022 09:34
@Austaras Austaras marked this pull request as ready for review September 5, 2022 12:16
@kdy1 kdy1 added this to the Planned milestone Sep 5, 2022
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Thank you!

I'm worried about some test changes

@kdy1
Copy link
Member

kdy1 commented Sep 6, 2022

Seems like it has a noticeable impact on performance.
I ran benchmark twice to get differnce.

Gnuplot not found, using plotters backend
Benchmarking es/minify/libraries/antd
Benchmarking es/minify/libraries/antd: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 8.3s.
Benchmarking es/minify/libraries/antd: Collecting 10 samples in estimated 8.2953 s (10 iterations)
Benchmarking es/minify/libraries/antd: Analyzing
es/minify/libraries/antd
                        time:   [829.03 ms 831.13 ms 833.39 ms]
                        change: [+3.6791% +4.0940% +4.5071%] (p = 0.00 < 0.05)
                        Performance has regressed.
Benchmarking es/minify/libraries/d3
Benchmarking es/minify/libraries/d3: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 9.2s or enable flat sampling.
Benchmarking es/minify/libraries/d3: Collecting 10 samples in estimated 9.2125 s (55 iterations)
Benchmarking es/minify/libraries/d3: Analyzing
es/minify/libraries/d3  time:   [160.70 ms 161.29 ms 161.75 ms]
                        change: [+3.8268% +4.2130% +4.6161%] (p = 0.00 < 0.05)
                        Performance has regressed.
Benchmarking es/minify/libraries/echarts
Benchmarking es/minify/libraries/echarts: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 6.6s.
Benchmarking es/minify/libraries/echarts: Collecting 10 samples in estimated 6.6295 s (10 iterations)
Benchmarking es/minify/libraries/echarts: Analyzing
es/minify/libraries/echarts
                        time:   [662.64 ms 666.59 ms 670.55 ms]
                        change: [+4.1153% +4.8756% +5.5201%] (p = 0.00 < 0.05)
                        Performance has regressed.
Benchmarking es/minify/libraries/jquery
Benchmarking es/minify/libraries/jquery: Warming up for 3.0000 s
Benchmarking es/minify/libraries/jquery: Collecting 10 samples in estimated 7.4047 s (165 iterations)
Benchmarking es/minify/libraries/jquery: Analyzing
es/minify/libraries/jquery
                        time:   [44.646 ms 44.970 ms 45.590 ms]
                        change: [+3.5938% +4.7226% +6.2589%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild
Benchmarking es/minify/libraries/lodash
Benchmarking es/minify/libraries/lodash: Warming up for 3.0000 s
Benchmarking es/minify/libraries/lodash: Collecting 10 samples in estimated 6.4630 s (110 iterations)
Benchmarking es/minify/libraries/lodash: Analyzing
es/minify/libraries/lodash
                        time:   [58.106 ms 58.251 ms 58.439 ms]
                        change: [-0.4730% +1.8331% +3.5444%] (p = 0.12 > 0.05)
                        No change in performance detected.
Found 3 outliers among 10 measurements (30.00%)
  1 (10.00%) low mild
  1 (10.00%) high mild
  1 (10.00%) high severe
Benchmarking es/minify/libraries/moment
Benchmarking es/minify/libraries/moment: Warming up for 3.0000 s
Benchmarking es/minify/libraries/moment: Collecting 10 samples in estimated 6.1733 s (220 iterations)
Benchmarking es/minify/libraries/moment: Analyzing
es/minify/libraries/moment
                        time:   [27.726 ms 27.802 ms 27.883 ms]
                        change: [+7.2839% +8.0099% +9.0483%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe
Benchmarking es/minify/libraries/react
Benchmarking es/minify/libraries/react: Warming up for 3.0000 s
Benchmarking es/minify/libraries/react: Collecting 10 samples in estimated 5.3063 s (440 iterations)
Benchmarking es/minify/libraries/react: Analyzing
es/minify/libraries/react
                        time:   [11.894 ms 11.925 ms 11.970 ms]
                        change: [+6.5085% +7.0331% +7.5466%] (p = 0.00 < 0.05)
                        Performance has regressed.
Benchmarking es/minify/libraries/terser
Benchmarking es/minify/libraries/terser: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 7.5s or enable flat sampling.
Benchmarking es/minify/libraries/terser: Collecting 10 samples in estimated 7.5296 s (55 iterations)
Benchmarking es/minify/libraries/terser: Analyzing
es/minify/libraries/terser
                        time:   [136.51 ms 136.78 ms 136.94 ms]
                        change: [+4.0720% +4.9253% +5.9873%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe
Benchmarking es/minify/libraries/three
Benchmarking es/minify/libraries/three: Warming up for 3.0000 s
Benchmarking es/minify/libraries/three: Collecting 10 samples in estimated 6.4533 s (30 iterations)
Benchmarking es/minify/libraries/three: Analyzing
es/minify/libraries/three
                        time:   [212.99 ms 213.32 ms 213.63 ms]
                        change: [+2.4322% +2.9403% +3.3006%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 2 outliers among 10 measurements (20.00%)
  2 (20.00%) low mild
Benchmarking es/minify/libraries/typescript
Benchmarking es/minify/libraries/typescript: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 19.1s.
Benchmarking es/minify/libraries/typescript: Collecting 10 samples in estimated 19.130 s (10 iterations)
Benchmarking es/minify/libraries/typescript: Analyzing
es/minify/libraries/typescript
                        time:   [1.8887 s 1.8967 s 1.9067 s]
                        change: [+3.2792% +4.2977% +5.1520%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild
Benchmarking es/minify/libraries/victory
Benchmarking es/minify/libraries/victory: Warming up for 3.0000 s
Benchmarking es/minify/libraries/victory: Collecting 10 samples in estimated 7.2624 s (20 iterations)
Benchmarking es/minify/libraries/victory: Analyzing
es/minify/libraries/victory
                        time:   [359.55 ms 360.89 ms 362.28 ms]
                        change: [+2.8333% +3.5643% +4.3209%] (p = 0.00 < 0.05)
                        Performance has regressed.
Benchmarking es/minify/libraries/vue
Benchmarking es/minify/libraries/vue: Warming up for 3.0000 s
Benchmarking es/minify/libraries/vue: Collecting 10 samples in estimated 7.5604 s (110 iterations)
Benchmarking es/minify/libraries/vue: Analyzing
es/minify/libraries/vue time:   [68.200 ms 68.512 ms 68.986 ms]
                        change: [+3.5048% +4.5375% +5.4641%] (p = 0.00 < 0.05)
                        Performance has regressed.

@Austaras
Copy link
Member Author

Austaras commented Sep 6, 2022

How to do benchmark? However I'm afraid performance cost is unavoidable

@kdy1
Copy link
Member

kdy1 commented Sep 6, 2022

Can't we store it in lits of Optimizer?

@kdy1
Copy link
Member

kdy1 commented Sep 6, 2022

To run benchmark, you can do RUST_LOG=off cargo bench --features concurrent

@Austaras
Copy link
Member Author

Austaras commented Sep 6, 2022

I know where is wrong. I'll fix it tonight

@kdy1
Copy link
Member

kdy1 commented Sep 6, 2022

Can you rebase, please?

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Thanks!

@Austaras
Copy link
Member Author

Austaras commented Sep 7, 2022

Some personal TODO

export function TinyColor(v, i) {
    var mod,
        r1,
        g1,
        rgb1 =
            ((r1 = [v, v, v, v, v, v][(mod = i % 6)]),
            (g1 = [v, v, v, v, v, v][mod]),
            {
                r: 255 * r1,
                g: 255 * g1,
                b: 255 * [p, p, t, v, v, q][mod],
            });
    this.isValid = rgb1.ok;
}
export function x() {
  var b, c
  c = (b = x(), console.log(), b)
  console.log(c)
}

seems both are about sequence expression

@kdy1
Copy link
Member

kdy1 commented Sep 8, 2022

Can you rebase?

kdy1
kdy1 previously approved these changes Sep 8, 2022
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Changes look good.

Thank you!


swc-bump:

  • swc_ecma_minifier

@kdy1 kdy1 enabled auto-merge (squash) September 8, 2022 07:28
@kdy1 kdy1 disabled auto-merge September 8, 2022 07:28
@kdy1 kdy1 enabled auto-merge (squash) September 8, 2022 07:29
@kdy1 kdy1 merged commit ee26337 into swc-project:main Sep 8, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.0 Sep 10, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 16, 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.

None yet

2 participants