{"action":"created","issue":{"url":"https://api.github.com/repos/npm/npm/issues/12280","repository_url":"https://api.github.com/repos/npm/npm","labels_url":"https://api.github.com/repos/npm/npm/issues/12280/labels{/name}","comments_url":"https://api.github.com/repos/npm/npm/issues/12280/comments","events_url":"https://api.github.com/repos/npm/npm/issues/12280/events","html_url":"https://github.com/npm/npm/issues/12280","id":147001772,"number":12280,"title":"npm-cli startup overhead could be faster","user":{"login":"gregglind","id":163983,"avatar_url":"https://avatars.githubusercontent.com/u/163983?v=3","gravatar_id":"","url":"https://api.github.com/users/gregglind","html_url":"https://github.com/gregglind","followers_url":"https://api.github.com/users/gregglind/followers","following_url":"https://api.github.com/users/gregglind/following{/other_user}","gists_url":"https://api.github.com/users/gregglind/gists{/gist_id}","starred_url":"https://api.github.com/users/gregglind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregglind/subscriptions","organizations_url":"https://api.github.com/users/gregglind/orgs","repos_url":"https://api.github.com/users/gregglind/repos","events_url":"https://api.github.com/users/gregglind/events{/privacy}","received_events_url":"https://api.github.com/users/gregglind/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/npm/npm/labels/feature-request","name":"feature-request","color":"98DCFF"},{"url":"https://api.github.com/repos/npm/npm/labels/patch-welcome","name":"patch-welcome","color":"BEEB71"},{"url":"https://api.github.com/repos/npm/npm/labels/performance","name":"performance","color":"0084FF"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-08T18:24:03Z","updated_at":"2016-04-08T21:08:55Z","closed_at":"2016-04-08T20:40:58Z","body":"(maybe related to #8826)\r\n**Observed**:  OSX.  **0.5 **second startup times for `cli` command.   \r\n```\r\ntime sh -c 'node -v'\r\nreal\t0m0.051s\r\n```\r\n\r\n## Why Problem\r\n\r\n`npm run-script` build process can call out to `npm` multiple time.  Those seconds add up :)\r\n\r\n## Lots of requires\r\n\r\nAdded a `time-require` call to see what happens.\r\n```\r\nnpm@3.6.0 /usr/local/lib/node_modules/npm\r\n\r\n\r\nStart time: (2016-04-08 18:10:02 UTC) [treshold=1%]\r\n #  module                                                                   time  %\r\n 1  chalk (../lib/node_modules/time-require/node_modules/chalk/index.js)      8ms  ▇ 1%\r\n 2  ./lib/_stream_readable.js (../lib/...e-stream/lib/_stream_readable.js)    7ms  ▇ 1%\r\n 3  readable-stream (../lib/node_modul...ules/readable-stream/readable.js)   21ms  ▇▇▇ 3%\r\n 4  are-we-there-yet (../lib/node_modu...odules/are-we-there-yet/index.js)   25ms  ▇▇▇ 4%\r\n 5  lodash.pad (../lib/node_modules/np...node_modules/lodash.pad/index.js)    7ms  ▇ 1%\r\n 6  lodash.padright (../lib/node_modul...modules/lodash.padright/index.js)    8ms  ▇ 1%\r\n 7  lodash.padleft (../lib/node_module..._modules/lodash.padleft/index.js)    8ms  ▇ 1%\r\n 8  gauge (../lib/node_modules/npm/nod...de_modules/gauge/progress-bar.js)   36ms  ▇▇▇▇ 6%\r\n 9  npmlog (../lib/node_modules/npm/node_modules/npmlog/log.js)              67ms  ▇▇▇▇▇▇▇▇ 10%\r\n10  graceful-fs (../lib/node_modules/n...dules/graceful-fs/graceful-fs.js)    9ms  ▇ 1%\r\n11  http (../lib/node_modules/npm/node_modules/ini/ini.js)                   10ms  ▇▇ 2%\r\n12  config-chain (../lib/node_modules/...de_modules/config-chain/index.js)   17ms  ▇▇ 3%\r\n13  osenv (../lib/node_modules/npm/node_modules/osenv/osenv.js)              11ms  ▇▇ 2%\r\n14  ./defaults.js (../lib/node_modules/npm/lib/config/defaults.js)           30ms  ▇▇▇▇ 5%\r\n15  ./config/core.js (../lib/node_modules/npm/lib/config/core.js)            65ms  ▇▇▇▇▇▇▇ 10%\r\n16  ../utils/correct-mkdir.js (../lib/...s/npm/lib/utils/correct-mkdir.js)   13ms  ▇▇ 2%\r\n17  ./get-stat.js (../lib/node_modules/npm/lib/cache/get-stat.js)            13ms  ▇▇ 2%\r\n18  glob (../lib/node_modules/npm/node_modules/glob/glob.js)                 14ms  ▇▇ 2%\r\n19  rimraf (../lib/node_modules/npm/node_modules/rimraf/rimraf.js)           15ms  ▇▇ 2%\r\n20  ./cache/caching-client.js (../lib/.../npm/lib/cache/caching-client.js)   41ms  ▇▇▇▇▇ 6%\r\n21  crypto (../lib/node_modules/npm/lib/cache/caching-client.js)              7ms  ▇ 1%\r\n22  ../lib/npm.js (../lib/node_modules/npm/lib/npm.js)                      138ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 21%\r\n23  ../lib/utils/error-handler.js (../...s/npm/lib/utils/error-handler.js)   11ms  ▇▇ 2%\r\n24  npm-package-arg (../lib/node_modul...e_modules/npm-package-arg/npa.js)    7ms  ▇ 1%\r\n25  /usr/local/lib/node_modules/npm/no...pm-registry-client/lib/access.js)    8ms  ▇ 1%\r\n26  ./pubsuffix (../lib/node_modules/n...es/tough-cookie/lib/pubsuffix.js)   41ms  ▇▇▇▇▇ 6%\r\n27  ./memstore (../lib/node_modules/np...les/tough-cookie/lib/memstore.js)    9ms  ▇ 1%\r\n28  tough-cookie (../lib/node_modules/...dules/tough-cookie/lib/cookie.js)   58ms  ▇▇▇▇▇▇▇ 9%\r\n29  ./lib/cookies (../lib/node_modules...e_modules/request/lib/cookies.js)   59ms  ▇▇▇▇▇▇▇ 9%\r\n30  https (https)                                                            10ms  ▇▇ 2%\r\n31  boom (../lib/node_modules/npm/node...k/node_modules/boom/lib/index.js)    7ms  ▇ 1%\r\n32  hawk (../lib/node_modules/npm/node...t/node_modules/hawk/lib/index.js)   18ms  ▇▇ 3%\r\n33  ./ber/index (../lib/node_modules/n...de_modules/asn1/lib/ber/index.js)    7ms  ▇ 1%\r\n34  asn1 (../lib/node_modules/npm/node...k/node_modules/asn1/lib/index.js)    8ms  ▇ 1%\r\n35  ./signature (../lib/node_modules/n...e_modules/sshpk/lib/signature.js)   11ms  ▇▇ 2%\r\n36  ./pem (../lib/node_modules/npm/nod...modules/sshpk/lib/formats/pem.js)    7ms  ▇ 1%\r\n37  ./formats/auto (../lib/node_module...odules/sshpk/lib/formats/auto.js)   10ms  ▇▇ 2%\r\n38  ./private-key (../lib/node_modules...modules/sshpk/lib/private-key.js)   25ms  ▇▇▇ 4%\r\n39  ./utils (../lib/node_modules/npm/n.../node_modules/sshpk/lib/utils.js)   27ms  ▇▇▇ 4%\r\n40  ./fingerprint (../lib/node_modules...modules/sshpk/lib/fingerprint.js)   30ms  ▇▇▇▇ 5%\r\n41  ./key (../lib/node_modules/npm/nod...re/node_modules/sshpk/lib/key.js)   43ms  ▇▇▇▇▇ 7%\r\n42  sshpk (../lib/node_modules/npm/nod.../node_modules/sshpk/lib/index.js)   44ms  ▇▇▇▇▇ 7%\r\n43  ./utils (../lib/node_modules/npm/n...ules/http-signature/lib/utils.js)   45ms  ▇▇▇▇▇ 7%\r\n44  ./parser (../lib/node_modules/npm/...les/http-signature/lib/parser.js)   50ms  ▇▇▇▇▇▇ 8%\r\n45  jsprim (../lib/node_modules/npm/no...ode_modules/jsprim/lib/jsprim.js)    9ms  ▇ 1%\r\n46  ./signer (../lib/node_modules/npm/...les/http-signature/lib/signer.js)   12ms  ▇▇ 2%\r\n47  http-signature (../lib/node_module...ules/http-signature/lib/index.js)   64ms  ▇▇▇▇▇▇▇ 10%\r\n48  ./db.json (../lib/node_modules/npm...pes/node_modules/mime-db/db.json)    7ms  ▇ 1%\r\n49  mime-db (../lib/node_modules/npm/n...es/node_modules/mime-db/index.js)    9ms  ▇ 1%\r\n50  mime-types (../lib/node_modules/np...node_modules/mime-types/index.js)   14ms  ▇▇ 2%\r\n51  form-data (../lib/node_modules/npm...dules/form-data/lib/form_data.js)   12ms  ▇▇ 2%\r\n52  ./schemas (../lib/node_modules/npm...r-validator/lib/schemas/index.js)   10ms  ▇▇ 2%\r\n53  is-my-json-valid (../lib/node_modu...odules/is-my-json-valid/index.js)   10ms  ▇▇ 2%\r\n54  ./runner (../lib/node_modules/npm/...ules/har-validator/lib/runner.js)   22ms  ▇▇▇ 3%\r\n55  har-validator (../lib/node_modules...dules/har-validator/lib/index.js)   27ms  ▇▇▇ 4%\r\n56  ./lib/har (../lib/node_modules/npm/node_modules/request/lib/har.js)      28ms  ▇▇▇ 4%\r\n57  ./request (../lib/node_modules/npm/node_modules/request/request.js)     188ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 29%\r\n58  request (../lib/node_modules/npm/node_modules/request/index.js)         253ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 39%\r\n59  /usr/local/lib/node_modules/npm/no...npm-registry-client/lib/fetch.js)  254ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 39%\r\n60  validate-npm-package-license (../l...ate-npm-package-license/index.js)   12ms  ▇▇ 2%\r\n61  ./fixer (../lib/node_modules/npm/n...malize-package-data/lib/fixer.js)   19ms  ▇▇▇ 3%\r\n62  normalize-package-data (../lib/nod...ze-package-data/lib/normalize.js)   22ms  ▇▇▇ 3%\r\n63  /usr/local/lib/node_modules/npm/no...m-registry-client/lib/publish.js)   25ms  ▇▇▇ 4%\r\nTotal require(): 726\r\nTotal time: 649ms\r\n```\r\n\r\n\r\n## Proposed solution\r\n\r\nI have no idea :)  Current `require` semantics need a lot of `stat` and fs overhead. /me shurgs \r\n\r\nMaybe build all of what npm itself needs into one file as part of build?"},"comment":{"url":"https://api.github.com/repos/npm/npm/issues/comments/207607309","html_url":"https://github.com/npm/npm/issues/12280#issuecomment-207607309","issue_url":"https://api.github.com/repos/npm/npm/issues/12280","id":207607309,"user":{"login":"gregglind","id":163983,"avatar_url":"https://avatars.githubusercontent.com/u/163983?v=3","gravatar_id":"","url":"https://api.github.com/users/gregglind","html_url":"https://github.com/gregglind","followers_url":"https://api.github.com/users/gregglind/followers","following_url":"https://api.github.com/users/gregglind/following{/other_user}","gists_url":"https://api.github.com/users/gregglind/gists{/gist_id}","starred_url":"https://api.github.com/users/gregglind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregglind/subscriptions","organizations_url":"https://api.github.com/users/gregglind/orgs","repos_url":"https://api.github.com/users/gregglind/repos","events_url":"https://api.github.com/users/gregglind/events{/privacy}","received_events_url":"https://api.github.com/users/gregglind/received_events","type":"User","site_admin":false},"created_at":"2016-04-08T21:08:55Z","updated_at":"2016-04-08T21:08:55Z","body":"I fat-fingered the times above :)  It really is half a second :)   Not that it changes much of what you said.  \r\n\r\nIt's just one of those things that is a continual low level drag, and inhibits the use of `npm` as build tool.\r\n\r\n```\r\nTotal require(): 726\r\nTotal time: 446ms\r\n\r\nreal\t0m0.563s\r\nuser\t0m0.422s\r\nsys\t0m0.080s\r\n```"}}