-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Vite 2.7.x is about 1.9 to 6.2 times slower than 2.6.14 #6030
Comments
We also experience vendor package size increase 3-4 times. Seems like tree shake is broken in some way. Also, the random part of functionality is broken. |
@alfeg I haven't noticed that, in the example repo that I posted it looks to be the same. But I haven't checked if tree shaking is working as it should in the first place in 2.6 either. vite v2.6.14 building for production...
✓ 10762 modules transformed.
dist/assets/favicon.17e50649.svg 1.49 KiB
dist/assets/logo.ecc203fb.svg 2.61 KiB
dist/index.html 0.52 KiB
dist/assets/index.b81c8c87.js 1.70 KiB / gzip: 0.91 KiB
dist/assets/index.cd9c0392.css 0.75 KiB / gzip: 0.48 KiB
dist/assets/vendor.ae31e9b8.js 235.78 KiB / gzip: 78.01 KiB
vite v2.7.1 building for production...
✓ 10762 modules transformed.
dist/assets/favicon.17e50649.svg 1.49 KiB
dist/assets/logo.ecc203fb.svg 2.61 KiB
dist/index.html 0.52 KiB
dist/assets/index.b81c8c87.js 1.70 KiB / gzip: 0.91 KiB
dist/assets/index.cd9c0392.css 0.75 KiB / gzip: 0.48 KiB
dist/assets/vendor.ae31e9b8.js 235.78 KiB / gzip: 78.01 KiB
|
This comment was marked as off-topic.
This comment was marked as off-topic.
For both 2.6 and 2.7, you're using the same version of |
Yes, the same version, which resolved to 1.1.1, when I created this issue. I did not change the plugin-react version between the tests. Only targeted different versions of vite using We noticed the issue in our internal project at work. So, I created the example repository and could reproduce it there with the same results. As we mainly use Windows, we are now stuck on 2.6, as we switched to Vite from CRA because of the bad performance of CRA. But as you can see the performance degration is also visible on Linux, but as the Linux file system, in my experience, is a lot faster at handling many small files request than Windows, the performance degration is not as big there, but still significant I would say. Let me know if there is anything else I can do to help to track down the cause of this. |
You can try using |
Hi @aleclarson! I've now had time to run the profile traces, and from the first look at it, it looks like the main regression is in how often realPath is being called. Maybe it's related to this file: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/resolve.ts I haven't had much more time to investigate the changes between 2.6.14 and 2.7.0 that calls realPath, but maybe someone with more experience with the code base could find it. I've also attached the files: |
@Lani Thanks for investigating! You could try |
@aleclarson Thanks for the tip! Preserving symlinks doubled the speed! I now see dev startup times between 20-22 seconds. With this setting active 2.7 is only about 3 times slower than 2.6. That is still significant though, so if you manage to reduce the number of realpath calls to speed 2.7 up even more, that would be great 😃 Maybe it's possible to cache some of the calls? |
I spent a big part of my day yesterday writing exactly that. 😄 If you'd like, I could share the code with you to try locally and I'll submit a PR to Vite, but I'm trying to boost my GitHub sponsor count, so I'd like to ask if could first sponsor me for as little as $1 (or however much you value this fix). 🤞 Cheers 🍻 |
@aleclarson I'd be happy to try out the changes that you've made. I'm, however, going on vacation over the holidays, so it may be a couple of weeks before I can get to it. We just started using Vite at work, at it's really great! We do not yet have a process in place for sponsoring open-source projects, but I'm advocating for it. I did, however, sponsor you personally with a onetime $10 donation. I think that the work is worth more than that, related to the hours that you've probably put into it. But hopefully it counts as something. Merry Christmas! 🎅 |
This comment was marked as spam.
This comment was marked as spam.
#6412 is ready for testing in big projects @Lani Your donation is greatly appreciated! ❤️ Others impacted by this bug are also encouraged to sponsor me for $1 to help me boost my sponsor count. Even a small donation will help Vite more than you know, as I'm withholding a lot of improvements because I feel unappreciated around here. |
Also donated, love your work @aleclarson |
@aleclarson I've tried to build vite to test this, but I get the following error: /c/code/_github/vite/packages/vite (feat/realpath-cache)
$ pnpm build-bundle
> vite@2.8.0-beta.1 build-bundle C:\code\_github\vite\packages\vite
> rollup -c
C:\code\_github\vite\packages\vite\src\client\env.ts → dist\client\env.mjs...
created dist\client\env.mjs in 2s
C:\code\_github\vite\packages\vite\src\client\client.ts → dist\client\client.mjs...
created dist\client\client.mjs in 2.3s
C:\code\_github\vite\packages\vite\src\node\index.ts, C:\code\_github\vite\packages\vite\src\node\cli.ts → dist...
shimmed: plugins/terser.ts
shimmed: cac/dist/index.mjs
shimmed: fsevents-handler.js
shimmed: process-content.js
shimmed: lilconfig/dist/index.js
shimmed: import-from/index.js
(!) Plugin typescript: @rollup/plugin-typescript TS2304: Cannot find name 'cjsInclude'.
src\node\packages.ts: (124:9)
124 if (cjsInclude && pkgPath !== originalPkgPath) {
~~~~~~~~~~
src\node\packages.ts: (125:35)
125 const filter = createFilter(cjsInclude, undefined, { resolve: false })
~~~~~~~~~~
src\node\packages.ts: (127:9)
127 cjsInclude.push(path.dirname(pkgPath) + '/**')
~~~~~~~~~~
created dist in 28.3s
C:\code\_github\vite\node_modules\.pnpm\terser@5.10.0_acorn@8.7.0\node_modules\terser\dist\bundle.min.js → dist...
created dist in 1.3s |
@Lani whoops, I fixed that but pushed to the wrong branch, so try again :) |
@aleclarson Thank you for the work you've put in! The PR helped some, but unfortunately it is still a big regression from 2.6. On Windows it now went from 6.2 times slower to 3.9 times slower: 2.6.14: 9, 9, 10, 9, 9 (re-ran to get current state of my environment) With preserveSymlinks set to true it is, however, a little better, but still 3 times slower than 2.6. Hopefully, there is something more that can be done? As the performance of 2.6 was what made us switch to vite. In a monorepo the dependencies often change, so full rebuilds happen often. With this change I wouldn't say that it is a dealbreaker, but still unfortunate that vite has gotten so much slower. This is the cache hit metrics from the production build (I didn't figure out how to get them from the dev build): vite v2.8.0-beta.1 building for production...
✓ 10762 modules transformed.
rendering chunks (2)...
cacheSize: 62
cacheHits: 724
fsCalls: 62 |
This comment has been minimized.
This comment has been minimized.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Hot load is very slow in vite@2.8.4. |
FYI the output result with my repository was as below.
|
Had the same problem, the profile file is as follows, the current startup time has reached an astonishing 26994ms |
We know the problem arrived between v2.6.14 and v2.7.0, according to @Lani's report. Can someone narrow the problem down to a specific beta version? |
Do you mean to test and upload the profile file with the beta version? Tested vite 2.9.0-beta.2 and it seems to solve the problem 27910ms => 5093ms |
@rxliuli That's probably a result of 24bb3e4 (not 100% sure), but it's not a true fix, since dep optimization was added long before this regression was reported. To confirm my suspicion, you could test v2.9.0-beta.0 to see if it's not "fixed" there too. I'm asking if someone can find which 2.7 beta version introduced this regression |
I tested it and basically determined that it was a bug introduced by 2.7.0-beta.5 test command pnpm i && rm -rf node_modules/.vite/ && pnpm vite --profile --force
profile
I'm basically sure it's a performance issue with #5665 , the following is a performance comparison before and after including this pr
|
We have been improving Vite's performance lately and I believe this has been fixed by the few PR references above. Closing this as the work has been completed. Appreciate if anyone following would give Vite 4.3 beta a spin too. |
@bluwy Just WOW! It builds under the second now! Really impressive work by the team! Thank you for all the effort that you have put into this. |
Describe the bug
When upgrading from vite 2.6.14 to 2.7.x the development build performance is about 6.2 times slower on Windows and 1.9 times slower on Ubuntu 20.04 running in WSL2.
Results in seconds on Windows 10:
2.6.14: 12, 7, 7, 6, 6
2.7.1: 46, 47, 46, 47, 48
2.7 is about 6.2 times slower.
Results on Ubuntu 20.04 in WSL2:
2.6.14: 3, 4, 4, 4, 4
2.7.1: 7, 7, 8, 8, 6
2.7 is about 1.9 times slower.
Reproduction
Example repo: https://github.com/Lani/vite-2.7-slow
Steps to reproduce:
npm i
npm run dev -- --force
System Info
Windows
Ubuntu:
Used Package Manager
npm
Logs
Windows log:
The text was updated successfully, but these errors were encountered: