Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Start Times #176

Open
stephenplusplus opened this issue Jun 20, 2014 · 57 comments
Open

Slow Start Times #176

stephenplusplus opened this issue Jun 20, 2014 · 57 comments

Comments

@stephenplusplus
Copy link

The ever-haunting issue with yo is the slow discovery of installed generators. I recall us getting it in check in the past, but has anyone else noticed it creeping up again?

@sindresorhus
Copy link
Member

I'm on a superfast Mac with SSD and it takes ~1s to startup, which is pretty slow.

@sindresorhus
Copy link
Member

https://www.npmjs.org/package/time-require would be useful for debugging and profiling this.

@dickeylth
Copy link

dickeylth commented May 12, 2016

I used time-require & it shows:

Start time: (2016-05-12 08:11:21 UTC) [treshold=1%]

module time %

1 chalk (../../gener...s/chalk/index.js) 22ms ▇ 1%
2 lodash (../../gene.../lodash/index.js) 42ms ▇ 2%
3 mem-fs (../../gene.../mem-fs/index.js) 27ms ▇ 1%
4 lodash (../../gene...lodash/lodash.js) 36ms ▇ 2%
5 ./baseUI (../../ge...lib/ui/baseUI.js) 40ms ▇ 2%
6 ./ui/bottom-bar (....ui/bottom-bar.js) 43ms ▇ 2%
7 inquirer (../../ge.../lib/inquirer.js) 99ms ▇▇ 5%
8 ./adapter (../../g...t/lib/adapter.js) 116ms ▇▇▇ 5%
9 yeoman-environment...b/environment.js) 234ms ▇▇▇▇▇ 11%
10 underscore.string....string/index.js) 39ms ▇ 2%
11 read-pkg (../../ge...ead-pkg/index.js) 42ms ▇ 2%
12 read-pkg-up (../.....-pkg-up/index.js) 43ms ▇ 2%
13 ast-query (../../g...uery/lib/tree.js) 44ms ▇ 2%
14 gruntfile-editor (...-editor/index.js) 45ms ▇ 2%
15 mem-fs-editor (../...-editor/index.js) 43ms ▇ 2%
16 ./api/attributes (...pi/attributes.js) 23ms ▇ 1%
17 ./api/traversing (...pi/traversing.js) 24ms ▇ 1%
18 ./lib/cheerio (../...o/lib/cheerio.js) 63ms ▇▇ 3%
19 cheerio (../../gen...cheerio/index.js) 64ms ▇▇ 3%
20 html-wiring (../.....-wiring/index.js) 66ms ▇▇ 3%
21 ./utils (../../gen...tch/lib/utils.js) 28ms ▇ 1%
22 ./lib/expand (../....ch/lib/expand.js) 31ms ▇ 1%
23 micromatch (../../...romatch/index.js) 32ms ▇ 2%
24 glob-stream (../.....-stream/index.js) 66ms ▇▇ 3%
25 ./lib/src (../../g...lib/src/index.js) 89ms ▇▇ 4%
26 vinyl-fs (../../ge...inyl-fs/index.js) 103ms ▇▇ 5%
27 decompress-tar (.....ess-tar/index.js) 25ms ▇ 1%
28 decompress-tarbz2...-tarbz2/index.js) 29ms ▇ 1%
29 decompress-targz (...s-targz/index.js) 31ms ▇ 1%
30 decompress (../../...ompress/index.js) 211ms ▇▇▇▇ 10%
31 gulp-util (../../g...lp-util/index.js) 39ms ▇ 2%
32 gulp-decompress (....ompress/index.js) 253ms ▇▇▇▇▇ 12%
33 download (../../ge...ownload/index.js) 296ms ▇▇▇▇▇▇ 14%
34 ./actions/fetch (....actions/fetch.js) 296ms ▇▇▇▇▇▇ 14%
35 got (../../generat...les/got/index.js) 30ms ▇ 1%
36 gh-got (../../gene.../gh-got/index.js) 31ms ▇ 1%
37 github-username (....sername/index.js) 31ms ▇ 1%
38 ./actions/user (...../actions/user.js) 45ms ▇ 2%
39 ./base (../../gene...ator/lib/base.js) 637ms ▇▇▇▇▇▇▇▇▇▇▇▇ 30%
40 yeoman-generator (...tor/lib/index.js) 876ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 41%
41 npm-updater (../.....updater/index.js) 26ms ▇ 1%
42 ../_libs/logo (../...am/_libs/logo.js) 34ms ▇ 2%
yeoman-generator really become very slow than before.

