diff options
author | Aapo Alasuutari <aapo.alasuutari@gmail.com> | 2022-08-11 16:56:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-11 15:56:56 +0200 |
commit | 2164f6b1eb7216c1045d547c94f26fe3ceaa9403 (patch) | |
tree | 056e3d6540ebd0e755650765adcff6b5cc173db8 /core/encode_decode_test.js | |
parent | 883269f1f183428f60c54223135d8dd25977b3cd (diff) |
perf(ops): Monomorphic sync op calls (#15337)
Welcome to better optimised op calls! Currently opSync is called with parameters of every type and count. This most definitely makes the call megamorphic. Additionally, it seems that spread params leads to V8 not being able to optimise the calls quite as well (apparently Fast Calls cannot be used with spread params).
Monomorphising op calls should lead to some improved performance. Now that unwrapping of sync ops results is done on Rust side, this is pretty simple:
```
opSync("op_foo", param1, param2);
// -> turns to
ops.op_foo(param1, param2);
```
This means sync op calls are now just directly calling the native binding function. When V8 Fast API Calls are enabled, this will enable those to be called on the optimised path.
Monomorphising async ops likely requires using callbacks and is left as an exercise to the reader.
Diffstat (limited to 'core/encode_decode_test.js')
-rw-r--r-- | core/encode_decode_test.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/encode_decode_test.js b/core/encode_decode_test.js index 5165b196c..663bc1af6 100644 --- a/core/encode_decode_test.js +++ b/core/encode_decode_test.js @@ -33,31 +33,31 @@ function main() { 108, 100 ]; - const empty = Deno.core.opSync("op_encode", ""); + const empty = Deno.core.ops.op_encode(""); if (empty.length !== 0) throw new Error("assert"); assertArrayEquals( - Array.from(Deno.core.opSync("op_encode", "𝓽𝓮𝔁𝓽")), + Array.from(Deno.core.ops.op_encode("𝓽𝓮𝔁𝓽")), fixture1, ); assertArrayEquals( - Array.from(Deno.core.opSync("op_encode", "Hello \udc12\ud834 World")), + Array.from(Deno.core.ops.op_encode("Hello \udc12\ud834 World")), fixture2, ); - const emptyBuf = Deno.core.opSync("op_decode", new Uint8Array(0)); + const emptyBuf = Deno.core.ops.op_decode(new Uint8Array(0)); if (emptyBuf !== "") throw new Error("assert"); - assert(Deno.core.opSync("op_decode", new Uint8Array(fixture1)) === "𝓽𝓮𝔁𝓽"); + assert(Deno.core.ops.op_decode(new Uint8Array(fixture1)) === "𝓽𝓮𝔁𝓽"); assert( - Deno.core.opSync("op_decode", new Uint8Array(fixture2)) === + Deno.core.ops.op_decode(new Uint8Array(fixture2)) === "Hello �� World", ); // See https://github.com/denoland/deno/issues/6649 let thrown = false; try { - Deno.core.opSync("op_decode", new Uint8Array(2 ** 29)); + Deno.core.ops.op_decode(new Uint8Array(2 ** 29)); } catch (e) { thrown = true; assert(e instanceof RangeError); |