fix(perf): avoid importing the entire semver package for update-notifier#7346
fix(perf): avoid importing the entire semver package for update-notifier#7346wraithgar merged 1 commit intonpm:latestfrom H4ad:perf/startup-time-update-notifier
Conversation
|
Update notifier is often skipped due to config or if it has been run recently. In addition to this, do you think we should lazy load all the requires in this file? |
|
@lukekarrys, if you think it will not hurt the maintainability, lazy loading everything will save ~ Most of the |
|
The update notifier, as far as I can remember, is called in a completely asynchronous way that gracefully handles a situation where the npm command is done before it finishes. Optimizing it is probably not needed. If you find a situation where the update notifier is blocking the event loop, causing npm to not exit if the command is already finished, that is an actionable situation. Otherwise it's probably not worth the effort. |
The About this module, just refactoring the imports for |
|
I also want to note that this may cause fluctuations in benchmarking. You can add |
There are a bunch of places were we load
semver, I'm trying to see if I can remove the full import forsemverand only import the specific functions.Currently, I didn't have any perf improvement since we still load the entire
semver, once we have removed all the package loads, then we could see some improvement (a little bit).