@sindresorhus
Copy link
Member

@dickeylth I would recommend upgrading to Node.js 6. They improved the require performance considerably in that version ;)

@dickeylth
Copy link

@sindresorhus unfortunately my local node tools are still not ready for npm 3, and npm3 itself still has so many big-bug issues to be resolved, so right now upgrading to Node.js v6 is still not a possible choice.😞

@Tiberriver256
Copy link

Still pretty darn slow these days... npm 6, node v8

@Olian04
Copy link

Olian04 commented Jul 4, 2018

This issue is still very much relevant. I'm on Node v10.5.0, npm v6.1.0 and yo v2.0.3 and its taking up towards 10 minutes between calling yo foo and the first line of code being executed in foo.

@SBoudrias
Copy link
Member

@Olian04 this is really abnormal. When we were talking about this, it was about lowering the startup time from ~1-2 seconds to near instant. Not minutes 😱

I'd be happy to help you figure out what's wrong. Try running DEBUG=yeoman:* yo and see if you can see where the time is spent.

@Olian04
Copy link

Olian04 commented Jul 5, 2018

@SBoudrias welp, thats some difference.... :/
I'm not currently in the exact same environment (I've downgraded node to LTS) but it still takes ages to run.
Since I'm on windows 10 i assumed DEBUG=yeoman:* meant Set-Variable -Name "DEBUG" -Value "yeoman:*". With that being set, just running yo and nothing else took a bit over 3 min before i hit the option screen. Am I supposed to look for a log file in some dir now, or did I set the variable the wrong way?

> yo

? 'Allo





! What would you like to do? Get me out of here!

     _-----_     ╭───────────────────────╮
    |       |    │      Bye from us!     │
    |--(o)--|    │       Chat soon.      │
   `---------´   │      Yeoman team      │
    ( _´U`_ )    │    https://yeoman.io   │
    /___A___\   /╰───────────────────────╯
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

@SBoudrias
Copy link
Member

The Set-Variable probably didn't work. You should see a lot of internal yeoman logs being printed out. Try set DEBUG=yeoman:generator (https://yeoman.io/authoring/debugging.html)

@Olian04
Copy link

Olian04 commented Jul 6, 2018

@SBoudrias I tried running set DEBUG=yeoman:generator and then yo but it didn't print anything extra. Would it make a difference if yo is installed globally or locally?

@Tiberriver256
Copy link

@SBoudrias - I'm in the same boat as @Olian04 too. Might be a Windows 10 thing? I've got minutes before yo comes back with a list of generators. Same time if I specify a specific generator.

@Olian04 from PowerShell it's an Environment variable. Try using this:

$Env:DEBUG = "yeoman:*"

Here is my response. Most of the load time is before the yeoman guy shows up and then a good chunk before the logging starts too. After the log messages start showing up it's pretty quick.

PS C:\Users\wmrm> $ENV:DEBUG = "yeoman:*"
PS C:\Users\wmrm> yo

     _-----_
    |       |    ╭──────────────────────────────────────────╮
    |--(o)--|    │ Update available: 2.0.3 (current: 2.0.2) │
   `---------´   │     Run npm install -g yo to update.     │
    ( _´U`_ )    ╰──────────────────────────────────────────╯
    /___A___\   /
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

  yeoman:environment found C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-generator/app/index.js, trying to register +0ms
  yeoman:environment Resolve namespaces for C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-generator/app/index.js: generator:app +0ms
  yeoman:environment Registered generator:app (C:\Users\wmrm\AppData\Roaming\npm\node_modules\generator-generator\app\index.js) +3ms
  yeoman:environment found C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-generator/subgenerator/index.js, trying to register +12ms
  yeoman:environment Resolve namespaces for C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-generator/subgenerator/index.js: generator:subgenerator +4ms
  yeoman:environment Registered generator:subgenerator (C:\Users\wmrm\AppData\Roaming\npm\node_modules\generator-generator\subgenerator\index.js) +2ms
  yeoman:environment found C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-haworthapp/app/index.js, trying to register +7s
  yeoman:environment Resolve namespaces for C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-haworthapp/app/index.js: haworthapp:app +7s
  yeoman:environment Registered haworthapp:app (C:\my\Generator-HaworthApp\app\index.js) +2ms
  yeoman:environment found C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-typescript-generator/app/index.js, trying to register +3s
  yeoman:environment Resolve namespaces for C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-typescript-generator/app/index.js: typescript-generator:app +3s
  yeoman:environment Registered typescript-generator:app (C:\Users\wmrm\AppData\Roaming\npm\node_modules\generator-typescript-generator\app\index.js) +2ms
  yeoman:environment found C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-node-typescript/generators/app/index.js, trying to register +36ms
  yeoman:environment Resolve namespaces for C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-node-typescript/generators/app/index.js: node-typescript:app +34ms
  yeoman:environment Registered node-typescript:app (C:\Users\wmrm\AppData\Roaming\npm\node_modules\generator-node-typescript\generators\app\index.js) +2ms
  yeoman:environment found C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-node-typescript/generators/classlib/index.js, trying to register +11ms
  yeoman:environment Resolve namespaces for C:/Users/wmrm/AppData/Roaming/npm/node_modules/generator-node-typescript/generators/classlib/index.js: node-typescript:classlib +9ms
  yeoman:environment Registered node-typescript:classlib (C:\Users\wmrm\AppData\Roaming\npm\node_modules\generator-node-typescript\generators\classlib\index.js) +2ms
? 'Allo Micah! What would you like to do? (Use arrow keys)

@Tiberriver256
Copy link

Massive improvement upgrading to 2.0.3 but still I think slower than would be expected. Almost 2 minutes. here is my time-require:

Start time: (2018-07-07 03:37:03 UTC) [treshold=1%]
 #  module                                        time  %
 1  rxjs/Rx (..\..\Users\..._modules\rxjs\Rx.js)    1s  ■ 1%
 2  ./ui/prompt (..\..\Us...er\lib\ui\prompt.js)    1s  ■ 1%
 3  inquirer (..\..\Users...rer\lib\inquirer.js)  1.2s  ■ 1%
 4  insight (..\..\Users\...nsight\lib\index.js)  1.3s  ■ 1%
 5  rxjs/Rx (..\..\Users\..._modules\rxjs\Rx.js)  1.1s  ■ 1%
 6  ./ui/prompt (..\..\Us...er\lib\ui\prompt.js)  1.1s  ■ 1%
 7  inquirer (..\..\Users...rer\lib\inquirer.js)  1.2s  ■ 1%
 8  ./adapter (..\..\User...ment\lib\adapter.js)  1.3s  ■ 1%
 9  yeoman-environment (....\lib\environment.js)  2.3s  ■ 2%
10  ./router (..\..\Users...es\yo\lib\router.js)  2.3s  ■■ 2%
Total require(): 4724
Total time: 1m 40.9s

     _-----_     ╭───────────────────────╮
    |       |    │      Bye from us!     │
    |--(o)--|    │       Chat soon.      │
   `---------´   │      Yeoman team      │
    ( _´U`_ )    │    https://yeoman.io   │
    /___A___\   /╰───────────────────────╯
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

@SBoudrias
Copy link
Member

@Olian04 @Tiberriver256 maybe some inspiration on gulpjs/gulp#1578 - looks like some windows users were having SSD disk issues which impacted node require() performance. 2.3s second import time isn't usual - but there's not much we can do on our side to fix that.

