- Communicate the current async stack length through a
typed array field rather than a native binding method
- Add a new fixed-size `async_ids_fast_stack` typed array
that contains the async ID stack up to a fixed limit.
This increases performance noticeably, since most of the time
the async ID stack will not be more than a handful of
levels deep.
- Make the JS `pushAsyncIds()` and `popAsyncIds()` functions
do the same thing as the native ones if the fast path
is applicable.
Benchmarks:
$ ./node benchmark/compare.js --new ./node --old ./node-master --runs 10 --filter next-tick process | Rscript benchmark/compare.R
[00:03:25|% 100| 6/6 files | 20/20 runs | 1/1 configs]: Done
improvement confidence p.value
process/next-tick-breadth-args.js millions=4 19.72 % *** 3.013913e-06
process/next-tick-breadth.js millions=4 27.33 % *** 5.847983e-11
process/next-tick-depth-args.js millions=12 40.08 % *** 1.237127e-13
process/next-tick-depth.js millions=12 77.27 % *** 1.413290e-11
process/next-tick-exec-args.js millions=5 13.58 % *** 1.245180e-07
process/next-tick-exec.js millions=5 16.80 % *** 2.961386e-07
PR-URL: https://github.com/nodejs/node/pull/17780
Reviewed-By: James M Snell <jasnell@gmail.com>
Is safer to use a `process.binding(config)` defined boolean, than to
regex on `process.execArgv`. Also, this better falls in line with the
conventions of checking flags passed to the executable.
PR-URL: https://github.com/nodejs/node/pull/17814
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Previously the getter would mutate the kDefaultTriggerAsncId value. This
refactor changes the setter to bind the current kDefaultTriggerAsncId to
a scope, such that the getter doesn't have to mutate its own value.
PR-URL: https://github.com/nodejs/node/pull/17273
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
When context is missing the executionAsyncId will be zero. For the
default triggerAsyncId the zero value was used to default to the
executionAsyncId. While this was not technically wrong because the
functions are different themself, it poorly separated the two concepts.
PR-URL: https://github.com/nodejs/node/pull/17273
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
rename initTriggerId to defaultTriggerAsyncId such it matches the rest
of our naming.
PR-URL: https://github.com/nodejs/node/pull/17273
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>