Yarn: "yarn pack" is slow compared to "npm pack"

Created on 16 Oct 2016  Â·  7Comments  Â·  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?
Bug

What is the current behavior?
Running yarn pack on Yarn itself takes around 200 seconds on my machine. On the other hand, npm pack runs within a few seconds.

If the current behavior is a bug, please provide the steps to reproduce.

git clone https://github.com/yarnpkg/yarn.git
cd yarn
npm install
npm run build
yarn pack

What is the expected behavior?
It should be at least as fast as npm

Please mention your node.js, yarn and operating system version.
Node.js v6.7.0
Windows 10 64-bit
Latest master of Yarn as of a few minutes ago

cat-bug

All 7 comments

Isn't there npm install missing before npm run build?

Yeah, sorry, I messed up the repro steps. Fixed it now 😄

It's slow on macOS Sierra as well, you can change the title:

$ time yarn pack
yarn pack v0.15.1
success Wrote tarball to "/Users/mgol/_/yarn-test/yarn/yarn-v0.15.1.tgz".
✨  Done in 91.34s.
yarn pack  89.95s user 1.09s system 99% cpu 1:31.63 total
$ time npm pack                      
yarn-0.15.1.tgz
npm pack  0.79s user 0.14s system 116% cpu 0.807 total

Thanks for the confirmation. I don't have a Mac so I couldn't test that myself.

I just dig into the code, and see each of this loop will takes 10ms, if you have 30000 files, it will takes 300s(which is 5min, wow)

https://github.com/yarnpkg/yarn/blob/master/src/util/filter.js#L28

The regex test is very slow, I just create a test script in gist
https://gist.github.com/kebot/fd756cbe1212d6f955bbbf13db6680d7

It's also yarn includes unnecessary files in pack files. This can result in unnecessarily huge packages uploaded to npm registry.

Was this page helpful?
0 / 5 - 0 ratings