diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2018-01-05 17:03:10 +0300 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-01-09 18:43:00 +0300 |
commit | fbad8bb1fa04bd47fdcc430a75a36c90ee996f09 (patch) | |
tree | 4fc9bb0fc69e72bc2ae6c0efca5d72148d43c07d /lib/internal/async_hooks.js | |
parent | 5a1aeab2dbe22be141579181c3381831d516182c (diff) |
async_hooks: update defaultTriggerAsyncIdScope for perf
The existing version of defaultTriggerAsyncIdScope creates an Array
for the callback's arguments which is highly inefficient. Instead,
use rest syntax and allow V8 to do that work for us. This yields
roughly 2x performance for this particular function.
PR-URL: https://github.com/nodejs/node/pull/18004
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib/internal/async_hooks.js')
-rw-r--r-- | lib/internal/async_hooks.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 7d99985dd11..801d90b7f50 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -260,7 +260,7 @@ function getDefaultTriggerAsyncId() { } -function defaultTriggerAsyncIdScope(triggerAsyncId, opaque, block) { +function defaultTriggerAsyncIdScope(triggerAsyncId, block, ...args) { // CHECK(Number.isSafeInteger(triggerAsyncId)) // CHECK(triggerAsyncId > 0) const oldDefaultTriggerAsyncId = async_id_fields[kDefaultTriggerAsyncId]; @@ -268,7 +268,7 @@ function defaultTriggerAsyncIdScope(triggerAsyncId, opaque, block) { var ret; try { - ret = Reflect.apply(block, null, opaque); + ret = Reflect.apply(block, null, args); } finally { async_id_fields[kDefaultTriggerAsyncId] = oldDefaultTriggerAsyncId; } |