Code Monkey home page Code Monkey logo

benchmarks-of-javascript-package-managers's Introduction

简体中文 | 日本語 | 한국어 | Italiano | Português Brasileiro

Fast, disk space efficient package manager:

  • Fast. Up to 2x faster than the alternatives (see benchmark).
  • Efficient. Files inside node_modules are linked from a single content-addressable storage.
  • Great for monorepos.
  • Strict. A package can access only dependencies that are specified in its package.json.
  • Deterministic. Has a lockfile called pnpm-lock.yaml.
  • Works as a Node.js version manager. See pnpm env use.
  • Works everywhere. Supports Windows, Linux, and macOS.
  • Battle-tested. Used in production by teams of all sizes since 2016.
  • See the full feature comparison with npm and Yarn.

To quote the Rush team:

Microsoft uses pnpm in Rush repos with hundreds of projects and hundreds of PRs per day, and we’ve found it to be very fast and reliable.

npm version Join the chat at Discord OpenCollective OpenCollective Twitter Follow Stand With Ukraine

Platinum Sponsors

Gold Sponsors

Silver Sponsors

Support this project by becoming a sponsor.

Background

pnpm uses a content-addressable filesystem to store all files from all module directories on a disk. When using npm, if you have 100 projects using lodash, you will have 100 copies of lodash on disk. With pnpm, lodash will be stored in a content-addressable storage, so:

  1. If you depend on different versions of lodash, only the files that differ are added to the store. If lodash has 100 files, and a new version has a change only in one of those files, pnpm update will only add 1 new file to the storage.
  2. All the files are saved in a single place on the disk. When packages are installed, their files are linked from that single place consuming no additional disk space. Linking is performed using either hard-links or reflinks (copy-on-write).

As a result, you save gigabytes of space on your disk and you have a lot faster installations! If you'd like more details about the unique node_modules structure that pnpm creates and why it works fine with the Node.js ecosystem, read this small article: Flat node_modules is not the only way.

💖 Like this project? Let people know with a tweet

Getting Started

Benchmark

pnpm is up to 2x faster than npm and Yarn classic. See all benchmarks here.

Benchmarks on an app with lots of dependencies:

Usage Trend

Usage Trend of pnpm

image

Backers

Thank you to all our backers! Become a backer

Contributors

This project exists thanks to all the people who contribute. Contribute.

License

MIT

benchmarks-of-javascript-package-managers's People

Contributors

brycekahle avatar kishan08 avatar mungojam avatar nikoladev avatar nogrtl avatar zkat avatar zkochan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

benchmarks-of-javascript-package-managers's Issues

Replace Yarn PnP w/ Yarn 2

Since Yarn 2 has PnP enabled (with a better implementation as Yarn 1), I think it would make more sense to use that.

To use Yarn 2, the following command has to be run within the project outside of the benchmark:

yarn policies set-version berry

Some other particularities:

  • to remove the cache, better use yarn cache clean --all. You also can add enableGlobalCache which will use a unique cache (otherwise it'll have a first global cache, then a per-project cache).

  • when removing the n_m, you'll instead want to remove the .pnp.js file for PnP (I think it's currently marked as n/a)

not complete install with material-components-web

its a grate package manager "pnpm" .
thanks for making this thing .

