]> Piment Noir Git Repositories - poolifier.git/commit
perf(pools): make task stealing hot path allocation free (#3413)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 18 Nov 2026 00:26:22 +0000 (01:26 +0100)
committerGitHub <noreply@github.com>
Wed, 18 Nov 2026 00:26:22 +0000 (01:26 +0100)
commit3a2df88b44399248a0086737c819e1323a62ed6e
treebc549022731aa321fa21f88f27ea142cb6cbd16e
parent6c3bfec204e7fd075ca7ecc2e2793d5e93a2339d
perf(pools): make task stealing hot path allocation free (#3413)

* perf(pools): make task stealing hot path allocation free

- select the steal source worker node with a single O(n) argmax scan
  (`selectStealSourceWorkerNode`) instead of sorting a copy of the
  worker nodes; tie-breaking matches the previous stable sort
- test for queued tasks with an early-exit scan (`hasQueuedTasks`) on
  every idle event instead of summing the full queued count

Selection is identical to the previous `sort().find()` behaviour
(fuzz-tested against a reference implementation over 10k random
vectors). No allocation per idle event anymore.

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
src/pools/abstract-pool.ts
src/pools/utils.ts
tests/pools/utils.test.mjs