Closed Bug 1152875 Opened 9 years ago Closed 6 years ago

Gecko DOM Promises are slower than bluebird Promise library on streams benchmark

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bkelly, Unassigned)

References

(Depends on 2 open bugs, )

Details

While benchmarking some "promise vs no-promise" spec questions for streams API, I wrote a small benchmark tool:

  https://github.com/wanderview/streams-promise-read

The index.html runs with native promises while bluebird.html uses the bluebird promise library.

When you increase the number of chunks in the test high enough, you can see some non-trivial differences in speed between our native promises and bluebird.

Native
------
1000 chunks:
"sync x 119 ops/sec ±27.87% (23 runs sampled)" test.js:14:3
"promise x 26.71 ops/sec ±2.97% (60 runs sampled)" test.js:14:3

10000 chunks:
"sync x 35.56 ops/sec ±20.20% (21 runs sampled)" test.js:14:3
"promise x 2.80 ops/sec ±8.60% (17 runs sampled)" test.js:14:3

Bluebird:
---------
1000 chunks:
"sync x 146 ops/sec ±16.29% (36 runs sampled)" test.js:14:3
"promise x 96.67 ops/sec ±4.96% (68 runs sampled)" test.js:14:3

10000 chunks:
"sync x 40.54 ops/sec ±21.98% (32 runs sampled)" test.js:14:3
"promise x 21.55 ops/sec ±5.12% (53 runs sampled)" test.js:14:3

Only 2.8 ops/sec for native promises vs 21.5 ops/sec for bluebird.  Thats a pretty large performance difference.

Note, you must checkout the test and tweak the values to test 10,000 chunks.
Depends on: 1152902
Depends on: 1152893
Depends on: 1152930
Depends on: 1156797
Running the benchmark, i get :

https://blog.wanderview.com/streams-promise-read/bluebird.html?chunks=10000&size=1
---------------
Testing 10000 chunks of 1 bytes per operation.
promise x 2.31 ops/sec ±8.30% (16 runs sampled)
Fastest is promise

https://blog.wanderview.com/streams-promise-read/native.html?chunks=10000&size=1
---------------
Testing 10000 chunks of 1 bytes per operation.
promise x 10.79 ops/sec ±3.12% (49 runs sampled)
Fastest is promise

I feel this means native promises have gotten better
RESOLVED WORKFORME
Sorry, i meant this to be a question

> RESOLVED WORKFORME

?
Yeah, I get similar results. Promise scheduling uses now microtasks and IIRC we also optimize out unused tail Promises, or what to call them.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.