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

Investigate why Vite is too slow #3855

Open
tachyons opened this issue Jun 30, 2023 · 12 comments
Open

Investigate why Vite is too slow #3855

tachyons opened this issue Jun 30, 2023 · 12 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@tachyons
Copy link
Member

vite v4.3.9 building for production...
transforming...


✓ 176 modules transformed.
rendering chunks...
computing gzip size...
../../public/vite/manifest-assets.json                           0.00 kB │ gzip:   0.02 kB
../../public/vite/assets/chevron-down-b11e7ab4.svg               0.37 kB │ gzip:   0.24 kB
../../public/vite/assets/fit-e5a0d8ab.svg                        0.40 kB │ gzip:   0.26 kB
../../public/vite/assets/save-online-b870412a.svg                0.44 kB │ gzip:   0.29 kB
../../public/vite/assets/save-9865bdd8.svg                       0.48 kB │ gzip:   0.30 kB
../../public/vite/assets/delete-e12e7722.svg                     0.50 kB │ gzip:   0.34 kB
../../public/vite/assets/redo-636a8fb3.svg                       0.50 kB │ gzip:   0.33 kB
../../public/vite/assets/undo-ca1f3958.svg                       0.51 kB │ gzip:   0.33 kB
../../public/vite/assets/close-12018d0f.svg                      0.54 kB │ gzip:   0.30 kB
../../public/vite/assets/download-46b76927.svg                   0.57 kB │ gzip:   0.35 kB
../../public/vite/assets/PortraidMode-ed428fd4.svg               2.74 kB │ gzip:   1.45 kB
../../public/vite/assets/ui-icons_cc0000_256x240-e6b6482e.png    4.62 kB
../../public/vite/assets/ui-icons_777620_256x240-ab37efb5.png    4.62 kB
../../public/vite/assets/CVLogo-0e0603ee.svg                     5.23 kB │ gzip:   2.41 kB
../../public/vite/manifest.json                                  5.59 kB │ gzip:   0.89 kB
../../public/vite/assets/ui-icons_ffffff_256x240-00e63e20.png    6.49 kB
../../public/vite/assets/ui-icons_555555_256x240-34fbc651.png    7.07 kB
../../public/vite/assets/ui-icons_444444_256x240-67c442fe.png    7.09 kB
../../public/vite/assets/ui-icons_777777_256x240-a177f8f9.png    7.11 kB
../../public/vite/assets/logo-345ab8c6.svg                      22.41 kB │ gzip:   9.19 kB
../../public/vite/assets/fa-solid-900-e2c5cf54.woff2           149.91 kB
../../public/vite/assets/fa-solid-900-67a880b4.ttf             394.83 kB
../../public/vite/assets/simulator-c6ed91cc.css                343.31 kB │ gzip:  63.84 kB
../../public/vite/assets/jquery-364e0644.js                      0.19 kB │ gzip:   0.17 kB │ map:     0.27 kB
../../public/vite/assets/_commonjsHelpers-87174ba5.js            0.78 kB │ gzip:   0.45 kB │ map:     0.11 kB
../../public/vite/assets/bootstrap-8ff7e24b.js                  85.49 kB │ gzip:  24.28 kB │ map:   348.17 kB
../../public/vite/assets/jquery-991d0b6a.js                     90.82 kB │ gzip:  32.36 kB │ map:   470.89 kB
../../public/vite/assets/simulator-916ec67b.js                 843.54 kB │ gzip: 228.68 kB │ map: 2,804.81 kB
✓ built in 6m 21s
@tanmoysrt
Copy link
Member

tanmoysrt commented Jun 30, 2023

I build the assets on my side. It's taking very less time compared to

