-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
react-packager: Use Bluebird (or others) instead of Q as Promises library #361
Comments
I think most bottleneck are transformation and filesystem. If you want to give it a go and report back numbers, I'll happily consider it :) |
The benchmark isn't really relevant as it runs with N=10000 and (I assume) packager is always N=1 - if you run the benchmark with N=1 you will hopefully not see any difference between implementations as anything is fast for a small N. |
Thanks for the clarification @petkaantonov |
I probably picked an irrelevant benchmark above depending on what it really tested, but I still think I identified a real performance bottleneck here... I ran a quick test just on Test SummaryBluebird performed almost 2x faster 👊
You can find the test script and full result here. DependencyGraph with Q (current code)
DependencyGraph with Bluebird (modified code)
Note that I only replaced I discovered this problem while trying to integrate with webpack. The solution I currently settled on uses |
That's surprising that so many promises are being created that there is actually a difference. It would be interesting to know how many. The bluebird sequential benchmark creates 80000 promises with N=10000 and 8 promises with N=1, hence why you wouldn't see any difference with N=1. |
@petkaantonov This particular case ( What's the best way to measure how many promises are created? |
@pilwon In bluebird I have just ad hoc edited the promise constructor code by doing Promise.promisesCreated++ (Initialize it to 0 somewhere first) inside the constructor and then reading it out at the end of the benchmark. Also results for 3.0 would be interesting too as it provides some significant performance improvements to Promise.all and promisify |
@petkaantonov Is this the right place? |
@pilwon Yes it is |
46039 promises are created in each test run. 😱 😲 😒 |
Ok, that's shocking and my earlier point doesn't make sense any more.. I was expecting more like 10-100 promises being created |
This awesome, thanks for digging into it. |
Summary: This PR improves performance of `react-packager` by switching the promises library from the [Q](https://github.com/kriskowal/q) to [Bluebird](https://github.com/petkaantonov/bluebird). [Here is the test result](facebook#361 (comment)) showing a noticeable difference. (2x speed improvement) Please refer to [this issue](facebook#361) for more details. Closes facebook#516 Github Author: Pilwon Huh <pilwon@gmail.com> Test Plan: ./runJestTests start app and click around
Summary: This PR improves performance of `react-packager` by switching the promises library from the [Q](https://github.com/kriskowal/q) to [Bluebird](https://github.com/petkaantonov/bluebird). [Here is the test result](facebook#361 (comment)) showing a noticeable difference. (2x speed improvement) Please refer to [this issue](facebook#361) for more details. Closes facebook#516 Github Author: Pilwon Huh <pilwon@gmail.com> Test Plan: ./runJestTests start app and click around
Summary: This PR improves performance of `react-packager` by switching the promises library from the [Q](https://github.com/kriskowal/q) to [Bluebird](https://github.com/petkaantonov/bluebird). [Here is the test result](facebook#361 (comment)) showing a noticeable difference. (2x speed improvement) Please refer to [this issue](facebook#361) for more details. Closes facebook#516 Github Author: Pilwon Huh <pilwon@gmail.com> Test Plan: ./runJestTests start app and click around
fixed |
Summary: This PR improves performance of `react-packager` by switching the promises library from the [Q](https://github.com/kriskowal/q) to [Bluebird](https://github.com/petkaantonov/bluebird). [Here is the test result](facebook/react-native#361 (comment)) showing a noticeable difference. (2x speed improvement) Please refer to [this issue](facebook/react-native#361) for more details. Closes facebook/react-native#516 Github Author: Pilwon Huh <pilwon@gmail.com> Test Plan: ./runJestTests start app and click around
Q is very slow and eats so much memory compared to alternative Promises libraries as shown here.
Consider switching to Bluebird or something else to squeeze out performance for
react-packager
.The text was updated successfully, but these errors were encountered: