Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yarn 5x slower on windows

When I add a new package to an existing installation where yarn install has already been run, it takes 5 minutes to add a new dependency, which is as slow as if I just did yarn install without node_modules there yet.

Is this normal?

I'm using Yarn 0.17.9 on Windows 10 x64. I did make Windows Defender ignore my project directory and yarn global cache directories.

EDIT: here are some benchmark results I did. Based on them, it seems that yarn add is actually 30-40% faster, and the real issue is rather just that yarn is 500% slower on Windows

EDIT 2: I have confirmed that indexing hasn't been enabled for the project and yarn cache directories. But now I have upgraded yarn from 0.16.1 to 0.17.9 and there was a 35-50% increase in speed in Windows! But it's still 350-400% slower than in Linux. I have updated the benchmarks.

There seems to be Github issue for the Windows performance issues: https://github.com/yarnpkg/yarn/issues/990

The benchmark:

--

Windows - yarn install (cached):

Done in 172.29s. 

Ubuntu - yarn install (cache):

yarn install  48,75s user 11,32s system 117% cpu 51,161 total 

--

Windows - yarn add lodash:

Done in 143.11s. 

Ubuntu - yarn add lodash:

yarn add lodash  33,42s user 5,72s system 108% cpu 36,203 total 

--

FYI the Ubuntu benchmarks were run on the same folder on the NTFS drive.

Project that was used for the benchmarks: https://github.com/amcsi/szeremi

like image 804
Attila Szeremi Avatar asked Nov 12 '16 18:11

Attila Szeremi


2 Answers

Disabling windows search indexing on your work folder and yarn cache folder as well as disabling windows defender completely or on a folder should give you significant performance boost. I've got 30-50% decrease on similar system with SSD drive, originally timings were as yours.

Disabling it on Yarn cache folder would also give you some speedup. Its location is shown by yarn cache dir command, %USERPROFILE%\Local Settings\Yarn\cache by default.

To disable search indexing on a folder, find it in Explorer, right click, then Properties - General - Advanced, uncheck the "Allow files in this folder to have contents indexed in addition to file properties" checkbox, then Apply the changes.

This performance issue already exists on yarn github (Oct'2016) and is still open to the moment: https://github.com/yarnpkg/yarn/issues/990

like image 176
Alexey Avatar answered Oct 11 '22 17:10

Alexey


My experience...

Doing a yarn start is excruciatingly slow.

My setup. I am running WSL2 Ubuntu 20 on windows 10 home. I have my WSL src directory a sym link to windows c:\Users\chai (as opposed to whatever filesystem WSL has me in ie. the native WSL filesystem). ie.

Filesystem      Size  Used Avail Use% Mounted on C:\             476G  395G   82G  83% /mnt/c 

I am running the yarn which is installed via WSL2 Ubuntu (ie. so it is the linux version, not the windows version of yarn). V v slow.

I experimented and copied the same src files into a non-symlinked directory. ie. under ~/tmp which is a WSL filesystem and not under the windows filesystem.

Filesystem      Size  Used Avail Use% Mounted on /dev/sdb        251G   11G  228G   5% / 

And the speed now is as per expected... ie. normal (or relative to previous behaviour, blindingly fast).

So I am now using the latter setup for my react projects.

like image 33
Chai Ang Avatar answered Oct 11 '22 17:10

Chai Ang