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

perf(es/minifier): Box VarUsageInfo of ProgramData #9894

Merged
merged 2 commits into from
Jan 19, 2025

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Jan 18, 2025

Description:

As the ProgramData.vars is re-allocated lots of time, we can reduce memmove operations by boxing the VarUsageInfo. This is because the hash map would need to allocate, e.g., 1024 * size_of<Box<T>> instead of 1024 * size_of<VarUsageInfo> while incrementing the size of the hash map from 512 to 1024.

Benchmarking es/minifier/libs/es/minifier/libs/antd
Benchmarking es/minifier/libs/es/minifier/libs/antd: Warming up for 3.0000 s
Benchmarking es/minifier/libs/es/minifier/libs/antd: Collecting 10 samples in estimated 9.7340 s (20 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/antd: Analyzing
es/minifier/libs/es/minifier/libs/antd
                        time:   [489.01 ms 490.05 ms 490.97 ms]
                        change: [-1.5287% -1.2158% -0.9269%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Benchmarking es/minifier/libs/es/minifier/libs/d3
Benchmarking es/minifier/libs/es/minifier/libs/d3: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 6.4s or enable flat sampling.
Benchmarking es/minifier/libs/es/minifier/libs/d3: Collecting 10 samples in estimated 6.4406 s (55 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/d3: Analyzing
es/minifier/libs/es/minifier/libs/d3
                        time:   [116.67 ms 117.18 ms 117.78 ms]
                        change: [-0.3332% +0.5408% +1.3860%] (p = 0.27 > 0.05)
                        No change in performance detected.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) low mild
Benchmarking es/minifier/libs/es/minifier/libs/echarts
Benchmarking es/minifier/libs/es/minifier/libs/echarts: Warming up for 3.0000 s
Benchmarking es/minifier/libs/es/minifier/libs/echarts: Collecting 10 samples in estimated 8.4715 s (20 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/echarts: Analyzing
es/minifier/libs/es/minifier/libs/echarts
                        time:   [424.80 ms 425.63 ms 426.53 ms]
                        change: [-0.8302% -0.5287% -0.2551%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Benchmarking es/minifier/libs/es/minifier/libs/jquery
Benchmarking es/minifier/libs/es/minifier/libs/jquery: Warming up for 3.0000 s
Benchmarking es/minifier/libs/es/minifier/libs/jquery: Collecting 10 samples in estimated 6.4860 s (165 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/jquery: Analyzing
es/minifier/libs/es/minifier/libs/jquery
                        time:   [39.416 ms 39.525 ms 39.635 ms]
                        change: [-1.1709% -0.3682% +0.3550%] (p = 0.37 > 0.05)
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  1 (10.00%) low mild
  1 (10.00%) high mild
Benchmarking es/minifier/libs/es/minifier/libs/lodash
Benchmarking es/minifier/libs/es/minifier/libs/lodash: Warming up for 3.0000 s
Benchmarking es/minifier/libs/es/minifier/libs/lodash: Collecting 10 samples in estimated 5.4512 s (110 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/lodash: Analyzing
es/minifier/libs/es/minifier/libs/lodash
                        time:   [48.916 ms 49.027 ms 49.132 ms]
                        change: [-0.3397% +0.1751% +0.7892%] (p = 0.55 > 0.05)
                        No change in performance detected.
Found 3 outliers among 10 measurements (30.00%)
  1 (10.00%) low severe
  1 (10.00%) high mild
  1 (10.00%) high severe
Benchmarking es/minifier/libs/es/minifier/libs/moment
Benchmarking es/minifier/libs/es/minifier/libs/moment: Warming up for 3.0000 s
Benchmarking es/minifier/libs/es/minifier/libs/moment: Collecting 10 samples in estimated 6.0985 s (275 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/moment: Analyzing
es/minifier/libs/es/minifier/libs/moment
                        time:   [21.975 ms 22.097 ms 22.180 ms]
                        change: [-0.5825% -0.0376% +0.4977%] (p = 0.89 > 0.05)
                        No change in performance detected.
Benchmarking es/minifier/libs/es/minifier/libs/react
Benchmarking es/minifier/libs/es/minifier/libs/react: Warming up for 3.0000 s
Benchmarking es/minifier/libs/es/minifier/libs/react: Collecting 10 samples in estimated 5.2885 s (770 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/react: Analyzing
es/minifier/libs/es/minifier/libs/react
                        time:   [6.8318 ms 6.8407 ms 6.8490 ms]
                        change: [-0.9893% -0.4427% +0.0059%] (p = 0.12 > 0.05)
                        No change in performance detected.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe
Benchmarking es/minifier/libs/es/minifier/libs/terser
Benchmarking es/minifier/libs/es/minifier/libs/terser: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 5.2s or enable flat sampling.
Benchmarking es/minifier/libs/es/minifier/libs/terser: Collecting 10 samples in estimated 5.2464 s (55 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/terser: Analyzing
es/minifier/libs/es/minifier/libs/terser
                        time:   [94.771 ms 95.388 ms 96.051 ms]
                        change: [-0.1542% +0.7131% +1.6361%] (p = 0.15 > 0.05)
                        No change in performance detected.
Benchmarking es/minifier/libs/es/minifier/libs/three
Benchmarking es/minifier/libs/es/minifier/libs/three: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 8.5s or enable flat sampling.
Benchmarking es/minifier/libs/es/minifier/libs/three: Collecting 10 samples in estimated 8.4619 s (55 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/three: Analyzing
es/minifier/libs/es/minifier/libs/three
                        time:   [153.14 ms 153.68 ms 154.43 ms]
                        change: [-0.9029% -0.0544% +0.8860%] (p = 0.92 > 0.05)
                        No change in performance detected.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild
Benchmarking es/minifier/libs/es/minifier/libs/typescript
Benchmarking es/minifier/libs/es/minifier/libs/typescript: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 9.7s.
Benchmarking es/minifier/libs/es/minifier/libs/typescript: Collecting 10 samples in estimated 9.7210 s (10 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/typescript: Analyzing
es/minifier/libs/es/minifier/libs/typescript
                        time:   [967.74 ms 972.37 ms 976.98 ms]
                        change: [-1.5382% -0.6114% +0.2760%] (p = 0.22 > 0.05)
                        No change in performance detected.
Benchmarking es/minifier/libs/es/minifier/libs/victory
Benchmarking es/minifier/libs/es/minifier/libs/victory: Warming up for 3.0000 s
Benchmarking es/minifier/libs/es/minifier/libs/victory: Collecting 10 samples in estimated 6.7932 s (30 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/victory: Analyzing
es/minifier/libs/es/minifier/libs/victory
                        time:   [226.69 ms 227.27 ms 227.88 ms]
                        change: [-1.1037% -0.7390% -0.3683%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Benchmarking es/minifier/libs/es/minifier/libs/vue
Benchmarking es/minifier/libs/es/minifier/libs/vue: Warming up for 3.0000 s
Benchmarking es/minifier/libs/es/minifier/libs/vue: Collecting 10 samples in estimated 5.9418 s (110 iterations)
Benchmarking es/minifier/libs/es/minifier/libs/vue: Analyzing
es/minifier/libs/es/minifier/libs/vue
                        time:   [53.880 ms 53.961 ms 54.118 ms]
                        change: [-1.2002% -0.0320% +0.9082%] (p = 0.96 > 0.05)
                        No change in performance detected.
Found 1 outliers among 10 measurements (10.00%)

@kdy1 kdy1 added this to the Planned milestone Jan 18, 2025
@kdy1 kdy1 self-assigned this Jan 18, 2025
Copy link

changeset-bot bot commented Jan 18, 2025

🦋 Changeset detected

Latest commit: 617d2be

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kdy1 kdy1 changed the title perf(es/minifier): Reduce memory allocations perf(es/minifier): Box VarUsageInfo of ProgramData Jan 19, 2025
@kdy1 kdy1 marked this pull request as ready for review January 19, 2025 04:43
@kdy1 kdy1 requested a review from a team as a code owner January 19, 2025 04:43
kodiakhq[bot]
kodiakhq bot previously approved these changes Jan 19, 2025
@kdy1 kdy1 requested a review from a team as a code owner January 19, 2025 04:43
@kdy1 kdy1 merged commit fafd754 into swc-project:main Jan 19, 2025
18 checks passed
@kdy1 kdy1 deleted the min-alloc branch January 19, 2025 04:44
@kdy1
Copy link
Member Author

kdy1 commented Jan 19, 2025

Original

heap stats:     peak       total       freed     current        unit       count
  reserved:     3.0 GiB     3.0 GiB     0           3.0 GiB
 committed:     2.9 GiB     3.0 GiB   720.7 MiB     2.2 GiB
     reset:     0
    purged:   575.5 MiB
   touched:    64.2 KiB   321.2 KiB   835.0 MiB  -834.7 MiB                          ok
  segments:     4           5           1           4                                not all freed
-abandoned:     0           0           0           0                                ok
   -cached:     0           0           0           0                                ok
     pages:     0           0           5.5 Ki     -5.5 Ki                           ok
-abandoned:     0           0           0           0                                ok
 -extended:     0
 -noretire:     0
    arenas:     3
-crossover:     0
 -rollback:     0
     mmaps:     0
   commits:     0
    resets:     0
    purges:   270
   threads:    31          31           0          31                                not all freed
  searches:     0.0 avg
numa nodes:     1
   elapsed:     2.680 s
   process: user: 3.090 s, system: 0.577 s, faults: 0, rss: 164.7 MiB, commit: 2.9 GiB

New

heap stats:     peak       total       freed     current        unit       count
  reserved:     2.0 GiB     2.0 GiB     0           2.0 GiB
 committed:     1.9 GiB     2.0 GiB   729.8 MiB     1.2 GiB
     reset:     0
    purged:   495.7 MiB
   touched:    64.2 KiB   321.2 KiB   685.3 MiB  -684.9 MiB                          ok
  segments:     4           5           2           3                                not all freed
-abandoned:     0           0           0           0                                ok
   -cached:     0           0           0           0                                ok
     pages:     0           0           5.9 Ki     -5.9 Ki                           ok
-abandoned:     0           0           0           0                                ok
 -extended:     0
 -noretire:     0
    arenas:     2
-crossover:     0
 -rollback:     0
     mmaps:     0
   commits:     0
    resets:     0
    purges:   263
   threads:    31          31           0          31                                not all freed
  searches:     0.0 avg
numa nodes:     1
   elapsed:     2.726 s
   process: user: 3.157 s, system: 0.562 s, faults: 0, rss: 159.6 MiB, commit: 1.9 GiB

@kdy1 kdy1 modified the milestones: Planned, 1.10.8 Jan 19, 2025
kdy1 added a commit to vercel/next.js that referenced this pull request Jan 20, 2025
### What?

Update SWC crates.

- ChangeLog: swc-project/swc@swc_core@v10.3.0...swc_core@v10.5.0


### Why?

To keep in sync and apply minifier perf PRs like

 - swc-project/swc#9894
 - swc-project/swc#9895
 - swc-project/swc#9900
 - swc-project/swc#9901
 - swc-project/swc#9902


### How?
@swc-project swc-project locked as resolved and limited conversation to collaborators Feb 18, 2025
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