Theoretically, as yo is a top level dependency, I guess we could do some amount of bundling. But to me it's really unclear how much improvement this would end up giving people in your situation:

  1. If we bundle only the yo core, then we remove ~10 imports maybe, potentially saving 10 seconds in your case? But that's not really gonna have a big impact as it'd still takes minutes.
  2. If we bundle everything, then fixes/updates to sub-dependencies aren't reflected unless we release new yo versions. For example, we regularly push updates to yeoman-environment to make sure our support of new npm and yarn version is kept up to date.

I'm open to suggestion.

@Olian04
Copy link

Olian04 commented Jul 7, 2018

@Tiberriver256 thanks for the advice I'll have a go with it once I get back to work on Monday.

@SBoudrias It might be worth mentioning that I've tried [email protected] & [email protected] both are as slow. However [email protected] is working as intended, so that's what I've been using previously.

@Olian04
Copy link

Olian04 commented Jul 9, 2018

@SBoudrias I tried what @Tiberriver256 suggested, and this time it worked.
However almost all of the time is spent before the first log message is printed.

PS C:\Users\xxqqvc\Projects\test> $Env:DEBUG = "yeoman:*"
PS C:\Users\xxqqvc\Projects\test> npx yo
npx: installed 1 in 2.19s
Path must be a string. Received undefined
C:\Users\xxqqvc\Projects\test\node_modules\yo\lib\cli.js
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-markstache/generators/app/index.js, trying to register +0ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-markstache/generators/app/index.js: markstache:app +0ms
  yeoman:environment Registered markstache:app (C:\Users\xxqqvc\Projects\generator-markstache\generators\app\index.js) +1ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/app/index.js, trying to register +30ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/app/index.js: microservice:app +24ms
  yeoman:environment Registered microservice:app (C:\Users\xxqqvc\Projects\generator-microservice\generators\app\index.js) +1ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/common-create/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/common-create/index.js: microservice:common-create +2ms
  yeoman:environment Registered microservice:common-create (C:\Users\xxqqvc\Projects\generator-microservice\generators\common-create\index.js) +0ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/common-update/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/common-update/index.js: microservice:common-update +1ms
  yeoman:environment Registered microservice:common-update (C:\Users\xxqqvc\Projects\generator-microservice\generators\common-update\index.js) +1ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/common-update-aurora/index.js, trying to register +3ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/common-update-aurora/index.js: microservice:common-update-aurora +2ms
  yeoman:environment Registered microservice:common-update-aurora (C:\Users\xxqqvc\Projects\generator-microservice\generators\common-update-aurora\index.js) +1ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/common-update-public/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/common-update-public/index.js: microservice:common-update-public +1ms
  yeoman:environment Registered microservice:common-update-public (C:\Users\xxqqvc\Projects\generator-microservice\generators\common-update-public\index.js) +2ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/core-create/index.js, trying to register +3ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/core-create/index.js: microservice:core-create +2ms
  yeoman:environment Registered microservice:core-create (C:\Users\xxqqvc\Projects\generator-microservice\generators\core-create\index.js) +1ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/core-update/index.js, trying to register +3ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/core-update/index.js: microservice:core-update +1ms
  yeoman:environment Registered microservice:core-update (C:\Users\xxqqvc\Projects\generator-microservice\generators\core-update\index.js) +1ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/java-create/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/java-create/index.js: microservice:java-create +2ms
  yeoman:environment Registered microservice:java-create (C:\Users\xxqqvc\Projects\generator-microservice\generators\java-create\index.js) +0ms
  yeoman:environment found C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/java-update/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/claxxqqvc/AppData/Roaming/npm/node_modules/generator-microservice/generators/java-update/index.js: microservice:java-update +2ms
  yeoman:environment Registered microservice:java-update (C:\Users\xxqqvc\Projects\generator-microservice\generators\java-update\index.js) +0ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-markstache/generators/app/index.js, trying to register +3ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-markstache/generators/app/index.js: markstache:app +3ms  yeoman:environment Registered markstache:app (C:\Users\xxqqvc\Projects\generator-markstache\generators\app\index.js) +0ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/app/index.js, trying to register +10ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/app/index.js: microservice:app +9ms
  yeoman:environment Registered microservice:app (C:\Users\xxqqvc\Projects\generator-microservice\generators\app\index.js) +0ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/common-create/index.js, trying to register +1ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/common-create/index.js: microservice:common-create +2ms
  yeoman:environment Registered microservice:common-create (C:\Users\xxqqvc\Projects\generator-microservice\generators\common-create\index.js) +0ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/common-update/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/common-update/index.js: microservice:common-update +2ms
  yeoman:environment Registered microservice:common-update (C:\Users\xxqqvc\Projects\generator-microservice\generators\common-update\index.js) +1ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/common-update-aurora/index.js, trying to register +3ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/common-update-aurora/index.js: microservice:common-update-aurora +1ms
  yeoman:environment Registered microservice:common-update-aurora (C:\Users\xxqqvc\Projects\generator-microservice\generators\common-update-aurora\index.js) +1ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/common-update-public/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/common-update-public/index.js: microservice:common-update-public +1ms
  yeoman:environment Registered microservice:common-update-public (C:\Users\xxqqvc\Projects\generator-microservice\generators\common-update-public\index.js) +1ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/core-create/index.js, trying to register +1ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/core-create/index.js: microservice:core-create +1ms
  yeoman:environment Registered microservice:core-create (C:\Users\xxqqvc\Projects\generator-microservice\generators\core-create\index.js) +0ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/core-update/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/core-update/index.js: microservice:core-update +1ms
  yeoman:environment Registered microservice:core-update (C:\Users\xxqqvc\Projects\generator-microservice\generators\core-update\index.js) +1ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/java-create/index.js, trying to register +1ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/java-create/index.js: microservice:java-create +1ms
  yeoman:environment Registered microservice:java-create (C:\Users\xxqqvc\Projects\generator-microservice\generators\java-create\index.js) +0ms
  yeoman:environment found C:/Users/xxqqvc/Projects/generator-microservice/generators/java-update/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/generator-microservice/generators/java-update/index.js: microservice:java-update +2ms
  yeoman:environment Registered microservice:java-update (C:\Users\xxqqvc\Projects\generator-microservice\generators\java-update\index.js) +0ms
  yeoman:environment found C:/Users/xxqqvc/Projects/test/node_modules/generator-git-migrator/generators/app/index.js, trying to register +2ms
  yeoman:environment Resolve namespaces for C:/Users/xxqqvc/Projects/test/node_modules/generator-git-migrator/generators/app/index.js: git-migrator:app +2ms
  yeoman:environment Registered git-migrator:app (C:\Users\xxqqvc\Projects\test\node_modules\generator-git-migrator\generators\app\index.js) +1ms
? 'Allo





! What would you like to do? Get me out of here!

     _-----_     ╭───────────────────────╮
    |       |    │      Bye from us!     │
    |--(o)--|    │       Chat soon.      │
   `---------´   │      Yeoman team      │
    ( _´U`_ )    │    https://yeoman.io   │
    /___A___\   /╰───────────────────────╯
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

PS C:\Users\xxqqvc\Projects\test>

@MarcoScabbiolo
Copy link
Contributor

Regarding how global-tunnel-ng might have affected the speed of yo, the package itself runs smoothly, 95 tests take less than 2 seconds to complete. If running yo behind a proxy any network request will take a little bit longer, how much will obviously depend on the network conditions.

I've tested the latest version of yo behind a corporate proxy running generator-node and also listing generators and it took less than 2 seconds for every operation using both environment variables and the npm configuration to set the proxy.

Are you doing anything in particular to cause these delays?

@Olian04
Copy link

Olian04 commented Jul 10, 2018

@MarcoScabbiolo not to my knowledge.
The proxy doesn't slow down any of my other tools.
Also, why would the proxy even factor in when it takes minutes between running yo and the first line being printed?

@MarcoScabbiolo
Copy link
Contributor

@Olian04 I've reproduced your environment (Win 10, Node LTS 8.11.3) and I have a 5-6 seconds delay. Using WSL (Ubuntu) the delay is 1-2 seconds.

