vite: Vite 2.7.x is about 1.9 to 6.2 times slower than 2.6.14
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.
Times rounded to nearest second.
Reproduction
Example repo: https://github.com/Lani/vite-2.7-slow
Steps to reproduce:
npm i
npm run dev -- --force
Use --force to always start without the cache
System Info
Windows
System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Memory: 20.85 GB / 39.75 GB
Binaries:
Node: 14.15.4 - C:\Tools\nodejs\node.EXE
npm: 6.14.10 - C:\Tools\nodejs\npm.CMD
Browsers:
Chrome: 96.0.4664.93
Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.43)
Internet Explorer: 11.0.19041.1202
npmPackages:
@vitejs/plugin-react: ^1.1.0 => 1.1.1
vite: ^2.7.1 => 2.7.1
Ubuntu:
System:
OS: Linux 4.19 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Memory: 30.14 GB / 31.17 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.15.4 - ~/.nvm/versions/node/v14.15.4/bin/node
npm: 7.24.1 - ~/.nvm/versions/node/v14.15.4/bin/npm
npmPackages:
@vitejs/plugin-react: ^1.1.0 => 1.1.1
vite: ^2.7.1 => 2.7.1
Used Package Manager
npm
No notable difference when using pnpm instead of npm.
Logs
Windows log:
vite:config bundled config file loaded in 425.78ms +0ms
vite:config using resolved config: {
vite:config plugins: [
vite:config 'vite:pre-alias',
vite:config 'alias',
vite:config 'vite:react-babel',
vite:config 'vite:react-refresh',
vite:config 'vite:react-jsx',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html-inline-script-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:client-inject',
vite:config 'vite:import-analysis'
vite:config ],
vite:config server: { force: true, fs: { strict: true, allow: [Array], deny: [Array] } },
vite:config resolve: { dedupe: [ 'react', 'react-dom' ], alias: [ [Object], [Object] ] },
vite:config optimizeDeps: {
vite:config include: [ 'react/jsx-dev-runtime' ],
vite:config esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
vite:config },
vite:config configFile: 'C:/code/_labs/vite-default/vite.config.ts',
vite:config configFileDependencies: [ 'vite.config.ts' ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config server: { force: true, fs: [Object] }
vite:config },
vite:config root: 'C:/code/_labs/vite-default',
vite:config base: '/',
vite:config publicDir: 'C:\\code\\_labs\\vite-default\\public',
vite:config cacheDir: 'C:\\code\\_labs\\vite-default\\node_modules\\.vite',
vite:config command: 'serve',
vite:config mode: 'development',
vite:config isProduction: false,
vite:config build: {
vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config polyfillModulePreload: true,
vite:config outDir: 'C:\\code\\_labs\\vite-default\\dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config sourcemap: false,
vite:config rollupOptions: { input: 'C:\\code\\_labs\\vite-default\\index.html' },
vite:config minify: 'esbuild',
vite:config terserOptions: {},
vite:config write: true,
vite:config emptyOutDir: null,
vite:config manifest: false,
vite:config lib: false,
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config reportCompressedSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null,
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite:config },
vite:config preview: {
vite:config port: undefined,
vite:config strictPort: undefined,
vite:config host: undefined,
vite:config https: undefined,
vite:config open: undefined,
vite:config proxy: undefined,
vite:config cors: undefined
vite:config },
vite:config env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen],
vite:config hasErrorLogged: [Function: hasErrorLogged]
vite:config },
vite:config packageCache: Map(0) {},
vite:config createResolver: [Function: createResolver]
vite:config } +13ms
vite:deps Crawling dependencies using entries:
vite:deps C:\code\_labs\vite-default\index.html +0ms
vite:resolve 4.14ms C:\code\_labs\vite-default\index.html -> C:/code/_labs/vite-default/index.html +0ms
vite:resolve 1.17ms /src/main.tsx -> C:/code/_labs/vite-default/src/main.tsx +29ms
vite:resolve 7.34ms react -> C:/code/_labs/vite-default/node_modules/react/index.js +13ms
vite:resolve 5.92ms react-dom -> C:/code/_labs/vite-default/node_modules/react-dom/index.js +7ms
vite:resolve 2.83ms ./App -> C:/code/_labs/vite-default/src/App.tsx +16ms
vite:resolve 5.57ms @mui/material -> C:/code/_labs/vite-default/node_modules/@mui/material/index.js +10ms
vite:resolve 3.88ms @mui/icons-material -> C:/code/_labs/vite-default/node_modules/@mui/icons-material/esm/index.js +7ms
vite:resolve 4.01ms @mui/styles -> C:/code/_labs/vite-default/node_modules/@mui/styles/index.js +8ms
vite:deps Scan completed in 119.05ms: {
react: 'C:/code/_labs/vite-default/node_modules/react/index.js',
'react-dom': 'C:/code/_labs/vite-default/node_modules/react-dom/index.js',
'@mui/material': 'C:/code/_labs/vite-default/node_modules/@mui/material/index.js',
'@mui/icons-material': 'C:/code/_labs/vite-default/node_modules/@mui/icons-material/esm/index.js',
'@mui/styles': 'C:/code/_labs/vite-default/node_modules/@mui/styles/index.js'
} +118ms
vite:resolve 4.99ms react/jsx-dev-runtime -> C:/code/_labs/vite-default/node_modules/react/jsx-dev-runtime.js +0ms
Pre-bundling dependencies:
react
react-dom
@mui/material
@mui/icons-material
@mui/styles
(...and 1 more)
(this will be run only when your dependencies or config have changed)
vite:resolve 5.53ms @mui/utils -> C:/code/_labs/vite-default/node_modules/@mui/utils/esm/index.js +0ms
vite:resolve 5.85ms object-assign -> C:/code/_labs/vite-default/node_modules/object-assign/index.js +0ms
vite:resolve 13.07ms react -> C:/code/_labs/vite-default/node_modules/react/index.js +14ms
vite:resolve 13.49ms @mui/base -> C:/code/_labs/vite-default/node_modules/@mui/base/index.js +28ms
vite:resolve 7.06ms scheduler -> C:/code/_labs/vite-default/node_modules/scheduler/index.js +67ms
vite:resolve 36.15ms @mui/private-theming/useTheme -> C:/code/_labs/vite-default/node_modules/@mui/private-theming/useTheme/index.js +103ms
vite:resolve 36.49ms @babel/runtime/helpers/esm/extends -> C:/code/_labs/vite-default/node_modules/@babel/runtime/helpers/esm/extends.js +0ms
vite:resolve 36.84ms @mui/private-theming/ThemeProvider -> C:/code/_labs/vite-default/node_modules/@mui/private-theming/ThemeProvider/index.js +1ms
vite:resolve 37.34ms jss-plugin-rule-value-function -> C:/code/_labs/vite-default/node_modules/jss-plugin-rule-value-function/dist/jss-plugin-rule-value-function.esm.js +1ms
vite:resolve 64.19ms scheduler/tracing -> C:/code/_labs/vite-default/node_modules/scheduler/tracing.js +104ms
vite:resolve 64.44ms @babel/runtime/helpers/esm/objectWithoutPropertiesLoose -> C:/code/_labs/vite-default/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +66ms
vite:resolve 27.35ms jss-plugin-global -> C:/code/_labs/vite-default/node_modules/jss-plugin-global/dist/jss-plugin-global.esm.js +29ms
vite:resolve 27.70ms react -> C:/code/_labs/vite-default/node_modules/react/index.js +0ms
vite:resolve 132.77ms prop-types -> C:/code/_labs/vite-default/node_modules/prop-types/index.js +136ms
vite:resolve 132.74ms react-is -> C:/code/_labs/vite-default/node_modules/@mui/utils/node_modules/react-is/index.js +1ms
vite:resolve 43.22ms jss-plugin-nested -> C:/code/_labs/vite-default/node_modules/jss-plugin-nested/dist/jss-plugin-nested.esm.js +49ms
vite:resolve 42.98ms hoist-non-react-statics -> C:/code/_labs/vite-default/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js +1ms vite:resolve 43.09ms jss -> C:/code/_labs/vite-default/node_modules/jss/dist/jss.esm.js +0ms
vite:resolve 43.46ms react-is -> C:/code/_labs/vite-default/node_modules/react-is/index.js +218ms
vite:resolve 25.53ms clsx -> C:/code/_labs/vite-default/node_modules/clsx/dist/clsx.m.js +35ms
vite:resolve 26.06ms jss-plugin-camel-case -> C:/code/_labs/vite-default/node_modules/jss-plugin-camel-case/dist/jss-plugin-camel-case.esm.js +1ms
vite:resolve 21.24ms react/jsx-runtime -> C:/code/_labs/vite-default/node_modules/react/jsx-runtime.js +24ms
vite:resolve 23.80ms jss-plugin-default-unit -> C:/code/_labs/vite-default/node_modules/jss-plugin-default-unit/dist/jss-plugin-default-unit.esm.js +25ms
vite:resolve 285.33ms @mui/base/ModalUnstyled -> C:/code/_labs/vite-default/node_modules/@mui/base/ModalUnstyled/index.js +339ms
vite:resolve 284.60ms @mui/base/TextareaAutosize -> C:/code/_labs/vite-default/node_modules/@mui/base/TextareaAutosize/index.js +1ms
vite:resolve 284.97ms @mui/base/NoSsr -> C:/code/_labs/vite-default/node_modules/@mui/base/NoSsr/index.js +0ms
vite:resolve 284.94ms jss-plugin-vendor-prefixer -> C:/code/_labs/vite-default/node_modules/jss-plugin-vendor-prefixer/dist/jss-plugin-vendor-prefixer.esm.js +1ms
vite:resolve 284.71ms @mui/base/ClickAwayListener -> C:/code/_labs/vite-default/node_modules/@mui/base/ClickAwayListener/index.js +1ms
vite:resolve 284.78ms @mui/system -> C:/code/_labs/vite-default/node_modules/@mui/system/esm/index.js +1ms
vite:resolve 285.49ms @mui/base/AutocompleteUnstyled -> C:/code/_labs/vite-default/node_modules/@mui/base/AutocompleteUnstyled/index.js +1ms
vite:resolve 1053.37ms is-in-browser -> C:/code/_labs/vite-default/node_modules/is-in-browser/dist/module.js +1s
vite:resolve 1387.42ms jss-plugin-props-sort -> C:/code/_labs/vite-default/node_modules/jss-plugin-props-sort/dist/jss-plugin-props-sort.esm.js +1s
vite:resolve 1385.79ms @mui/styled-engine -> C:/code/_labs/vite-default/node_modules/@mui/styled-engine/index.js +2ms
vite:resolve 720.73ms tiny-warning -> C:/code/_labs/vite-default/node_modules/tiny-warning/dist/tiny-warning.esm.js +7s
vite:resolve 605.37ms react-dom -> C:/code/_labs/vite-default/node_modules/react-dom/index.js +610ms
vite:resolve 678.20ms css-vendor -> C:/code/_labs/vite-default/node_modules/css-vendor/dist/css-vendor.esm.js +3s
vite:resolve 678.36ms @mui/material/utils -> C:/code/_labs/vite-default/node_modules/@mui/material/utils/index.js +0ms
vite:resolve 687.91ms hyphenate-style-name -> C:/code/_labs/vite-default/node_modules/hyphenate-style-name/index.js +697ms
vite:resolve 602.13ms @emotion/styled -> C:/code/_labs/vite-default/node_modules/@emotion/styled/dist/emotion-styled.browser.esm.js +24s
vite:resolve 602.50ms @mui/private-theming -> C:/code/_labs/vite-default/node_modules/@mui/private-theming/index.js +1ms
vite:resolve 600.95ms @babel/runtime/helpers/esm/createClass -> C:/code/_labs/vite-default/node_modules/@babel/runtime/helpers/esm/createClass.js +1ms
vite:resolve 428.78ms react-is -> C:/code/_labs/vite-default/node_modules/@mui/material/node_modules/react-is/index.js +434ms
vite:resolve 429.25ms @mui/base/PopperUnstyled -> C:/code/_labs/vite-default/node_modules/@mui/base/PopperUnstyled/index.js +0ms
vite:resolve 578.98ms @emotion/react -> C:/code/_labs/vite-default/node_modules/@emotion/react/dist/emotion-react.browser.esm.js +584ms
vite:resolve 576.90ms @babel/runtime/helpers/esm/inheritsLoose -> C:/code/_labs/vite-default/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +1ms
vite:resolve 568.55ms react-is -> C:/code/_labs/vite-default/node_modules/@mui/base/node_modules/react-is/index.js +1ms
vite:resolve 568.97ms @popperjs/core -> C:/code/_labs/vite-default/node_modules/@popperjs/core/lib/index.js +1ms
vite:resolve 568.87ms react-transition-group -> C:/code/_labs/vite-default/node_modules/react-transition-group/esm/index.js +1ms
vite:resolve 509.42ms @babel/runtime/helpers/esm/assertThisInitialized -> C:/code/_labs/vite-default/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +520ms
vite:resolve 506.83ms @mui/base/BackdropUnstyled -> C:/code/_labs/vite-default/node_modules/@mui/base/BackdropUnstyled/index.js +1ms
vite:resolve 40.92ms @babel/runtime/helpers/esm/toConsumableArray -> C:/code/_labs/vite-default/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +44ms
vite:resolve 41.43ms @babel/runtime/helpers/extends -> C:/code/_labs/vite-default/node_modules/@babel/runtime/helpers/esm/extends.js +1ms
vite:resolve 25.99ms @emotion/cache -> C:/code/_labs/vite-default/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js +638ms
vite:resolve 553.07ms @mui/base/BadgeUnstyled -> C:/code/_labs/vite-default/node_modules/@mui/base/BadgeUnstyled/index.js +556ms
vite:resolve 553.73ms @mui/base/SliderUnstyled -> C:/code/_labs/vite-default/node_modules/@mui/base/SliderUnstyled/index.js +1ms
vite:resolve 553.83ms @mui/base/composeClasses -> C:/code/_labs/vite-default/node_modules/@mui/base/composeClasses/index.js +1ms
vite:resolve 48.05ms @emotion/is-prop-valid -> C:/code/_labs/vite-default/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.browser.esm.js
+50ms
vite:resolve 27.83ms @emotion/weak-memoize -> C:/code/_labs/vite-default/node_modules/@emotion/weak-memoize/dist/weak-memoize.browser.esm.js +491ms
vite:resolve 17.80ms @emotion/utils -> C:/code/_labs/vite-default/node_modules/@emotion/utils/dist/emotion-utils.browser.esm.js +334ms
vite:resolve 16.58ms @emotion/serialize -> C:/code/_labs/vite-default/node_modules/@emotion/serialize/dist/emotion-serialize.browser.esm.js +171ms
vite:resolve 17.06ms @emotion/sheet -> C:/code/_labs/vite-default/node_modules/@emotion/sheet/dist/emotion-sheet.browser.esm.js +0ms
vite:resolve 107.55ms dom-helpers/addClass -> C:/code/_labs/vite-default/node_modules/dom-helpers/esm/addClass.js +109ms
vite:resolve 42.02ms stylis -> C:/code/_labs/vite-default/node_modules/stylis/index.js +44ms
vite:resolve 42.49ms @emotion/memoize -> C:/code/_labs/vite-default/node_modules/@emotion/memoize/dist/emotion-memoize.browser.esm.js +1ms
vite:resolve 42.84ms @emotion/hash -> C:/code/_labs/vite-default/node_modules/@emotion/hash/dist/hash.browser.esm.js +0ms
vite:resolve 73.63ms dom-helpers/removeClass -> C:/code/_labs/vite-default/node_modules/dom-helpers/esm/removeClass.js +75ms
vite:resolve 19.93ms @emotion/unitless -> C:/code/_labs/vite-default/node_modules/@emotion/unitless/dist/unitless.browser.esm.js +22ms
vite:deps deps bundled in 44638.17ms +0ms
vite v2.7.1 dev server running at:
> Local: http://localhost:3000/
> Network: use `--host` to expose
ready in 45672ms.
### Validations
- [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitejs.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitejs/vite/issues) that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite/discussions) or join our [Discord Chat Server](https://chat.vitejs.dev/).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 14
- Comments: 30 (15 by maintainers)
@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! 🎅
@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.
I tested it and basically determined that it was a bug introduced by 2.7.0-beta.5
test command
profile
vite-profile.zip
I’m basically sure it’s a performance issue with https://github.com/vitejs/vite/pull/5665 , the following is a performance comparison before and after including this pr
pull vite-profile.zip
#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.
@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) 2.7.1: 46, 47, 46, 47, 48 PR: 36, 38, 38, 36, 32 PR-SYM: 31, 26, 26, 27, 28 (preserveSymlinks = true)
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-PR1-profile.zip
Also donated, love your work @aleclarson
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 🍻
You can try using
--profile
flag, which writes to./vite-profile.cpuprofile
once the dev server is ready. Then you can open that up in Chrome devtools to figure out where in Vite the slowdown appeared.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.
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
profile.zip
FYI the output result with my repository was as below.