Code Monkey home page Code Monkey logo

Comments (6)

shadowspawn avatar shadowspawn commented on August 25, 2024

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:

n/bin/n

Line 1112 in 76d6b98

verbose_log "resolving" "${range}"

from n.

elibarzilay avatar elibarzilay commented on August 25, 2024

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.

shadowspawn avatar shadowspawn commented on August 25, 2024

For interest, what are you doing that you notice the slowness?

from n.

shadowspawn avatar shadowspawn commented on August 25, 2024

If it's ok to use jq, I'll be happy to make a PR that uses it if it exists, or use node 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.

elibarzilay avatar elibarzilay commented on August 25, 2024
  1. 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.)
  2. 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.
  3. In addition, node can be popular in some setups, but n 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.

elibarzilay avatar elibarzilay commented on August 25, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.