question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite 2.7.x is about 1.9 to 6.2 times slower than 2.6.14

See original GitHub issue

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:

  1. npm i
  2. 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.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:14
  • Comments:27 (14 by maintainers)

github_iconTop GitHub Comments

18reactions
Lanicommented, Dec 23, 2021

@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! 🎅

8reactions
rxliulicommented, Mar 17, 2022

@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
  • 2.7.0-beta.4: 9441ms
  • 2.7.0-beta.5: 18540ms

profile

vite-profile.zip

Even before the bug was introduced, the performance doesn’t seem to be very good (9s+), is it possible to keep doing some optimizations to keep the fast performance of vite development?


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 before: 8858ms
  • pull after: 29174ms

pull vite-profile.zip

Read more comments on GitHub >

github_iconTop Results From Across the Web

Evan You on Twitter: "I'm of course biased - but curious to hear ...
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...
Read more >
Vite 3.0 is out!
Vite 3.0 is out! #. In February last year, Evan You released Vite 2. Since then, its adoption has grown non-stop, reaching more...
Read more >
Coulomb, Riesz and log-gases
a constant times the left-hand side in (2.3.20), and the result then follows from Lemma 2.3.4 integrated against. ¯. Pelec,x and then ......
Read more >
The Confessions of Saint Augustine: Book 1
1.9.15 commentary on 1.9.15. estne quisquam, domine, tam magnus animus, ... simple valeur copulative' more than 100 times, in Bk. 1 more than...
Read more >
Deep Space Telecommunications Systems ... - Amazon AWS
from earth, tens of thousands of times farther than the most ... of the antenna, the 2.7 K cosmic background, and that portion...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found