Comments (11)
It’s going to pick the Worker that has the least amount of tasks currently being processed, i.e. yes, it picks “breadth first”. In your example, task 3 may end up being picked up by either worker, depending on which Worker finishes its task first.
from piscina.
Since Worker pools aren’t graphs: What would breadth-first or depth-first even mean here?
from piscina.
As I understand concurrentTasksPerWorker
is how many tasks a worker can run concurrently.
So if I have concurrentTasksPerWorker = 2 and maxThreads = 2. How will the tasks be scheduled?
Let's say I have 3 tasks.
Breadth first:
Worker1: task 1
Worker2: task 2 (reached maxThreads start over)
Worker1: task 3
Depth first:
Worker1: task 1
Worker1: task 2 (reached concurrentTasksPerWorker switch to next worker)
Worker2: task 3
from piscina.
It likely would be a good idea to document that :-)
from piscina.
Would be nice to be able to implement a custom scheduler, i.e. I might want to consider cpu utilization instead of queue size. Or maybe even want to have it depth first if I have a IO mixed workload.
from piscina.
if I have a IO mixed workload.
I mean, in that case, don’t use Workers.
from piscina.
I mean, in that case, don’t use Workers.
There is a lot of computation mixed with IO. I could do the IO in master and then transfer to worker but that just adds lots of complexity.
from piscina.
I mean, in that case, don’t use Workers.
There is a lot of computation mixed with IO. I could do the IO in master and then transfer to worker but that just adds lots of complexity.
That’s generally the idea behind this library, though. From what it sounds like, piscina might not be the right fit for you, if you do I/O in the Worker pool anyway.
from piscina.
piscina might not be the right fit for you
It fits just fine even if not perfect. I'm moving low priority work with lot's cpu utilization off my main thread with almost no added complexity. Just could be even better with more fine grained scheduling.
from piscina.
I'm not convinced that changing the scheduling model would yield any significant benefit, regardless of the workload type.
@ronag, do you see a possible performance benefit?
from piscina.
Maybe. But it's a bit unclear to me as well. I think we can keep things simple as is.
from piscina.
Related Issues (20)
- Any particular reason for the 1100+ lines `src/index.ts`? HOT 1
- Support for `AsyncIterators` HOT 1
- Block the others thread when set minThreads = 1 HOT 3
- No handler function exported after building via webpack HOT 6
- How can I pass service between service and workers? HOT 3
- Piscina and @types/node > 20.8.0 HOT 2
- Threads are re-created when calling `destroy` HOT 2
- Increase memory consumption HOT 9
- TypeScript + ESM modules + piscina v3.2.0 HOT 1
- Default TaskQueue implementation is slow for a large number of queued tasks HOT 5
- How to distribute message data to each worker? HOT 1
- Thoughts on m:n worker mapping? HOT 9
- The value of "val" is out of range HOT 3
- resourceLimits Working HOT 3
- Make Max Threads default to `os.availableParallelism()` https://nodejs.org/api/os.html#osavailableparallelism HOT 3
- Is there a programmatic way to kill all workers of a queue? HOT 4
- Errors thrown from Node vm.Script cause pool.run() to resolve to null instead of rejecting HOT 3
- Error [ERR_MODULE_NOT_FOUND]: Cannot find module '...\app.asar\out\main\worker.js' imported from ...\app.asar\node_modules\piscina\dist\src\worker.js HOT 3
- Express js
- RangeError in Piscina -> RecordableHistogram HOT 3
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 piscina.