From aa9b94a80eadde7737417eb7d412559bc567c77c Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 31 Mar 2023 21:28:21 +0530 Subject: perf(ext/websocket): use opAsync2 to avoid spread deopt (#18525) This commit adds a new core API `opAsync2` to call an async op with atmost 2 arguments. Spread argument iterators has a pretty big perf hit when calling ops. | name | avg msg/sec/core | | --- | --- | | 1.32.1 | `127820.750000` | | #18506 | `140079.000000` | | #18506 + #18509 | `150104.250000` | | #18506 + #18509 + this | `157340.000000` | --- ext/fs/30_fs.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ext/fs') diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index a8ae7ad3a..500416980 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -31,7 +31,7 @@ function chmodSync(path, mode) { } async function chmod(path, mode) { - await core.opAsync("op_chmod_async", pathFromURL(path), mode); + await core.opAsync2("op_chmod_async", pathFromURL(path), mode); } function chownSync( @@ -121,7 +121,7 @@ async function mkdir( path, options, ) { - await core.opAsync("op_mkdir_async", mkdirArgs(path, options)); + await core.opAsync2("op_mkdir_async", mkdirArgs(path, options)); } function readDirSync(path) { @@ -349,7 +349,7 @@ function ftruncateSync(rid, len) { } async function ftruncate(rid, len) { - await core.opAsync("op_ftruncate_async", rid, coerceLen(len)); + await core.opAsync2("op_ftruncate_async", rid, coerceLen(len)); } function truncateSync(path, len) { @@ -357,7 +357,7 @@ function truncateSync(path, len) { } async function truncate(path, len) { - await core.opAsync("op_truncate_async", path, coerceLen(len)); + await core.opAsync2("op_truncate_async", path, coerceLen(len)); } function umask(mask) { @@ -369,7 +369,7 @@ function linkSync(oldpath, newpath) { } async function link(oldpath, newpath) { - await core.opAsync("op_link_async", oldpath, newpath); + await core.opAsync2("op_link_async", oldpath, newpath); } function toUnixTimeFromEpoch(value) { @@ -499,7 +499,7 @@ function flockSync(rid, exclusive) { } async function flock(rid, exclusive) { - await core.opAsync("op_flock_async", rid, exclusive === true); + await core.opAsync2("op_flock_async", rid, exclusive === true); } function funlockSync(rid) { -- cgit v1.2.3