-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default TaskQueue implementation is slow for a large number of queued tasks #452
Comments
Hey @robhogan, thanks for your notes; they are in fact very useful. We have #347 to enhance and have some out-of-the-box algorithms that can fulfills other needs, aside of the I'm seeing this one as somehow duplicated of #347, I'll link your comment there for reference. |
Use nodes fixed_queue implementation? |
As |
@ronag @metcoder95 I would like to enhance piscina with node's fixed_queue. |
Let's continue on the PR 👍 |
I'm writing this not as an ask from the maintainers but as a note for users and an opportunity for contributors.
While benchmarking
piscina
againstjest-worker
for a (very) large number of small tasks, I sawjest-worker
was several times faster out of the box, using worker threads. After digging in a bit, it turns out that for a large enough number of tasks,ArrayTaskQueue.prototype.shift()
, within the default FIFO queue , whose implementation is just an O(n)Array
shift, dominates on the host thread. For me this became apparent at around 100,000 queued tasks.A lightweight linked list implementation would speed this up algorithmically without much extra complexity in implementation - indeed using a custom
taskQueue
I was able to get parity withjest-worker
for queues around 500k.PR to follow (hopefully!), but I wanted to note this anyway for the benefit of anyone seeing (maybe without realising) this issue.
The text was updated successfully, but these errors were encountered: