Repository navigation
[Perf] nvm_resolve_local_alias: skip nvm_version for an exact, installed version - #3945
hridhinvarkeyjoseph wants to merge 1 commit into
Conversation
…stalled version See nvm-sh#3416
|
@ljharb I've also cherry-picked this commit onto #3937, since both are the same exact-version fast path on the startup route. Would you prefer to review them together there (and I'll close this one), or keep this as a separate PR? The 3 failing checks look unrelated to the change: the two WSL |
|
Closing in favour of #3937, which now includes this commit, so there's one PR for this startup fast path instead of two overlapping ones. |
|
In the future, please don't ever close a PR you've opened; PR refs are permanent and can never be removed. |
|
@ljharb Understood, sorry about that. I've reopened this. Since #3937 also has this commit cherry-picked, which would you prefer?
|
|
Folded into #3937. |
|
Sorry, I closed this by mistake despite your earlier note — reopened. Its commit is already in #3937 (now approved, with your tweak), so please close this one whenever it suits you. |
Part of #3416 (the second cost described in #3416 (comment)).
When an alias resolves to an exact
vX.Y.Zthat is already installed,nvm_resolve_local_aliasstill passes it throughnvm_version, which can't change the result. This returns it directly after annvm_is_version_installedcheck. Anything else (partial versions,node,lts/*, iojs, not-installed versions) still goes throughnvm_versionas before.In the fast test fixtures this took
nvm_resolve_local_aliason an exact alias from ~63ms to ~22ms per call.This does not address the bigger cost in the original report, where
default -> nodehas to resolve thenode/stableimplicit aliases. Happy to look at that separately, or to fold this into #3937 if you'd prefer.Adds a test that mocks
nvm_versionto confirm it's skipped for an exact installed version and still used for one that isn't installed.