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 is slow on large codebases on windows

See original GitHub issue

Describe the bug

While using Vite for bundling large codebase (around 700 files served) on Windows machine (reproducible both on windows 10 and 11 beta) Vite page load time takes around 5-30 seconds depending on drive type (NVME on-board SSD, NVME SSD, SATA SSD), comparing to <2 seconds on Mac (did not try on linux).

Core reason is tryFsResolve function image

Which is using accessSync call, which is internally using multiple sync FS calls, and NTFS (specifically NTFS, looks like FAT is working better) is rather complex system with multiple checks that can take milliseconds; also this is causing the server act in sync mode (instead of async) and not utilize the benefits of parallel http requests.

Another reason is rather slow HTTP service which takes several seconds overhead; I was able to win few seconds with page with this script (https://gist.github.com/Jabher/c9e5f9bb905c8ec2ab6289a181c2b6ce). Probably switching from express to fastify or native code will make things work faster.

Reproduction

issue seems obvious as long as performance result like was provided and specific code part was targeted as a reason of bug

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 4.26 GB / 15.92 GB
  Binaries:
    Node: 16.4.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.20.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (92.0.902.73)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    vite: ^2.5.0 => 2.5.0

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:12
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Yesterday17commented, Sep 27, 2022

This problem also exists if you’re using a mounted remote file system. Since the speed of existSync(and other sync methods) is slow(due to latency), resolver was blocked, causing other (incoming) requests to wait for the previous (ongoing) resolve process to finish. The server degraded from (async) parallel processing to serial processing.

The problem can be reproduced if you mount a NFS/CIFS partition from a remote server and run a project on that with Vite.

0reactions
mreduarcommented, Dec 6, 2022

Finally I think I found the right issue. I have a similar problem, maybe it is the same, maybe not. The truth is that my development compile now takes about 30 minutes to compile, this is something that only happens to me in the team, the rest of my colleagues compile in 2 seconds having the same code base, only they are in Linux with Docker and I am in Windows without docker (I am not using WSL2), and no, it is not because of computer resources, and if it were I do not think the difference would be so brutal. We are working on a somewhat medium-sized project, about 400 components and counting.

We are using Tailwind, and I have read that it can cause slow startup, but why only me if we have the same configuration?

This is how long it takes me. image (2)

This is how long it takes my teammates. image

Does anyone have any suggestions, or at least where to start?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page reload on dev server is very slow in large codebase #7608
Describe the bug. In issue #3208. You've asked to code example, so I've created one: https://github.com/michalzubkowicz/slow-vite-demo.
Read more >
Webpack to Vite: Improving Speed and Performance
As our web app became larger and larger and we had many files in the codebase, it made HMR so slow it would...
Read more >
Vite: Rethinking Frontend Tooling by Evan You - GitNation
Vite is a new build tool that intends to provide a leaner, faster, and more friction-less workflow for building modern web apps.
Read more >
11 Great Tools for a Monorepo in 2021 | Bits and Pieces
Best tools to build a monorepo. Develop, build, and publish packages, and scale development. Discover Lerna, Nx, Rush, Bit, Yarn Workspaces, and more....
Read more >
A deep-dive on Vite featuring Evan You (JS Party #212)
So - slow build times, right? Can you kind of like walk folks through what was maybe some of the source of that...
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