Building with Vite ⚡️
vite v4.3.9 building for production...
transforming...
✓ 176 modules transformed.
rendering chunks...
computing gzip size...
../../public/vite/manifest-assets.json                           0.00 kB │ gzip:   0.02 kB
../../public/vite/assets/chevron-down-b11e7ab4.svg               0.37 kB │ gzip:   0.24 kB
../../public/vite/assets/fit-e5a0d8ab.svg                        0.40 kB │ gzip:   0.26 kB
../../public/vite/assets/save-online-b870412a.svg                0.44 kB │ gzip:   0.29 kB
../../public/vite/assets/save-9865bdd8.svg                       0.48 kB │ gzip:   0.30 kB
../../public/vite/assets/delete-e12e7722.svg                     0.50 kB │ gzip:   0.34 kB
../../public/vite/assets/redo-636a8fb3.svg                       0.50 kB │ gzip:   0.33 kB
../../public/vite/assets/undo-ca1f3958.svg                       0.51 kB │ gzip:   0.33 kB
../../public/vite/assets/close-12018d0f.svg                      0.54 kB │ gzip:   0.30 kB
../../public/vite/assets/download-46b76927.svg                   0.57 kB │ gzip:   0.35 kB
../../public/vite/assets/PortraidMode-ed428fd4.svg               2.74 kB │ gzip:   1.45 kB
../../public/vite/assets/ui-icons_777620_256x240-ab37efb5.png    4.62 kB
../../public/vite/assets/ui-icons_cc0000_256x240-e6b6482e.png    4.62 kB
../../public/vite/assets/CVLogo-0e0603ee.svg                     5.23 kB │ gzip:   2.41 kB
../../public/vite/manifest.json                                  5.59 kB │ gzip:   0.89 kB
../../public/vite/assets/ui-icons_ffffff_256x240-00e63e20.png    6.49 kB
../../public/vite/assets/ui-icons_555555_256x240-34fbc651.png    7.07 kB
../../public/vite/assets/ui-icons_444444_256x240-67c442fe.png    7.09 kB
../../public/vite/assets/ui-icons_777777_256x240-a177f8f9.png    7.11 kB
../../public/vite/assets/logo-345ab8c6.svg                      22.41 kB │ gzip:   9.19 kB
../../public/vite/assets/fa-solid-900-e2c5cf54.woff2           149.91 kB
../../public/vite/assets/fa-solid-900-67a880b4.ttf             394.83 kB
../../public/vite/assets/simulator-c6ed91cc.css                343.31 kB │ gzip:  63.84 kB
../../public/vite/assets/jquery-364e0644.js                      0.19 kB │ gzip:   0.17 kB │ map:     0.27 kB
../../public/vite/assets/_commonjsHelpers-87174ba5.js            0.78 kB │ gzip:   0.45 kB │ map:     0.11 kB
../../public/vite/assets/bootstrap-8ff7e24b.js                  85.49 kB │ gzip:  24.28 kB │ map:   348.17 kB
../../public/vite/assets/jquery-991d0b6a.js                     90.82 kB │ gzip:  32.36 kB │ map:   470.89 kB
../../public/vite/assets/simulator-916ec67b.js                 843.54 kB │ gzip: 228.68 kB │ map: 2,804.81 kB
✓ built in 8.64s
Build with Vite complete: /home/tanmoy/Desktop/oss/CircuitVerse/public/vite

...

OS : Ubuntu 20.04 LTS

@tachyons
Copy link
Member Author

tachyons commented Jul 4, 2023

@tanmoysrt That could be because of the CPU cores and RAM availability in your machine

@tachyons tachyons added the help wanted Extra attention is needed label Jul 4, 2023
@tachyons tachyons pinned this issue Jul 4, 2023
@tanmoysrt
Copy link
Member

tanmoysrt commented Jul 4, 2023

@tanmoysrt That could be because of the CPU cores and RAM availability in your machine

Can you share the specs of the system , then I can try to reproduce the result and can try to find solution

@zzz-creator
Copy link

@tanmoysrt That could be because of the CPU cores and RAM availability in your machine

Can you share the specs of the system , then I can try to reproduce the result and can try to find solution

@smritigarg
Copy link
Contributor

smritigarg commented Jul 7, 2023

@tachyons @tanmoysrt how many times will we need to build these assets?

@tachyons
Copy link
Member Author

tachyons commented Jul 7, 2023

@tanmoysrt 4GB ram single core ec2 instance

@smritigarg Once for each deployment

@tanmoysrt
Copy link
Member

@tanmoysrt 4GB ram single core ec2 instance

@smritigarg Once for each deployment

Thanks , will check that

@tanmoysrt
Copy link
Member

@tanmoysrt 4GB ram single core ec2 instance

@smritigarg Once for each deployment

What is its os and version ?

@tachyons
Copy link
Member Author

tachyons commented Jul 7, 2023

Ubuntu 20.04

@tanmoysrt
Copy link
Member

tanmoysrt commented Jul 8, 2023

I have tested this in EC2 with various configuration.
Based on that, on average Vite requires almost 80% of 1 vCPU and ~500 mb memory to production bundle within 25 seconds.

  1. CPU is the bottleneck in this process, as with low memory also it works.
  2. During tests, found that this vite sometimes left the server in throttled state and without force reboot cant up the server

Little Optimization can be -

  1. We can reduce the time by ~30% by removing the source map while bundling
import { defineConfig } from 'vite'
import RubyPlugin from 'vite-plugin-ruby'

export default defineConfig({
  build : {
    sourcemap: false
  },
  plugins: [
    RubyPlugin(),
  ],
})

@tachyons can we offload the task from the server?
Like make the vite build part of docker image generation step and we can create a cronjob in Github Actions which will run every 24 hr to generate and upload to Github Container Registry. As the Github runner has high resources , vite will take few seconds to build assets.

@tachyons
Copy link
Member Author

tachyons commented Jul 8, 2023

Yes, this step will be removed from server once the containarization is completed, still the speed of vite is significantly slower than esbuild based configuration.

10 seconds to 6 minutes is too much

@tanmoysrt
Copy link
Member

Yes, this step will be removed from server once the containarization is completed, still the speed of vite is significantly slower than esbuild based configuration.

10 seconds to 6 minutes is too much

Yes the time is so high, and with lower resources it grows exponentially. With 300 mb ram & 30% VCPU it takes a round 35 minute to building.

I am searching if this resource issue of vite can be solved somehow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Development

No branches or pull requests

4 participants