You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Promise performance drop between v8 7.4 and 7.5 #33384
I was doing some benchmark about promises performances and I noticed a performance drop in traditional promises (then/catch) between Node.js 10 and Node.js 12.
With further investigation I'm now able to say that the performance drop occur between v8 7.4 (Node.js 12.0.0) and v8 7.5 (Node.js 12.5.0).
The performance drop is still present in recent version of v8 (tested with v8 8.1 on Node.js 14.2.0)
Promises are between 3x and 5x slower in v8 7.5 than in v8 7.4 and they are still 2x slower in v8 8.1
Do you have any idea why?
If we look at the bigger picture, we can see that promise performance were much more better at some point (Node.js 10) and then start to deteriorate
FYI, to underly my comment about measuring the right thing:
Commenting out the memMax = Math.max(memMax, process.memoryUsage().rss); line in performance.js makes the benchmark run 3x faster in node v12.5.
Hey, I totally missed this issue - cool investigation I'll take a look at the bluebird issue.
Note that:
V8 has their own forked version of the bluebird benchmark (which I think @bmerurer made?), IMO it's slightly worse (because it doesn't measure the overhead of promisification) but it's probably more maintained.
These benchmarks haven't been updated on the bluebird side in ~5 years and were written for CrankShaft (the old JIT), it (and bluebird) make a lot of (now incorrect) assumptions regarding how the benchmarks are run and I would not want people to use them as an authoritative source. It's kind of shameful Doxbee is still the best we have for this in non-micro-benchmark land.
I'm also a Node member - and there are lots of promise performance and debugging tasks Node needs helps with :]
If you want to add a promise performance benchmark to Node core that we run to detect regressions that could be a good place to contribute - though not where I'd start.
We've been trying to get people to use native promises (and improve those!) where possible.
Promises are generally "fast enough" for most use cases afaict.
The cause of the issue has been identified: the process.memoryUsage().rss iterate on every pages and the size of allocated pages has been divided by to between v8 7.4 and 7.5 so iterating over the pages to compute memory usage statistics is much more longer.
A new fast access to the rss has been implemented and will land on the next Node.js release: process.memoryUsage.rss()
Activity
mscdex commentedon May 13, 2020
Out of curiosity, did you try the master branch, which now has V8 8.3?
targos commentedon May 13, 2020
The following download has V8 8.3 if you want to test it: https://nodejs.org/download/nightly/v15.0.0-nightly202005135bb4d01fbe/
Aschen commentedon May 14, 2020
@mscdex I updated the benchmark and the script to use the version @targos linked and the results are worse with the latest version of Node.js / v8
Aschen commentedon May 21, 2020
This issue is being addressed here https://bugs.chromium.org/p/v8/issues/detail?id=10550
camillobruni commentedon Jul 9, 2020
After some investigation I found the root cause: V8 changed the default page size from 512 KiB (v7.4) to 256 KiB (v7.5)
Some background:
process.memoryUsage()Take-away:
camillobruni commentedon Jul 9, 2020
FYI, to underly my comment about measuring the right thing:
Commenting out the
memMax = Math.max(memMax, process.memoryUsage().rss);line inperformance.jsmakes the benchmark run 3x faster in node v12.5.Aschen commentedon Jul 10, 2020
Thanks you very much @camillobruni for all these explanations!
I submitted a PR in Bluebird to fix those benchmarks and another one in Node.js to add a direct access to the rss.
Also updated the original article at https://blog.kuzzle.io/bluebird-native-async_await-javascript-promises-performances-2020
Leodau commentedon Jul 10, 2020
@ryzokuken
benjamingr commentedon Jul 10, 2020
Hey, I totally missed this issue - cool investigation I'll take a look at the bluebird issue.
Note that:
mmarchini commentedon Jul 30, 2020
@benjamingr I believe you're referring to these benchmarks?
process: add direct access to rss without iterating pages
Aschen commentedon Jan 10, 2021
The cause of the issue has been identified: the
process.memoryUsage().rssiterate on every pages and the size of allocated pages has been divided by to between v8 7.4 and 7.5 so iterating over the pages to compute memory usage statistics is much more longer.A new fast access to the rss has been implemented and will land on the next Node.js release:
process.memoryUsage.rss()process: add direct access to rss without iterating pages
process: add direct access to rss without iterating pages
process: add direct access to rss without iterating pages
process: add direct access to rss without iterating pages