Fix performance issue with setImmediate #619
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there,
As explained in issue #617, there's a serious performance issue in
generateAsync
since v3.2.0.After having run a comparison test (https://jsbin.com/kuxutodini/edit?html,console) and monitored the performance with Chrome's Javascript Profiler, I noticed repeated pauses during which the browser does nothing.
I found the culprit to be a change introduced in 5566c95 from MR #532.
The set-immediate-shim introduced is a very naive implementation using the
setTimeout(..., 0)
trick, whereas thecore-js
ponyfill used before is more subtle, e.g. usingMessageChannel
in browsers (as explained on MDN).setImmediate
is used extensively in the code base, and this change alone made the performance drop significantly in browsers.This MR is a partial revert of 5566c95, but with a recent version of
core-js-pure
instead of the oldercore-js
used before. With,core-js-pure
we're guaranteed to use a ponyfill (not a polyfill polluting the global environment) as explained here.The resulting file sizes in
dist/
folder are a little bigger, but I think this is totally acceptable: