Giter Club home page Giter Club logo

Comments (8)

sindresorhus avatar sindresorhus commented on June 11, 2024 1

I plan on supporting worker_threads here soon.

from make-synchronous.

sindresorhus avatar sindresorhus commented on June 11, 2024 1

@mmkal This executes in a subprocess which has some benefits:

  • Complete isolation.
  • Cannot hang the process (worker threads can potentially hang the main process).
  • Separate memory limit, so you could execute something that takes a lot of memory.

Yes, it's slower to launch a subprocess, but that only matters if you use it for short-running tasks. For long-running intensive tasks, the difference is neglible.

from make-synchronous.

sindresorhus avatar sindresorhus commented on June 11, 2024

Yeah, I've been thinking about moving to worker_threads (and removing the current child process implementation). When I initially made this package, I was not aware that it could be done with worker_threads too.

from make-synchronous.

JounQin avatar JounQin commented on June 11, 2024

Can I recommend user's to use synckit instead in the README?

from make-synchronous.

sindresorhus avatar sindresorhus commented on June 11, 2024

It's about 300x slower.

Your benchmark is flawed. You should run a heavy operation in the worker to actually test it, not just a lightweight task. Also, the task you are running in the worker (fs.promises.readFile) is already run in a background thread by Node.js.

from make-synchronous.

JounQin avatar JounQin commented on June 11, 2024

I plan on supporting worker_threads here soon.

That's great, I would follow your changes then.

from make-synchronous.

mmkal avatar mmkal commented on June 11, 2024

@sindresorhus I came here wondering what the advantages are of this over synckit. synckit seems well thought, fairly feature-rich out and widely used - do you think it's worth maintaining this rival at this point? Is there something missing from synckit that make-synchronous does better, or will do better?

This is a genuine question - it's often hard to tell what the tradeoffs of various libraries are, and maintainers tend to know best.

from make-synchronous.

JounQin avatar JounQin commented on June 11, 2024

Yes, it's slower to launch a subprocess, but that only matters if you use it for short-running tasks. For long-running intensive tasks, the difference is neglible.

Or if your task needs to be run many times, there will be huge difference too.

from make-synchronous.

Related Issues (8)

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.