async_hooks: optimize fast-path promise hook for ALS

Remove unnecessary native-to-JS code switches in fast-path for
PromiseHooks. Those switches happen even if a certain type of
hook (say, before) is not installed, which may lead to sub-optimal
performance in the AsyncLocalStorage scenario, i.e. when there is
only an init hook.

PR-URL: https://github.com/nodejs/node/pull/34512
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
This commit is contained in:
Andrey Pechkurov committed 2020-07-28 10:54:01 +03:00
1 parent 6fd09e4f36
commit 53870ddeac
2 files changed
+65 -7

No files matched your search

+6
View File
@@ -19,6 +19,11 @@ const tests = {
promiseResolve() {},
destroy() {}
}).enable();
},
enabledWithInitOnly() {
hook = createHook({
init() {}
}).enable();
}
};
@@ -27,6 +32,7 @@ const bench = common.createBenchmark(main, {
asyncHooks: [
'enabled',
'enabledWithDestroy',
'enabledWithInitOnly',
'disabled',
]
});