-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Allow internal nextTick
utility to use microtasks when possible.
#370
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from my limited understanding of these things this looks okay to me in general. it does slightly change the semantics of the lib though, so might need a bit of real world testing before getting merged/released.
On that topic, may this be a problem if we don't do the same in https://github.com/emberjs/ember.js/blob/master/packages/ember-testing/lib/test/pending_requests.js#L16-L23 ? |
@@ -1,6 +1,7 @@ | |||
import { Promise } from 'rsvp'; | |||
|
|||
export const nextTick = setTimeout; | |||
export const nextTick = | |||
typeof Promise === 'undefined' ? setTimeout : cb => Promise.resolve().then(cb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't that conflict with the nextTickPromise()
description below which talks about "the next turn of the event loop"?
I've just tried this branch out on one of our larger apps, and it worked without any issues. Unfortunately I also did not see any significant speed improvements though 🤔 |
5a678c7
to
ba418a1
Compare
Rebased against current master (which is finally green against various dep changes dropping Node 4 without major bumps)... |
This seems like a good change. @Turbo87 it surprises me that you didn't see an improvement in speed, considering we're moving from macro to microtasks. how big was your test suite? |
I think it depends on the suite actually. For example, if the suite was still using a large number of |
I do agree with #370 (review) though, I'll try to test in some OSS apps (and internally) soon. |
Tested in a few apps without issue, going to |
nextTick
utility to use microtasks when possible.nextTick
utility to use microtasks when possible.
@scalvert sorry, didn't see your comment. I'm not entirely sure anymore which app it was that I tested but I think it was about 3000 tests. The time it takes for the test suite to run was about 5min using ember-exam with 2 or 3 partitions and it did not improve by a significant amount. |
Ya, FWIW, I don't expect this to dramatically improve all scenarios, but it does reduce at least one of the sources of significant idle times. I made a quick set of JSBin's to demo the difference:
This is clearly not doing anything useful, I mainly made them this way to show the general overhead of running a "simple" test. After doing about 10 runs of each of those, the microtask one is generally ~ 4s (40%) faster. |
interesting, I didn't know that it wouldn't work with RSVP Promises. the app that I probably tried this on is using the unforunate |
No description provided.