All CLIs in Windows are very slow, PowerShell is not an exception. It is also usual for CLIs in Windows to get stuck while running any command, and you need to Ctrl + C to wake them up.

If you have any other information about your environment that could be causing the minutes delay please let me know and I'll try to reproduce the conditions.

@Tiberriver256
Copy link

5-6 seconds would be awesome. Both of us however are experiencing minutes.

@Olian04
Copy link

Olian04 commented Jul 10, 2018

@MarcoScabbiolo don't know if it makes any difference but I'm installing yo locally and running it via a globally installed npx

@Tiberriver256
Copy link

@MarcoScabbiolo
Copy link
Contributor

MarcoScabbiolo commented Jul 10, 2018

Ran yo with npx installing it locally and had the same delay, 5-6 seconds. Can you share your package.json file to see if the ammount of dependencies is having an impact on the time it takes to resolve all modules to see which of them are candidates for a generator?

@MarcoScabbiolo
Copy link
Contributor

MarcoScabbiolo commented Jul 10, 2018

By the way I'm running these on a pretty beafy PC, 18 GB of RAM and an i7-7700 with two SSDs , but I don't think this accounts for the huge difference in the delay.

@Olian04
Copy link

Olian04 commented Jul 11, 2018

@MarcoScabbiolo Just in case it matters; I'm on an i7-6820HQ with 16GB RAM and an ok SSD.

As suggested in #589 i tried using #590/[email protected] but its the same result. Slow start, but once the first log line is printed it runs smooth and quick.

@MarcoScabbiolo
Copy link
Contributor

@SBoudrias Looking at what @Tiberriver256 said it doesnt look like global-tunnel-ng is the reason for these delays.

If Im able to reproduce the issue ill try to debug it.

@wsrast
Copy link

wsrast commented Jul 16, 2018

I'll throw my hat in the ring here as well, coming from another issue I posted and redirected here by @SBoudrias .

