Comments (6)
From some experimentation, the slowest part is using semver
to resolve a complex version expression. Are you seeing a progress line containing "resolving"?
Relatively slow with complex expression:
% time n lsr engine
found : /Users/john/Documents/Sandpits/n/issues/807/package.json
read : >=14.6 <19.0.0
resolving : >=14.6 <19.0.0
18.20.4
n lsr engine 1.47s user 0.38s system 86% cpu 2.149 total
Relatively fast with simple expression that is recognised by n
and processed directly:
% time n lsr engine
found : /Users/john/Documents/Sandpits/n/issues/807/package.json
read : >18.0.0
target : current
22.5.1
n lsr engine 0.06s user 0.04s system 75% cpu 0.141 total
The block of code that contains that progress uses npx
to execute semver
to resolve the expression:
from n.
I'm talking about the simple case, where just starting node
is much slower than starting jq
. When a resolution is needed, there's obviously no good way to avoid going through the code.
For example, n which auto
in the source directory takes an average 354ms, and with jq
I get 169ms.
from n.
For interest, what are you doing that you notice the slowness?
from n.
If it's ok to use
jq
, I'll be happy to make a PR that uses it if it exists, or usenode
otherwise.
On the one hand, I don't particularly like checking for an optional tool. On the other hand, the engine
support checks for node in the same way! I do like that would not need node installed for processing simple expressions if jq
is available.
PR welcome, see how it goes. (And I would like jq
version included in the doctor
output.)
from n.
- Slowness: just running node has a significant startup overhead, with using node like this, that overhead is (at least) duplicated, which is how I noticed it. (So, just through plain interactive use.)
- An advantage of
jq
-- besides being smaller + faster -- is that it is a popular choice for CI pipelines, and since it's simple I figured it's worth the minor improvement. - In addition,
node
can be popular in some setups, butn
is useful in installing it in the first place for setups that lack a builtin node. So my guess is that there's good chances that there's a fair number of cases that would be simplified.
from n.
@shadowspawn Made the above PR.
Apologies, but I can't access my work machine at the moment, so I used the tweak that I did previously, with a bit of reshuffling to make it a proper PR. Hopefully I didn't make have any stupid typos.
from n.
Related Issues (20)
- Add a new command (say `use`) to switch to preinstalled versions of Node.js HOT 12
- Retry when downloading/extraction of Node.js tar fails HOT 12
- OS recogonition mistakes HOT 4
- Modify repo "About" to match npm search criteria HOT 1
- LTS downloading stable instead of LTS HOT 3
- corepack is not removed when downgrading node HOT 4
- Default install location (N_PREFIX) to home HOT 4
- Unsupported Platform for window HOT 1
- Incorrect cache folder path in show_diagnostics HOT 2
- Installation error. Pls help. HOT 3
- n latest curl: (23) Failed writing received data to disk/application HOT 3
- Problem with curl 8.7.1 HOT 4
- [Question] Maintaining global packages after installing new nodejs version HOT 2
- 。
- N_NODE_MIRROR, Error: failed to download version index + "error": "this version doesn't exist: index.tab" HOT 2
- Is there a way to force n to change versions even if node is running? HOT 1
- node executable and libs seem to be duplicated HOT 9
- Using `auto` or `engine` is inconvenient due to lack of fallback
- should not network curl `index.tab` when using numeric `.node-version` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from n.