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

Improve performance by loading dependencies only when needed. #80

Closed
nikhilkh opened this issue May 9, 2016 · 1 comment
Closed

Improve performance by loading dependencies only when needed. #80

nikhilkh opened this issue May 9, 2016 · 1 comment

Comments

@nikhilkh
Copy link
Contributor

nikhilkh commented May 9, 2016

Some of the node modules that index.js depends on do not need to be loaded, unless a later version of an npm module is found. Delay loading them provides better startup performance by pay-for-play. Here's the simple test that I performed on warm-startup and it improve the node module load time by 50% for update-notifier and it's children.

I will shortly submit a PR with my change.

--- a/before.txt
+++ b/after.txt
@@ -1,36 +1,18 @@
->> Module load abbrev parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 2
-> Module load nopt parent: . : 7
+> Module load nopt parent: . : 3
 > Module load underscore parent: . : 5
->> Module load child_process parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 2
->>>> Module load ./polyfills.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 2
->>> Module load graceful-fs parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 7
->>> Module load osenv parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 3
+>> Module load child_process parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 3
+>>>>> Module load ./fs.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/node_modules/graceful-fs/graceful-fs.js : 2
+>>>> Module load ./polyfills.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 3
+>>> Module load graceful-fs parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 9
+>>> Module load osenv parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 4
+>>> Module load object-assign parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 2
 >>>>> Module load crypto parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/node_modules/uuid/uuid.js : 4
 >>>> Module load ./rng parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 5
 >>> Module load uuid parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 7
 >>> Module load xdg-basedir parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 2
->>>> Module load slide parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 2
->>> Module load write-file-atomic parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 4
->> Module load configstore parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 28
->> Module load chalk parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 5
->>> Module load semver parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 2
->> Module load semver-diff parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 3
->>>>> Module load http parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 3
->>>>> Module load https parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 3
->>>>>> Module load stream parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/index.js : 2
->>>>>> Module load ./lib/_stream_readable.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/index.js : 5
->>>>>> Module load ./lib/_stream_writable.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/index.js : 2
->>>>> Module load readable-stream parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 11
->>>>> Module load url-parse-lax parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 2
->>>>>> Module load ./vendor/parse parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/index.js : 2
->>>>> Module load parse-json parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 3
->>>>> Module load ./package.json parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 2
->>>> Module load got parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/index.js : 37
->>>>> Module load ./lib/utils parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 2
->>>> Module load rc parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/index.js : 4
->>> Module load package-json parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 42
->> Module load latest-version parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 43
->>> Module load string-width parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 4
->> Module load boxen parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 9
-> Module load update-notifier parent: . : 92
+>>>> Module load slide parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 3
+>>> Module load write-file-atomic parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 6
+>>> Module load dot-prop parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 3
+>> Module load configstore parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 35
+> Module load update-notifier parent: . : 40
@sindresorhus
Copy link
Owner

Was fixed by #82.

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

No branches or pull requests

2 participants