I'm now experiencing this on two separate Windows machines. Things I've tried:

  1. Uninstalled NVM and all versions of Node it contained.
  2. Reinstalled Node LTS 8.11.3
  3. Used both private and public NPM registries.
  4. Installed Yeoman 2.0.4 with Yarn instead of NPM (this bypasses another issue I've created with any Yeoman version >2.0.2 on an NPM install behind a corporate proxy).
  5. Ran powershell command suggested by @Tiberriver256 . Delay was still in evidence (~3-5 minutes). Output was:
PS C:\Users\rastwe> $Env:DEBUG = "yeoman:*"
PS C:\Users\myuser> yo
? 'Allo rastwe! What would you like to do? Get me out of here!
Terminate batch job (Y/N)? y
PS C:\Users\myuser>

I am behind a corporate proxy, but the speed of the proxy doesn't seem to be an issue in any other application.

Can someone give some insight in how you're producing your time-require logs? I'd be interested to try that out, but don't see anything obvious on how to use that from the command line in the official documentation.

@Olian04
Copy link

Olian04 commented Jul 16, 2018

@wsrast take a look at #589

@wsrast
Copy link

wsrast commented Jul 17, 2018

@Olian04 Thanks, these issues do seem to all revolve around proxy settings. I've subscribed to #589 and will see if I can add anything to the conversation as I continue testing.

@MarcoScabbiolo
Copy link
Contributor

If you're having this issue running yo behind a proxy please try #597 setting the DEBUG environment variable to global-tunnel and share the output.

@wsrast
Copy link

wsrast commented Jul 23, 2018

A simple set DEBUG=global-tunnel shows no output for me on a yo --generators command on Windows.

@SBoudrias
Copy link
Member

@wsrast did you try to update yo? (uninstall/reinstall?)

@wsrast
Copy link

wsrast commented Jul 23, 2018

Yes, I've tried that several times while working with the original issue.

@MarcoScabbiolo
Copy link
Contributor

@wsrast Last version of yo that includes the additional logging isn't published to npm yet, that's why you don't get the debug info.

@SBoudrias
Copy link
Member

2.0.5 is out. My bad, I didn't know npm respect package-lock.json for global install.

@wsrast
Copy link

wsrast commented Jul 26, 2018

Here's my update using 2.0.5. I've tried in turn using proxy, http-proxy, and https-proxy settings in my global .npmrc file, and all are functional, but they all show the ~3-5 minute delay. Here's the debugging information from the global-tunnel output. The long pause occurs after the second "Creating proxying agent" statement, and before "Available Generators:". It's worth noting that all the lines before the pause show up in just a few seconds.

set DEBUG=global-tunnel && yo --generators
DEBUG global-tunnel: Found proxy in npm config proxy
DEBUG global-tunnel: Proxy configuration to be used is {
"protocol": "http:",
"host": "web.company.net",
"port": 8080,
"proxyAuth": "user:pw"
}
DEBUG global-tunnel: Creating proxying agent
DEBUG global-tunnel: Creating proxying agent
Available Generators:
@company/package

@wsrast
Copy link

wsrast commented Jul 26, 2018

I've just reverted to version 1.8.5 and performance has improved to less than 1 second for the same yo --generators command. At this point, I'll be recommending to all the business units I work with to avoid v2.0 due to the large performance hit.

@MarcoScabbiolo
Copy link
Contributor

Definitively the delays are not caused by the proxy wrapper introduced, yo --generators does not do any http request, and if it did, you would see it logged as you can see when you run yo doctor

yo doctor
DEBUG global-tunnel: Found proxy in environment variable http_proxy
DEBUG global-tunnel: Proxy configuration to be used is {
  "protocol": "http:",
  "host": "localhost",
  "port": 8080,
  "proxyAuth": null
}
DEBUG global-tunnel: Creating proxying agent
DEBUG global-tunnel: Creating proxying agent

Yeoman Doctor
Running sanity checks on your system

✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ Node.js version
DEBUG global-tunnel: Requesting to https://registry.npmjs.org:443
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
✔ yo version

Everything looks all right!

It looks like the discovery of generators is taking too long, probably because its looking in too many directories recursively.

@wsrast
Copy link

wsrast commented Jul 30, 2018

@MarcoScabbiolo This occurs with calls to individual generators as well, not just "yo" or "yo --generators".

@MarcoScabbiolo
Copy link
Contributor

The cli looks up for available generators running env.lookup on the init function that is always invoked. It doesn't matter what arguments you pass to yo the generators are always discovered and this is what is causing the delays.

@SBoudrias
Copy link
Member

Anyone running into the issue could run a profiling with chrome dev tool remote debugging? This would be extremely useful and likely to point to the core issues.

It could just be a library we bumped that has a performance regression in an hot path of yo.

@martaver
Copy link

martaver commented Aug 4, 2018

Just a thought, I'm using yeoman on Win10 with WSL, and its slow too. Are you by any chance using yarn link, or similar thing, to run a local generator too?

@SBoudrias
Copy link
Member

Ran a trace with clinic:

clinic flame -- node which yo --generators (for windows users you won't have which available, but where is roughly equivalent on powershell)

screen shot 2018-08-04 at 11 08 02 pm

Looks like most of the time is spent inside @mrmlnc/readdir-enhanced which was updated when globby was updated to use fast-glob.

You can copy-paste this HTML in jsbin to explore the graph https://gist.github.com/SBoudrias/3004406099a97f05478305311e5dc3a3

@andersaloof
Copy link

andersaloof commented Aug 20, 2018

I'm on Win 7 and I've been quite annoyed at the slowness in running generators too, so I did some console.log debugging to try to figure out whats happening.

I managed to cut almost 50% off time used before a prompt in an internal generator appears, by doing some small modifications to resolver.js, PR is here yeoman/environment#105.

However, the biggest problem is definately somewhere in fast-glob or readdir-enhanced, as stated by @SBoudrias above, to me it seems to be using an unreasonable long time searching for generators with the @*/generators-* selector.

@andersaloof
Copy link

After some more debugging, it looks to me like the underlying issue is with https://github.com/BigstickCarpet/readdir-enhanced/blob/master/lib/directory-reader.js, it seems to recurse folders which does not match the specified @*/generator-* pattern, making it traverse entire node_modules structures, when it only should be recursing into folders matching the pattern...

@MarcoScabbiolo
Copy link
Contributor

globby was updated to use fast-glob which depends on micromatch that has a performance issue.

yeoman-environment updated to version 8> of globby introducing the above issue, which was then introduced into yo when yeoman-environment was bumped

@andersaloof
Copy link

I've cut down time to prompt further, by removing lookups in non-namespace folders when searching for generators in namespace folders. A PR is here yeoman/environment#106.

In my current project, I've gone from around 20s until prompt from a generator appears, to 4s with the two submitted PRs.

@alexkreidler
Copy link

I am on a MacBook Pro with a fast SSD, yet Yeoman consistently take 1-2 seconds just to show the welcome menu. I hope these performance patches get released soon and we can see if they make a difference.

? 'Allo Tim! What would you like to do? (Use arrow keys)
  Run a generator
❯ Node Typescript
  ──────────────
  Update your generators
  Install a generator
  Find some help
  Clear global config
(Move up and down to reveal more choices)

@DrogoNevets
Copy link

Having same issue here where anything involving the yo command takes unacceptablly long.

anyone got any ideas?

Windows 10 too

@axten
Copy link

axten commented Mar 8, 2019

are there any updates here?
for me, yo startup takes up to 10 seconds.
this issue exist since we updated from 1.0 to 2.0.5...

yo 2.0.5 global installed
mac book pro mojave with SSD

@ghost
Copy link

ghost commented Apr 2, 2019

I'm in the same boat with Windows 10 and its taking 10sec. Globally installed, cleared out any other node modules I could live without (only 7 remain).
I immediately thought the problem was completely down to the fact yeoman tries to search all locations for my generator, hence the 10 seconds.
So I roughly threw yeoman into my CLI, hoping to avoid the "generator lookup" performance hit. It made a difference but not a massive difference. I went from 10seconds down to ~7sec.

Would it be helpful for me to post additional logs or metrics?

@cliffred
Copy link

cliffred commented Aug 5, 2019

I also experienced minutes of delay after running yo. I did some debugging and found it was caused by running npm -g prefix via spawnSync. (https://github.com/yeoman/environment/blob/da6411e978b833d4cbc710cb2b3f3dda965f66aa/lib/resolver.js#L216)

Then, I found this issue: https://npm.community/t/npm-version-takes-3-minutes-to-complete-when-run-in-child-process-and-behind-corporate-proxy/1658

After applying one of the workarounds mentioned there it was fixed:
Set environment variable NO_UPDATE_NOTIFIER=1

This also works:
npm config set update-notifier false

@neilenns
Copy link

neilenns commented Jun 12, 2020

I'm facing this issue on Windows 10 right now. Yeoman takes over 30 seconds to run my local generator, whereas my colleagues on a mac have it run in under a second. Any ideas what can be done to improve this? I have no need to look up external generators, I simply want to run my local one.

I did some more digging and this appears to be specific to running Yeoman inside WSL2 Unix instances on Windows 10. The same generator run from Powershell is fast, but when run inside WSL2 on Ubuntu takes over 40 seconds to start. This is with both my generator and a public one like Visual Studio Code's extension generator.

@weshouman
Copy link

👍 Thanks a lot @cliffred for the workaround, npm config set update-notifier false works like a charm.


❓ Does anybody know whether

  1. such delay could be fixed from yeoman's side
    or
  2. it stems from npm's usage of npm-update-notifier and thus has no fix from yeoman's side, and the issue could be closed by the aforementioned workaround?

📝 Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests