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/websocket/01_websocket.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ext/websocket/01_websocket.js') diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js index 03a6427c2..cadd35a50 100644 --- a/ext/websocket/01_websocket.js +++ b/ext/websocket/01_websocket.js @@ -301,7 +301,7 @@ class WebSocket extends EventTarget { const sendTypedArray = (ta) => { this[_bufferedAmount] += ta.byteLength; PromisePrototypeThen( - core.opAsync("op_ws_send_binary", this[_rid], ta), + core.opAsync2("op_ws_send_binary", this[_rid], ta), () => { this[_bufferedAmount] -= ta.byteLength; }, @@ -322,7 +322,7 @@ class WebSocket extends EventTarget { const d = core.encode(string); this[_bufferedAmount] += d.byteLength; PromisePrototypeThen( - core.opAsync("op_ws_send_text", this[_rid], string), + core.opAsync2("op_ws_send_text", this[_rid], string), () => { this[_bufferedAmount] -= d.byteLength; }, @@ -394,7 +394,7 @@ class WebSocket extends EventTarget { async [_eventLoop]() { while (this[_readyState] !== CLOSED) { - const { 0: kind, 1: value } = await core.opAsync( + const { 0: kind, 1: value } = await core.opAsync2( "op_ws_next_event", this[_rid], ); -- cgit v1.2.3