diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-04-13 14:32:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 14:32:47 +0200 |
commit | 702284dc2268eae565778b8b522ba534d7d48580 (patch) | |
tree | 9fbd5ee7f0b31643363399ce25df830fb62e1be8 /ops/optimizer_tests | |
parent | e39bc959c160e2af947034bd183b010a747e6b88 (diff) |
perf(ops): directly respond for eager ops (#18683)
This commit changes "eager ops" to directly return a response value
instead of calling "opresponse" callback in JavaScript. This saves
one boundary crossing and has a fantastic impact on the "async_ops.js"
benchmark:
```
v1.32.4
$ deno run cli/bench/async_ops.js
time 329 ms rate 3039513
time 322 ms rate 3105590
time 307 ms rate 3257328
time 301 ms rate 3322259
time 303 ms rate 3300330
time 306 ms rate 3267973
time 300 ms rate 3333333
time 301 ms rate 3322259
time 301 ms rate 3322259
time 301 ms rate 3322259
time 302 ms rate 3311258
time 301 ms rate 3322259
time 302 ms rate 3311258
time 302 ms rate 3311258
time 303 ms rate 3300330
```
```
this branch
$ ./target/release/deno run -A cli/bench/async_ops.js
time 257 ms rate 3891050
time 248 ms rate 4032258
time 251 ms rate 3984063
time 246 ms rate 4065040
time 238 ms rate 4201680
time 227 ms rate 4405286
time 228 ms rate 4385964
time 229 ms rate 4366812
time 228 ms rate 4385964
time 226 ms rate 4424778
time 226 ms rate 4424778
time 227 ms rate 4405286
time 228 ms rate 4385964
time 227 ms rate 4405286
time 228 ms rate 4385964
time 227 ms rate 4405286
time 229 ms rate 4366812
time 228 ms rate 4385964
```
Prerequisite for https://github.com/denoland/deno/pull/18652
Diffstat (limited to 'ops/optimizer_tests')
-rw-r--r-- | ops/optimizer_tests/async_nop.out | 5 | ||||
-rw-r--r-- | ops/optimizer_tests/async_result.out | 5 | ||||
-rw-r--r-- | ops/optimizer_tests/issue16934.out | 5 | ||||
-rw-r--r-- | ops/optimizer_tests/issue16934_fast.out | 5 |
4 files changed, 16 insertions, 4 deletions
diff --git a/ops/optimizer_tests/async_nop.out b/ops/optimizer_tests/async_nop.out index 5d73f2343..7782b5970 100644 --- a/ops/optimizer_tests/async_nop.out +++ b/ops/optimizer_tests/async_nop.out @@ -79,7 +79,7 @@ impl op_void_async { state.tracker.track_async(op_id); state.get_error_class_fn }; - deno_core::_ops::queue_async_op( + let maybe_response = deno_core::_ops::queue_async_op( ctx, scope, false, @@ -94,6 +94,9 @@ impl op_void_async { ) }, ); + if let Some(response) = maybe_response { + rv.set(response); + } } } #[allow(clippy::too_many_arguments)] diff --git a/ops/optimizer_tests/async_result.out b/ops/optimizer_tests/async_result.out index f820687cd..c3bb433f1 100644 --- a/ops/optimizer_tests/async_result.out +++ b/ops/optimizer_tests/async_result.out @@ -90,7 +90,7 @@ impl op_async_result { state.tracker.track_async(op_id); state.get_error_class_fn }; - deno_core::_ops::queue_async_op( + let maybe_response = deno_core::_ops::queue_async_op( ctx, scope, false, @@ -104,6 +104,9 @@ impl op_async_result { ) }, ); + if let Some(response) = maybe_response { + rv.set(response); + } } } #[allow(clippy::too_many_arguments)] diff --git a/ops/optimizer_tests/issue16934.out b/ops/optimizer_tests/issue16934.out index f8acf5712..68f59ef43 100644 --- a/ops/optimizer_tests/issue16934.out +++ b/ops/optimizer_tests/issue16934.out @@ -84,7 +84,7 @@ impl send_stdin { state.tracker.track_async(op_id); state.get_error_class_fn }; - deno_core::_ops::queue_async_op( + let maybe_response = deno_core::_ops::queue_async_op( ctx, scope, false, @@ -102,5 +102,8 @@ impl send_stdin { ) }, ); + if let Some(response) = maybe_response { + rv.set(response); + } } } diff --git a/ops/optimizer_tests/issue16934_fast.out b/ops/optimizer_tests/issue16934_fast.out index 0cdc3eb25..7a4a39f34 100644 --- a/ops/optimizer_tests/issue16934_fast.out +++ b/ops/optimizer_tests/issue16934_fast.out @@ -82,7 +82,7 @@ impl send_stdin { state.tracker.track_async(op_id); state.get_error_class_fn }; - deno_core::_ops::queue_async_op( + let maybe_response = deno_core::_ops::queue_async_op( ctx, scope, false, @@ -100,5 +100,8 @@ impl send_stdin { ) }, ); + if let Some(response) = maybe_response { + rv.set(response); + } } } |