Skip to content
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

Perfs #132

Merged
merged 1 commit into from Nov 26, 2013
Merged

Perfs #132

merged 1 commit into from Nov 26, 2013

Conversation

stefanpenner
Copy link
Collaborator

Micro benchmarks FTW.

This is a bit ongoing, but i wanted to see how much juice I could squeeze out of RSVP, fun experiment.
Interestingly accordingly to these very important micro benchmarks, RSVP is now relatively quick. In node bluebird still often takes the lead (not to mention it likely has improved memory usage over RSVP) so we have some work todo. Interestingly in the browser, RSVP now comes up ahead, putting chrome's own native DOM Promises to shame.

notes to: @petkaantonov before he gets worried

  • (don't worry bluebird is still faster in node/IRL)
  • yes the server side performance has more impact that client side.

using: https://github.com/stefanpenner/promise_benchmarks
side-note: I hope to add some more real-life scenarios to that benchmark suite.

  • basic benchmarks
  • initial easy improvements.
  • make travis happy.
  • test in more browsers
  • edited for fix bluebirds long stack traces being on in the browser build
    Chrome 33
Running Tests for Promise Creation ... promise_benchmarks.amd.js:330
- [Promise Creation] dom x 115,313 ops/sec ±7.25% (51 runs sampled)
- [Promise Creation] when x 5,383,836 ops/sec ±3.33% (59 runs sampled)
- [Promise Creation] bluebird x 6,447,872 ops/sec ±5.08% (56 runs sampled)
- [Promise Creation] rsvp-2.0.4 x 330,662 ops/sec ±6.79% (50 runs sampled)
- [Promise Creation] rsvp x 8,734,347 ops/sec ±7.02% (54 runs sampled)
Fastest for Promise Creation is ["rsvp"] promise_benchmarks.amd.js:288
Running Tests for Promise Rejection ... promise_benchmarks.amd.js:330
- [Promise Rejection] dom x 12,091 ops/sec ±5.05% (57 runs sampled)
- [Promise Rejection] when x 17,294 ops/sec ±6.48% (48 runs sampled)
- [Promise Rejection] bluebird x 18,681 ops/sec ±7.25% (52 runs sampled)
- [Promise Rejection] rsvp-2.0.4 x 12,704 ops/sec ±6.92% (53 runs sampled)
- [Promise Rejection] rsvp x 18,880 ops/sec ±8.70% (44 runs sampled)
Fastest for Promise Rejection is ["bluebird", "rsvp"] promise_benchmarks.amd.js:288
Running Tests for Promise Resolve: value ... promise_benchmarks.amd.js:330
- [Promise Resolve: value] dom x 12,991 ops/sec ±5.22% (56 runs sampled)
- [Promise Resolve: value] when x 17,248 ops/sec ±5.99% (47 runs sampled)
- [Promise Resolve: value] bluebird x 20,152 ops/sec ±4.77% (53 runs sampled)
- [Promise Resolve: value] rsvp-2.0.4 x 13,754 ops/sec ±5.36% (47 runs sampled)
- [Promise Resolve: value] rsvp x 23,168 ops/sec ±4.52% (52 runs sampled)
Fastest for Promise Resolve: value is ["rsvp"] promise_benchmarks.amd.js:288
Running Tests for Resolve Promise: promise ... promise_benchmarks.amd.js:330
- [Resolve Promise: promise] dom x 12,715 ops/sec ±3.86% (56 runs sampled)
- [Resolve Promise: promise] when x 18,345 ops/sec ±4.98% (50 runs sampled)
- [Resolve Promise: promise] bluebird x 21,023 ops/sec ±5.29% (53 runs sampled)
- [Resolve Promise: promise] rsvp-2.0.4 x 3,179 ops/sec ±27.57% (22 runs sampled)
- [Resolve Promise: promise] rsvp x 19,158 ops/sec ±5.41% (50 runs sampled)
Fastest for Resolve Promise: promise is ["bluebird"] promise_benchmarks.amd.js:288
Running Tests for Then Sequence 1 ... promise_benchmarks.amd.js:330
- [Then Sequence 1] dom x 15,474 ops/sec ±4.81% (53 runs sampled)
- [Then Sequence 1] when x 16,399 ops/sec ±6.11% (49 runs sampled)
- [Then Sequence 1] bluebird x 19,199 ops/sec ±4.49% (53 runs sampled)
- [Then Sequence 1] rsvp-2.0.4 x 3,749 ops/sec ±28.29% (31 runs sampled)
- [Then Sequence 1] rsvp x 19,569 ops/sec ±5.54% (48 runs sampled)
Fastest for Then Sequence 1 is ["rsvp", "bluebird"] promise_benchmarks.amd.js:288
Running Tests for Then Sequence 2 ... promise_benchmarks.amd.js:330
- [Then Sequence 2] dom x 14,056 ops/sec ±4.88% (55 runs sampled)
- [Then Sequence 2] when x 14,004 ops/sec ±5.84% (51 runs sampled)
- [Then Sequence 2] bluebird x 18,229 ops/sec ±6.76% (51 runs sampled)
- [Then Sequence 2] rsvp-2.0.4 x 3,493 ops/sec ±26.75% (29 runs sampled)
- [Then Sequence 2] rsvp x 18,707 ops/sec ±7.08% (48 runs sampled)
Fastest for Then Sequence 2 is ["rsvp", "bluebird"] promise_benchmarks.amd.js:288
Running Tests for Then Sequence 10 ... promise_benchmarks.amd.js:330
- [Then Sequence 10] dom x 12,347 ops/sec ±5.85% (59 runs sampled)
- [Then Sequence 10] when x 7,776 ops/sec ±10.67% (45 runs sampled)
- [Then Sequence 10] bluebird x 16,660 ops/sec ±6.54% (52 runs sampled)
- [Then Sequence 10] rsvp-2.0.4 x 4,277 ops/sec ±11.01% (40 runs sampled)
- [Then Sequence 10] rsvp x 15,345 ops/sec ±6.98% (49 runs sampled)
Fastest for Then Sequence 10 is ["bluebird", "rsvp"] promise_benchmarks.amd.js:288
Running Tests for Then Sequence 100 ... promise_benchmarks.amd.js:330
- [Then Sequence 100] dom x 4,075 ops/sec ±5.63% (54 runs sampled)
- [Then Sequence 100] when x 1,589 ops/sec ±14.34% (37 runs sampled)
- [Then Sequence 100] bluebird x 11,038 ops/sec ±8.42% (51 runs sampled)
- [Then Sequence 100] rsvp-2.0.4 x 568 ops/sec ±11.40% (43 runs sampled)
- [Then Sequence 100] rsvp x 4,914 ops/sec ±13.17% (47 runs sampled)
Fastest for Then Sequence 100 is ["bluebird"] 

Node v0.10.21

> promise_benchmarks@ start /Users/stefan/src/promise_benchmarks
> npm build && node index

Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Promise Creation ...
   - [Promise Creation] rsvp x 10,092,983 ops/sec ±1.69% (82 runs sampled)
   - [Promise Creation] rsvp-2.0.4 x 509,287 ops/sec ±2.39% (75 runs sampled)
   - [Promise Creation] bluebird x 5,984,504 ops/sec ±3.91% (75 runs sampled)
   - [Promise Creation] when x 5,750,027 ops/sec ±2.56% (78 runs sampled)
Fastest for Promise Creation is [ 'rsvp' ]


Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Promise Rejection ...
   - [Promise Rejection] rsvp x 54,269 ops/sec ±2.80% (64 runs sampled)
   - [Promise Rejection] rsvp-2.0.4 x 24,179 ops/sec ±4.22% (63 runs sampled)
   - [Promise Rejection] bluebird x 49,933 ops/sec ±3.87% (66 runs sampled)
   - [Promise Rejection] when x 39,552 ops/sec ±5.28% (54 runs sampled)
Fastest for Promise Rejection is [ 'rsvp' ]


Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Promise Resolve: value ...
   - [Promise Resolve: value] rsvp x 51,517 ops/sec ±3.24% (66 runs sampled)
   - [Promise Resolve: value] rsvp-2.0.4 x 26,344 ops/sec ±2.76% (58 runs sampled)
   - [Promise Resolve: value] bluebird x 53,605 ops/sec ±2.53% (66 runs sampled)
   - [Promise Resolve: value] when x 38,942 ops/sec ±2.84% (60 runs sampled)
Fastest for Promise Resolve: value is [ 'bluebird', 'rsvp' ]


Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Resolve Promise: promise ...
   - [Resolve Promise: promise] rsvp x 46,669 ops/sec ±1.86% (63 runs sampled)
   - [Resolve Promise: promise] rsvp-2.0.4 x 2,745 ops/sec ±45.04% (15 runs sampled)
   - [Resolve Promise: promise] bluebird x 44,776 ops/sec ±4.11% (64 runs sampled)
   - [Resolve Promise: promise] when x 33,140 ops/sec ±4.80% (58 runs sampled)
Fastest for Resolve Promise: promise is [ 'rsvp', 'bluebird' ]


Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Then Sequence 1 ...
   - [Then Sequence 1] rsvp x 48,692 ops/sec ±4.92% (52 runs sampled)
   - [Then Sequence 1] rsvp-2.0.4 x 3,023 ops/sec ±49.28% (13 runs sampled)
   - [Then Sequence 1] bluebird x 47,615 ops/sec ±5.30% (62 runs sampled)
   - [Then Sequence 1] when x 38,917 ops/sec ±7.27% (60 runs sampled)
Fastest for Then Sequence 1 is [ 'rsvp', 'bluebird' ]


Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Then Sequence 2 ...
   - [Then Sequence 2] rsvp x 43,842 ops/sec ±5.59% (60 runs sampled)
   - [Then Sequence 2] rsvp-2.0.4 x 2,765 ops/sec ±38.52% (18 runs sampled)
   - [Then Sequence 2] bluebird x 44,832 ops/sec ±11.06% (57 runs sampled)
   - [Then Sequence 2] when x 29,350 ops/sec ±9.32% (59 runs sampled)
Fastest for Then Sequence 2 is [ 'rsvp' ]


Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Then Sequence 10 ...
   - [Then Sequence 10] rsvp x 25,306 ops/sec ±15.29% (58 runs sampled)
   - [Then Sequence 10] rsvp-2.0.4 x 6,124 ops/sec ±15.31% (53 runs sampled)
   - [Then Sequence 10] bluebird x 42,072 ops/sec ±9.00% (62 runs sampled)
   - [Then Sequence 10] when x 10,591 ops/sec ±18.43% (35 runs sampled)
Fastest for Then Sequence 10 is [ 'bluebird' ]


Queueing Tests for rsvp, rsvp-2.0.4, bluebird, when ...
Running Tests for Then Sequence 100 ...
   - [Then Sequence 100] rsvp x 5,954 ops/sec ±15.62% (53 runs sampled)
   - [Then Sequence 100] rsvp-2.0.4 x 741 ops/sec ±14.78% (51 runs sampled)
   - [Then Sequence 100] bluebird x 21,832 ops/sec ±11.58% (69 runs sampled)
   - [Then Sequence 100] when x 880 ops/sec ±25.98% (27 runs sampled)
Fastest for Then Sequence 100 is [ 'bluebird' ]

@teddyzeenny
Copy link
Contributor

Awesome!! 👍

@petkaantonov
Copy link

Haha :)

});

describe("rejected promise", function(){
it("progoates changes via throw", function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"propagates"

- custom pub-sub for propogate state changes instead of event emitter
- minimize closure allocations.
- as we only need to publish once, cleanup subscribers after publish
stefanpenner added a commit that referenced this pull request Nov 26, 2013
@stefanpenner stefanpenner merged commit 2d0a517 into tildeio:master Nov 26, 2013
@stefanpenner stefanpenner deleted the perf branch November 26, 2013 04:52
@spion
Copy link

spion commented Nov 28, 2013

Well, it turned out that bluebird was running in the browser with longStackTraces turned on by default (not in node though). Latest build (v0.10.10) disables them, which should result with absolutely massive improvements for the browser benchmarks (perhaps 50-100x).

@stefanpenner
Copy link
Collaborator Author

@spion I had my suspicion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants