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

Array.shift() causing bad perf when there are lots of tasks #916

Open
jtarchie opened this Issue Oct 26, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@jtarchie

jtarchie commented Oct 26, 2017

tl;dr - Chrome doesn't handle Array#shift in an efficient manner for large arrays. Causing workerQueue to not handle lots of events in a quick manner.

Our application uses EventSource to stream output from an external process. The EventSource is 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.shift in Javascript is inefficient in Google Chrome for large arrays. This causes workQueue to 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!

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

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.

@zwilias

This comment has been minimized.

Show comment
Hide comment
@zwilias

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.)

Member

zwilias commented Oct 27, 2017

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.)

@evancz evancz added the performance label Mar 7, 2018

@evancz evancz changed the title from process queue cannot handle a large number of events in Google Chrome to Array.shift() causing bad perf when there are lots of tasks Mar 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment