tinylibs / tinypool

🧵 A minimal and tiny Node.js Worker Thread Pool implementation (38KB)

Home Page:https://npmjs.com/package/tinypool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

With isolation enabled tinypool keeps worker count at a minimum

Demivan opened this issue · comments

If isolation is enabled _ensureMinimumWorkers is called when worker is done. But it only creates a worker if worker count is less then minimum.

Because minimum worker count is half of physical core count right now, this means that Tinypool is using only a quarter of actual PC cores. This is really inefficient. On my 16 core CPU Tinypool is using only 4 cores.

So we've got two solutions now:
1: #22
2: making your quarter of cores into half of them!

Which one do you suggest? For now, two is more appropriate, which can be a bug! and then 1

I think I will add a minThreads/maxThreads override in Vitest for now.
Tinypool just needs a better scheduling for isolated workers. It should keep using available threads.

I think I will add a minThreads/maxThreads override in Vitest for now. Tinypool just needs a better scheduling for isolated workers. It should keep using available threads.

https://github.com/vitest-dev/vitest/blob/578258e026922ab2bbbebca5de864570b7101de5/packages/vitest/src/node/config.ts#L103

@Demivan Could you check #24 and try it!

@Demivan Please let's keep Vitest aligned with tinypool! So let's not override, so we can benefit from improvements properly 😄