Git Product home page Git Product logo

tinypool's Introduction

Tinypool - the node.js worker pool ๐Ÿงต

Piscina: A fast, efficient Node.js Worker Thread Pool implementation

Tinypool is a fork of piscina. What we try to achieve in this library, is to eliminate some dependencies and features that our target users don't need (currently, our main user will be Vitest). Tinypool's install size (38KB) can then be smaller than Piscina's install size (6MB). If you need features like utilization or NAPI, Piscina is a better choice for you. We think that Piscina is an amazing library, and we may try to upstream some of the dependencies optimization in this fork.

  • โœ… Smaller install size, 38KB

  • โœ… Minimal

  • โœ… No dependencies

  • โœ… Physical cores instead of Logical cores with physical-cpu-count

  • โŒ No utilization

  • โŒ No NAPI

  • Written in TypeScript, and ESM support only. For Node.js 14.x and higher.

Example

In main.js:

import path from 'path'
import Tinypool from 'tinypool'

const pool = new Tinypool({
  filename: new URL('./worker.js', import.meta.url).href,
})

;(async function () {
  const result = await pool.run({ a: 4, b: 6 })
  console.log(result) // Prints 10
})()

In worker.js:

export default ({ a, b }) => {
  return a + b
}

API

We have a similar API to Piscina, so for more information, you can read Piscina's detailed documentation and apply the same techniques here.

Additional Options
  • isolateWorkers: Default to false. Always starts with a fresh worker when running tasks to isolate the environment.

Credits

The Vitest team for giving me the chance of creating and maintaing this project for vitest.

Piscina, because Tinypool is not more than a friendly fork of piscina.

tinypool's People

Contributors

0xflotus avatar addaleax avatar antfu avatar aslemammad avatar deivu avatar hhprogram avatar jasnell avatar nicholas-l avatar prinzhorn avatar sajad-sharhani avatar samverschueren avatar trivikr avatar usmanyunusov avatar zaubernerd avatar

Watchers

 avatar

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.