Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upArray.shift() causing bad perf when there are lots of tasks #916
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Oct 26, 2017
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Oct 26, 2017
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zwilias
Oct 27, 2017
Member
For reference, a fairly simple fifo queue implementation that only has enqueue and dequeue operations like this one make performance on chrome manageable. (It basically cheats by acting as if dequeued elements are no longer in the array, periodically slicing the start off in a batch.)
|
For reference, a fairly simple fifo queue implementation that only has |
jtarchie commentedOct 26, 2017
•
edited
Edited 4 times
-
jtarchie
edited Oct 26, 2017 (most recent)
-
jtarchie
edited Oct 26, 2017
-
jtarchie
edited Oct 26, 2017
-
jtarchie
edited Oct 26, 2017
tl;dr - Chrome doesn't handle
Array#shiftin an efficient manner for large arrays. CausingworkerQueueto not handle lots of events in a quick manner.Our application uses EventSource to stream output from an external process. The
EventSourceis modeled as a subscription, with each event triggering a new message.On some streams, we can received hundreds of thousands of events, which creates a new process for each event on the elm process queue. On Google Chrome, the process queue does not get processed in a timely manner. On Firefox, however, it is near instantaneous. We were able to find with the Performance developer tool in Chrome that a lot of time is spent in
work.We've been able to find that
Array.shiftin Javascript is inefficient in Google Chrome for large arrays. This causesworkQueueto choke on a large amount of processes.With @zwilias help there is a SSCCE example. It doesn't use
EventSource, but does demostrate the slow processing of a large number of processes. Try it in Chrome and then FF. Such wow, amaze!