async_hooks: improve resource stack performance
Removes some of the performance overhead that came with
executionAsyncResource()
by storing async resources that
are managed by JS and those managed by C++ separately, and
instead caching the result of executionAsyncResource()
with
low overhead to avoid multiple calls into C++.
This particularly improves performance when async hooks are not being used.
$ ./node benchmark/compare.js --new ./node --old ./node-master --runs 30 --filter messageport worker | Rscript benchmark/compare.R
[00:04:41|% 100| 1/1 files | 60/60 runs | 2/2 configs]: Done
confidence improvement accuracy (*) (**) (***)
worker/messageport.js n=1000000 payload='object' * 8.85 % ±7.40% ±9.85% ±12.83%
worker/messageport.js n=1000000 payload='string' *** 18.56 % ±8.37% ±11.13% ±14.49%
(I’ll also try to run the async_hooks
benchmarks, but they are failing locally for me on master – hence only the ones for MessagePorts as another measure.)
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines