microjob
threads.js
microjob | threads.js | |
---|---|---|
2 | 10 | |
2,018 | 2,989 | |
- | - | |
0.0 | 0.0 | |
over 1 year ago | 5 days ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
microjob
-
Ship it!
node.js is multithreaded under the hood and always has been. It's true that we used to not have multi thread capability as developers, but we actually have for several years now, but most developers have probably never used it. Even prior to Worker Threads/Shared Buffers, we had 3rd party modules such as node-fiber and various shared memory data structure libraries which could be used to build multi threaded javascript programs. https://github.com/wilk/microjob <- dead simple batteries included multi threading in node.js
-
Should all functions be async?
Real life example: We wanted our website to be static files to save on system time as a kind of caching strategy. So far there are about 100 pages that need to be rendered sometimes when there is an update to the site. Running all of this through our templating engine at once caused the node server to be unresponsive for about 30 to 40 seconds. No joy. There are a few ways to solve this but the one we decided on was to use web worker threads for this execution because this was not going to happen very often. About 5% to 10% of the time. It basically just puts this function (rendering all of the pages) into another thread and returns the result. Now this takes about 15 to 20 seconds and does not hold up the main thread. We used a library called Microjob that makes using a web worker really easy https://github.com/wilk/microjob
threads.js
-
threads.js VS multithreading - a user suggested alternative
2 projects | 10 Jan 2024
-
threads.js VS threadman - a user suggested alternative
2 projects | 10 Sep 2022
-
whats the advantages and disadvantages and limitations of worker thread in nodejs compared to multithreading in frameworks like spring ?
Threads.js makes it pretty easy to spawn a thread pool and handle multi-threading workloads.
-
Make your end to end tests fast
We did this via the npm threads wrapper and esbuild. We first moved all of our compute code into a new file with minimal imports, called imageCompare.worker.js. We then added a pre-compilation step with esbuild to compile this file into a bundle. We then spawn the worker using this generated file as a blob, and interact with it via the threads promise interface.
-
How to make an API route for a computationally heavy task?
That latter one is in it's own process, and I also use multiple threads with the threads library.
-
Kanye West AI in JavaScript (React and TFJS)
This app has a memory leak where your worker threads are spawning out of control. You can verify this in Chrome DevTools Source tab: after you click the Generate button, you can see the worker threads spawning out of control until you close the process.
I'd advise that you do a better job at manually spawning and terminating the threads with the TFJS process. I've had success using this library in combination with TFJS: https://threads.js.org/
-
[AskJS] Examples of Apps not suitable to be implemented with NodeJS
You can use it for everything. Even the compute tasks you can offload to worker threads using something like https://github.com/andywer/threads.js or you could create intensive modules in Rust and integrate using something like https://github.com/neon-bindings/neon
-
Hacker News top posts: May 23, 2021
Web worker meets worker threads โ threads.js\ (3 comments)
- Web worker meets worker threads โ threads.js
-
Poolifier as Node.js thread/cluster pool
threads.js
What are some alternatives?
libev - Full-featured high-performance event loop loosely modelled after libevent
piscina - A fast, efficient Node.js Worker Thread Pool implementation
threadedClass - Fork instances of classes with one line of code, all while retaining the types of the class.
partytown - Relocate resource intensive third-party scripts off of the main thread and into a web worker. ๐
Joplin - Joplin - the secure note taking and to-do app with synchronisation capabilities for Windows, macOS, Linux, Android and iOS.
comlink - Comlink makes WebWorkers enjoyable.
jobber - ๐ผ Super simple API to fetch job listings from popular job boards (Ashby, Greenhouse, Lever, etc.)
threadbox - Recursive Worker Threads in NodeJS
react-native-multithreading - ๐งต Fast and easy multithreading for React Native using JSI
workerize - ๐๏ธ Run a module in a Web Worker.
poolifier - Fast and small Node.js worker_threads and cluster worker pool
greenlet - ๐ฆ Move an async function into its own thread.