-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Use Promise.resolve().then(...) to schedule coroutines by default for all platforms (including node.js) with fallback to setTimeout #820
Comments
I agree this could lead to a performance improvement (especially on Node.js) but using I made some micro-bench with the same library that power esbench.com and those where the results on my machine (Node.js v11):
In the light of the differences in performances I think changing the Node.js dispatcher implementation is something to consider. I uploaded the bench if you are interested bench.zip |
Another reason to do it (ASAP?): #863 |
I am afraid we can't use The problem (and the virtue) of promises lies in the fact that they use different scheduling mechanism aka microtasking. And microtasks queue has the priority over regular tasks (e.g. ready-to-run I am concerned that with microtasking as default dispatch mechanism, any user can easily shoot himself in the foot. For example, do you expect the following snippet to eventually return
If microtasking is used for dispatching, this code may or may not complete, depending on the JS engine. E.g. in node on my local machine it hangs. In the chrome this block completes with |
Maybe having |
This idea sounds good and I was thinking about it as well.
will print What we can do though is to provide another JS-specific property, e.g. |
Good point, the fact that different JS engines behave differently is annoying but JS devs are (unfortunately) used to this kind of things. |
Fixed in 1.3.0-M1 |
The related micro-benchmark: https://esbench.com/bench/55d4d44e2efbca1100bf7251
Maybe it's worth to have a special implementation for Node.js using
process.nextTick
.The related issue: #194
The text was updated successfully, but these errors were encountered: