-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
perf: avoid importing npm-registry-fetch for replace-info #7314
Conversation
We are going to publish the replace info util as its own module since we need a version of it elsewhere as well. I believe that should have a similar performance impact. But I don't think this PR will land as is. Thank you for this though! I will keep the open until we have an open PR implementing it as a separate package so we can benchmark that also. |
In case you are interested in other refactor or small gains, the full log with the amount of time to load each js file requested: npm run echo
|
See prior discussion in #7176 |
Just a refresher here about why npm does not typically allow lazy loading of modules. |
I also want to say again thank you @H4ad for all of the work you've put in on performance improvements to npm. It's nowhere near as easy as folks think it is, it's slow going and usually when you're done nobody even notices. We notice. We think you're great. |
imho replace-info and cleanUrl belong in this net new package, wdyt @lukekarrys ? (This is now the issue where we will discuss the new package, it's as good as any) |
I also want to add that we now have a test protecting against regressions here. We (and by we I mean @wraithgar) have had success moving to lazy loading requires in a few places after we implemented that test. |
agreed. what do we think about a name? |
This does more than clean urls it also has a more aggressive match for stripping known npm token patterns. |
Or we can make this a named export of our logger which we will be requiring on every instantiation. |
Maybe this will springboard into |
output / logging task is here we can move the conversation there |
Closing in favor of #7334 |
Instead of importing the entire module, just copy the function from the
npm-registry-fetch
.Benchmark:
hyperfine --warmup 3 "node ./bin/npm-cli.js run echo"
Before:
After: