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/lib.deno_core.d.ts | |
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/lib.deno_core.d.ts')
-rw-r--r-- | core/lib.deno_core.d.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/core/lib.deno_core.d.ts b/core/lib.deno_core.d.ts index bd3729ed9..c5662794a 100644 --- a/core/lib.deno_core.d.ts +++ b/core/lib.deno_core.d.ts @@ -10,15 +10,13 @@ declare namespace Deno { /** Call an op in Rust, and synchronously receive the result. */ function opSync( opName: string, - a?: any, - b?: any, + ...args: any[] ): any; /** Call an op in Rust, and asynchronously receive the result. */ function opAsync( opName: string, - a?: any, - b?: any, + ...args: any[] ): Promise<any>; /** Mark following promise as "ref", ie. event loop won't exit @@ -30,10 +28,10 @@ declare namespace Deno { function unrefOps(promiseId: number): void; /** - * Retrieve a list of all registered ops, in the form of a map that maps op + * List of all registered ops, in the form of a map that maps op * name to internal numerical op id. */ - function ops(): Record<string, number>; + const ops: Record<string, (...args: unknown[]) => any>; /** * Retrieve a list of all open resources, in the form of a map that maps |