-
-
Notifications
You must be signed in to change notification settings - Fork 749
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
Copying node is slow #831
Comments
Also, hard links do not work across partitions, and the cache destination and install destination may be on different partitions.
I appreciate that you recognise switching to symlinks would be major and unlikely, but adding a partial feature to make it possible to opt-in is... a bit weird and overly specific. 😆 For interest, my recollection is this is similar to how |
The two supported ways of avoiding or lowering the copy cost are:
|
For my own interest I did a quick check, and % time n 22.13.1
copying : node/22.13.1
installed : v22.13.1 (with npm 10.9.2)
n 22.13.1 0.18s user 1.09s system 45% cpu 2.797 total
% time n 22.13.1
copying : node/22.13.1
installed : v22.13.1 (with npm 10.9.2)
n 22.13.1 0.18s user 1.07s system 46% cpu 2.676 total
% time n --preserve 22.13.1
copying : node/22.13.1
installed : v22.13.1
n --preserve 22.13.1 0.09s user 0.44s system 29% cpu 1.815 total
% time n --preserve 22.13.1
copying : node/22.13.1
installed : v22.13.1
n --preserve 22.13.1 0.09s user 0.44s system 28% cpu 1.853 total |
Copying a big directory is slow.
Using symlinks is much lighter, but obviously there's too many issues.
I have two suggestions:
First,
cp -l
creates a hard link, which is of course much faster, and the result is very close to a plaincp
so there shouldn't be any issues. For example, a very lightweight change would be to setCP="cp -l"
and use that instead of allcp
s. (CP_OPTIONS
is better, but maybe that's too big of a change.)Second, having a symlink based thing is nice not only in being fast, but also in keeping things more organized, since the downloaded stuff is kept in a single place. But of course adding that properly is expensive + risky so unlikely to be desirable.
A possible way to get that with minimal changes could be:
/usr/local/n/versions/node/current -> 22.13.1
. That should be just a one-line thing to create/set it before copying. This effectively adds a proper place that remembers the current version directly rather thannode --version
.--no-copy
flag (better: envvar (better: both)) to completely skip copying (so just the above symlink is changed). This is probably also a very small change.This means that I can maintain my own
bin/*
symlinks tocurrent/bin/*
, and others if I want to.Now, this looks like a weird and overly specific feature, but a good way to think about it is that
n
has functionality to (A) get some node version, and more functionality to (B) install it. This suggestion makes it possible to use (A) without (B). (IOW: useinstalll()
withoutactivate()
.)This is very close to using
--download
, the only difference is that it's still doing the symlink change. A tiny change would be to rename$DOWNLOAD
to a$MODE
internally, so it can have three values for downloading only, or also doing the symlink, or also doing the whole thing.Again, I can do PRs for both of these if it sounds reasonable. I'm guessing that they will be very small overall.
The text was updated successfully, but these errors were encountered: