Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Progress bar noticeably slows down npm install #11283
Comments
GavinJoyce
commented
Jan 26, 2016
|
I found the original report here whilst researching how I could make |
GavinJoyce
commented
Jan 26, 2016
|
It seems to yield a significant speed up for most people, all my colleagues in @intercom are seeing a significant boost. So far @kittens is the only one who hasn't reported a big difference: https://twitter.com/sebmck/status/691911481114415104 I tried
|
|
Looks like there's something in the works that might help: iarna/gauge#7 (comment) |
ghengeveld
commented
Jan 26, 2016
|
Same here. I'm running local-npm so I can rule out any network related issues:
That's a 41% increase in total time. |
vysinsky
commented
Jan 26, 2016
|
Same here
Computer specs:
|
Reinmar
commented
Jan 26, 2016
|
Minor difference in my case: https://gist.github.com/Reinmar/f69303b79157f2ca5764 (npm 3.5.2, MacOS) and here. Maybe it's OS specific? |
AgronKabashi
commented
Jan 26, 2016
|
Keep in mind that this is most likely also affected by the user's machine specs. The diff might be notably higher on lower end computers. |
GavinJoyce
commented
Jan 26, 2016
I'm running OSX 10.11.2 / MacBook Pro 2015 |
dashdanw
commented
Jan 26, 2016
|
@AgronKabashi i'm sure the slowdown would still be rationally similar. Seems like regardless of how slow the system is, most are experiencing something around a 2x slowdown. |
timdorr
commented
Jan 26, 2016
|
What terminal app do you use and what font do you have selected? Also, do you have anti-aliasing enabled in your terminal? The system might be using a fallback font for rendering the progress bar, since most "nice" programming fonts don't have line glyphs that the progress bar uses. That could be slowing things down. Also, AA or other fancy graphical things (transparent windows) can slow down draw commands. I'd make sure your terminal is up to date or try a nightly build if it's iTerm. |
GavinJoyce
commented
Jan 26, 2016
timdorr
commented
Jan 26, 2016
|
I'd be curious to see a performance measurement with non-ascii anti-aliasing disabled. I suspect this is slow draw performance. |
flying-sheep
commented
Jan 26, 2016
timdorr
commented
Jan 26, 2016
|
Here's my diff: progress=false
progress=true
I'm running Inconsolata-dz for Powerline with regular anti-aliasing and non-ascii anti-aliasing disabled. To maintain parity, here are the tests with Monaco 12pt with AA on for all fonts and a transparent window: progress=false
progress=true
Some difference, but not huge. I wonder if someone can run it with |
lipis
commented
Jan 26, 2016
|
Regardless of progress bar.. |
uhoh-itsmaciek
commented
Jan 26, 2016
|
For what it's worth, I seem to be affected by this as well: progress=false$ time npm install
...
real 1m30.147s
user 1m2.716s
sys 0m5.052s$ time npm install
...
real 1m17.472s
user 0m58.336s
sys 0m4.484s$ time npm install
...
real 1m20.335s
user 1m1.436s
sys 0m4.976sprogress=true$ time npm install
...
real 2m35.531s
user 2m11.340s
sys 0m5.628s$ time npm install
...
real 2m23.303s
user 2m4.780s
sys 0m5.396s$ time npm install
...
real 2m21.438s
user 2m2.048s
sys 0m4.880sI'm on Ubuntu 15.04, GNOME Terminal 3.14.2, with the default font. |
|
npm appears to be working on it in iarna/gauge#7 |
gcoguiec
commented
Jan 26, 2016
|
If my modest benchmarks can help in some way:
I'm using iTerm 2.1.4 with Droid Sans Mono font. |
samccone
commented
Jan 26, 2016
TL;DRInstalling without the progress bar on npm causes a 20% speedup to overall install time. The slowdown is due to a hot method call that if throttled, would prevent the majority of the slowdown. Over the past few days or so, there have been some interesting comments on twitter around npm’s progress bar and the performance cost of having it enabled. Instead of just blindly throwing conclusions only based on running On a cold run with a prewarmed .npm cache folder from an earlier install, I am seeing a 20% increase in the install time .. from npm i to process exit. With ProgressWithout ProgressStepping down into the bottom up view of the cpu profiler in chrome devtools right away we can verify exactly what is eating up that 20% With tracker on:With tracker off:Hmm so when the progress bar is enabled it looks like 23~% of the program time is being spent in a method called Taking a look in Cachegrind via https://github.com/jlfwong/chrome2calltree allows us to even further visulize the sheer cost of the progress bar during runtime ^ That big red blob is time spent inside of the loggingSo there seems to be 3 players in progress bar game here: Gauge https://github.com/iarna/gauge/blob/master/progress-bar.js The question is what is causing so much time to be spent in the log methods. So then let’s look at Alright, so it looks like we are totally skipping it if progress has been disabled.. So let’s take one more step into the gauge show code: Well this seems to be the issue and the reason for the massive slowdown, although there is some throttling happening inside of the ProgressBar code, we are still calling into it a lot and doing quite a bit of work before we eager exit. By simplifying the logic in the method, removing the inline method definition (which is probably causing v8 to do some extra work due to scope variable binding) and upstreaming the throttling responsibility, I believe that the cost of showing the progress bar can be significantly cut down. |
SomeKittens
commented
Jan 26, 2016
|
Jumping into this conversation, (I'm "SomeKittens", not just "Kittens"). I tried a few different packages and got different results (though I was able to repro the timings with |
|
Just a quick note to say that the CLI team is aware of this issue, and after @samccone's in-depth analysis (for which: thank you very much), much further contribution to the thread is likely to just be piling on. |
othiym23
added
bug
performance
labels
Jan 26, 2016
Morantron
commented
Jan 26, 2016
|
Nice profiling tools! Noting them down |
reimertz
commented
Jan 26, 2016
|
@samccone That is some legit detective work. I |
rauchg
commented
Jan 26, 2016
|
Awesome analysis as usual @samccone. Thank you |
|
TBH I'm a bit embarrassed that I didn't push out a quick gauge patch earlier. I've been aware of this as an issue for a while and the fix was literally 10 minutes or so of effort, but it hadn't bubbled up in priority as I hadn't realized how big an impact it was having. I'd been waiting as it's addressed by the improved architecture of the rewrite (prints at a set interval, no debounce needed), but clearly it was worth doing sooner than later. |
rauchg
commented
Jan 27, 2016
|
@iarna no need to be embarrassed. This only surfaced due to its immense popularity |
added a commit
to twbs/bootstrap
that referenced
this issue
Jan 27, 2016
This was referenced Jan 27, 2016
added a commit
to jamesramsay/hercule
that referenced
this issue
Jan 27, 2016
jamesramsay
referenced this issue
in jamesramsay/hercule
Jan 27, 2016
Merged
Build: disable npm progress bar for increased performance #175
|
I read codes and a forEach loop may be called every EE.on.('change', func): |
techmaurice
commented
Jan 27, 2016
|
Thanks, @samccone ! |
added a commit
to MarkusTeufelberger/rippled
that referenced
this issue
Jan 27, 2016
added a commit
to craigmichaelmartin/backbone
that referenced
this issue
Jan 27, 2016
This was referenced Jan 27, 2016
jrudolph
commented
Jan 27, 2016
|
FWIW I created an interactive flame graph (built using the instructions from here): Clicking on the the link will open an SVG that allows to drill down into more information. The big bars are UPDATED: removed the inline svg |
added a commit
to STRML/npmlog
that referenced
this issue
Jan 27, 2016
STRML
referenced this issue
in npm/npmlog
Jan 27, 2016
Closed
Add throttling option to enableProgress(). #27
|
I've opened three PRs based on profiling I've done motivated by this ticket.
These three updates have gotten an We can do further easy optimization by moving to EventEmitter3 for most (maybe all) uses of EventEmitter, as the built-in Node emitter actually causes deopt quite often. Other optimization possibilities are possible inside |
samccone
commented
Jan 27, 2016
|
impressive work @STRML |
|
Got another PR to are-we-there-yet: This gets our CPU usage down another 100x compared to the last patch. Performance on this patch is a little crazy - without throttling on So that's 61113ms -> 64ms! |
jadbox
commented
Jan 27, 2016
|
@STRML 100x is pretty impressive. What was the core issue here? Was it really the inline functions + Perhaps try turning the closure into a function definition instead instead of resorting to raw |
|
@jadbox Would much rather just use a The bulk of the gain appears to be from removing the |
samccone
commented
Jan 27, 2016
|
cc @indutny for some v8 depot insights ^ |
indutny
commented
Jan 27, 2016
|
@samccone TL;DR ? Has anyone actually run code with |
Sinewyk
commented
Jan 27, 2016
|
@jrudolph I suspect that your SVG inlined is making our browsers work a lot for nothing much, most of us who actually want to see something will click on it ... so you should probably remove the inlining and just put a link to it to relieve our browsers. Or just take a screenshot and you can inline this. |
|
@indutny I'm incorrect on that, the Chrome profiler doesn't report GC time as function's Re: tracing deopt, I've run most of the relevant code; aside from a small deopt in EventEmitter#emit I haven't seen anything else of consequence. |
tracker1
commented
Jan 27, 2016
|
@STRML What's the memory footprint look like for a large-ish npm install? Just curious, on a project last year, I found that forcing GC every N cycles through a stream kept the memory footprint pretty low, which helped in our test deploy with was a resource constrained system. |
Not sure about that. Might be true for |
added a commit
to mpc-hc/mpc-hc.org
that referenced
this issue
Jan 28, 2016
This was referenced Jan 29, 2016
added a commit
to jridgewell/amphtml
that referenced
this issue
Feb 2, 2016
added a commit
to alt-code/CrashMonkey
that referenced
this issue
Feb 2, 2016
added a commit
to cramforce/amphtml
that referenced
this issue
Feb 4, 2016
added a commit
to tamird/cockroach
that referenced
this issue
Feb 8, 2016
added a commit
to tamird/cockroach
that referenced
this issue
Feb 8, 2016
added a commit
to tamird/cockroach
that referenced
this issue
Feb 8, 2016
added a commit
to mpc-hc/mpc-hc.org
that referenced
this issue
Feb 19, 2016
added a commit
to mpc-hc/mpc-hc.org
that referenced
this issue
Feb 19, 2016
added a commit
to mpc-hc/mpc-hc.org
that referenced
this issue
Feb 19, 2016
pushed a commit
to amazeui/amazeui
that referenced
this issue
Feb 25, 2016
Krinkle
commented
Feb 29, 2016
|
I've got However, confirmed that setting |
added a commit
to umi-uyura/dotfiles
that referenced
this issue
Mar 2, 2016
added a commit
to Automattic/wp-calypso
that referenced
this issue
Mar 4, 2016
added a commit
to Automattic/wp-calypso
that referenced
this issue
Mar 4, 2016
added a commit
to unikent/kent-bar
that referenced
this issue
Mar 8, 2016
This was referenced Mar 12, 2016
added a commit
to abr4xas/vagrant-config
that referenced
this issue
Apr 16, 2016
added a commit
to abr4xas/vagrant-config
that referenced
this issue
Apr 16, 2016
added a commit
to kreisys/docker-images
that referenced
this issue
Apr 21, 2016
Webysther
commented
May 3, 2016
|
My stats with node v5.10.1 npm set progress=false && rm -rf ~/.npm && rm -rf node_modules && time npm install
real 3m33.941s
user 1m40.416s
sys 0m20.864s
npm set progress=true && rm -rf ~/.npm && rm -rf node_modules && time npm install
real 3m40.210s
user 1m23.640s
sys 0m13.956s
npm set progress=false && rm -rf node_modules && time npm install
real 2m10.048s
user 1m15.416s
sys 0m12.492s
npm set progress=true && rm -rf node_modules && time npm install
real 2m25.098s
user 1m23.788s
sys 0m14.460s
npm set progress=false && time npm rebuild
real 0m11.728s
user 0m11.140s
sys 0m1.340s
npm set progress=true && time npm rebuild
real 0m12.364s
user 0m11.732s
sys 0m1.244s |
edmorley
referenced this issue
in heroku/heroku-buildpack-nodejs
May 6, 2016
Closed
Set `NPM_CONFIG_PROGRESS=false` to speed up npm install #312
referenced
this issue
in jhipster/generator-jhipster
May 9, 2016
JaKXz
referenced this issue
in istanbuljs/nyc
May 10, 2016
Merged
Test against more relevant versions of node on Travis #251
brandonweiss
commented
May 12, 2016
|
Is this still an issue? |
Webysther
commented
May 12, 2016
|
apparently all ok |
BookOfGreg
commented
May 13, 2016
•
|
Node v5.10.1
There still is a difference, and it's slower for progress=false but faster for progress=true than it was on Node 4.1.1, It's down to about 6% difference between progress for me on the same deps as my previous comment on Node 4.1.1 |
Sinewyk
commented
May 13, 2016
|
As long as it's ~5% that's ok IMO. Start of issue was ~40-50% performance degradation. You can't expect additional work (tracking of progress) to have 0 impact on performance, so the slight degradation is expected. consider this fixed and close it ? |
nolanlawson
referenced this issue
in pouchdb/pouchdb
May 21, 2016
Merged
(#5191) - disable npm progress bar in Travis #5191
ahmadawais
commented
Jun 8, 2016
|
@BookOfGreg @Webysther The latest stable version of node is |
|
@Sinewyk I'm landing a rewrite of the progress bar this week that will likely eliminate even that 5%, so my plan was to close this when that lands. |
ahmadawais
commented
Jun 13, 2016
|
@iarna That rewrite will be part of which NPM version? |
This was referenced Jun 16, 2016
added a commit
to kasperg/ding2
that referenced
this issue
Jul 7, 2016
added a commit
to kasperg/ding2
that referenced
this issue
Jul 7, 2016
added a commit
to kasperg/ding2
that referenced
this issue
Jul 7, 2016
kevinSuttle
commented
Jul 8, 2016
|
Is it possible to set |
jffry
commented
Jul 8, 2016
|
@kevinSuttle You can put |
added a commit
to meteor/meteor
that referenced
this issue
Jul 15, 2016
added a commit
to meteor/meteor
that referenced
this issue
Jul 15, 2016
This was referenced Jul 21, 2016
|
I'm closing this because we landed the updated gauge ages in v3.10.0, way back in June, and there shouldn't be any more progress bar related slow downs. (It prints at a fixed interval now, so printing it shouldn't be adding a measurable amount of work.) |















zakjan commentedJan 26, 2016
Compare these runtimes of
npm install:Npm 3.5.2. Both commands were run with already warmed-up cache. Progress bar may be responsible for up to 50% slow down.
Original source: https://twitter.com/gavinjoyce/status/691783314261331969 by @GavinJoyce