now , i have noticed some issue with pnpm last day
the issue is,
when i am trying to install material-components-web with pnpm its installing the main package not
@material/** dir
but when install with npm its doing the complete install
though i got a work aroung is to copy the @material dir to node modules.

but i though it need to be noticed by u guys .

thanks again..
lots of love

Not working on windows

Throws error while on Windows 10

Nogr@Gaming-Fury MINGW64 /c/Projects/Development/Nodejs/benchmark-package-managers (feat/windows-compability-fix)
$ npm run prebenchmark

> [email protected] prebenchmark C:\Projects\Development\Nodejs\benchmark-package-managers
> rimraf .tmp


Nogr@Gaming-Fury MINGW64 /c/Projects/Development/Nodejs/benchmark-package-managers (feat/windows-compability-fix)
$ npm run benchmark

> [email protected] prebenchmark C:\Projects\Development\Nodejs\benchmark-package-managers
> rimraf .tmp


> [email protected] benchmark C:\Projects\Development\Nodejs\benchmark-package-managers
> node index

# first install
> npm install --ignore-scripts --cache cache --registry https://registry.npmjs.org/
Error: npm failed with status code null
    at measureInstall (C:\Projects\Development\Nodejs\benchmark-package-managers\lib\benchmarkFixture.js:163:11)
    at benchmark (C:\Projects\Development\Nodejs\benchmark-package-managers\lib\benchmarkFixture.js:64:24)
    at async module.exports (C:\Projects\Development\Nodejs\benchmark-package-managers\lib\recordBenchmark.js:20:22)
    at async run (C:\Projects\Development\Nodejs\benchmark-package-managers\index.js:109:28)

Add time taken to add a new module (eg. npm install XXX)

It would be nice if the benchmark also tracked how long it took to install (ie. add) modules, after the project has already been fully installed/initialized.

This is an important consideration, since it's the most common dependency-related operation that is performed (at least in my projects).

It's also significant because npm is actually faster than yarn for adding new modules -- at least for my project, with a package-lock present for both:

These commands were done in order, in the "mobx-devtools-advanced" repo, on 2019-11-13.

NPM version: 6.11.2
Yarn version: 1.19.1

* npm install [email protected]: 62s (slow since had to clear yarn metadata + rebuild it)
* npm install [email protected]: 5s
* npm install [email protected]: 5s
* npm install [email protected]: 5s
* yarn add [email protected]: 48s (slow since had to clear npm metadata + rebuild it)
* yarn add [email protected]: 12s
* yarn add [email protected]: 10s
* npm install lodash @2.0.0: 67s (slow again due to rebuild)
* npm install lodash @2.1.0: 5s
* npm install lodash @2.2.0: 5s

Note that the operation of just adding a new module took about half as long for npm than yarn.

That said, both are quite fast, so perhaps it's not so important after all.

Add size/disk usage benchmarks

According to the website, one of the major features is pnpm's minimal disk usage. If it is possible, could you add sizes of the folders (with du -sh or something) to the benchmark, so we could see for ourselves?

Add more test-cases

Hi. For some reason I don't like to use the Lockfile. I'd like to find out what's the difference in speed when I have cache and node_modules folder, but no Lockfile.

Yarn has such test at https://yarnpkg.com/lang/en/compare/ but it's outdated.

Missing test-cases:
✔ Warm Cache ✔ node_modules ✗ Lockfile/Shrinkwrap
✗ Warm Cache ✔ node_modules ✗ Lockfile/Shrinkwrap
✗ Warm Cache ✔ node_modules ✔ Lockfile/Shrinkwrap

Benchmark doesn't check native modules.

Your benchmark doesn't packages which require native compilation.
Try to depend on truffle, for example. it depends on quite a few native modules.
NPM compiles them one by one. Yarn opens multiple parallel processes to compile, and achieves great efficiency.

Moreover, since re-install often requires to compile such native modules again (I don't really know why, but both NPM and Yarn do it) , the above compilation times affect not only initial installs but also re-installs.

Benchmark Measurements

The tables are labeled runtime in ms, but the measurements are all given in seconds. This should be consistent.

Measure speed of updating dependencies

Another benchmark that would be good to have is to measure how the different package managers handle updated dependencies. Take for example the dependencies of the React app package.json:

{
  // ...other package.json stuff
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.1.1"
  },
  // ...other package.json stuff
}

After all the currently available benchmarks are done (clean install, etc...) the dependencies could be updated and the update speed could be measured:

{
  // ...other package.json stuff
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "^2.1.8" // <===== changed
  },
  // ...other package.json stuff
}

This way the package managers don't just install new packages, but some packages also have to be deleted and/or rearranged. For me, updating my packgage.json and node_modules is a far more common use case than starting a new project.

What do you think?

Benchmark npm ci

In npm v5.7.1 a new command was added - npm ci. Npm team claims it is faster (2x-10x) than npm install

The new npm ci command installs from your lock-file ONLY. If your package.json and your lock-file are out of sync then it will report an error.

It works by throwing away your node_modules and recreating it from scratch.

Beyond guaranteeing you that you'll only get what is in your lock-file it's also much faster (2x-10x!) than npm install when you don't start with a node_modules.

As you may take from the name, we expect it to be a big boon to continuous integration environments. We also expect that folks who do production deploys from git tags will see major gains.

Please add yarn with PnP turned on

It feels like it is a totally different mode that is meant to offer huge speed improvement so would be good to have as a separate category

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.