refactor(core): limit number of boundary crossings between Rust and V8 (#18652)

This commit refactors "deno_core" to do fewer boundary crossings
from Rust to V8. In other words we are now calling V8 from Rust fewer
times.

This is done by merging 3 distinct callbacks into a single one. Instead
of having "op resolve" callback, "next tick" callback and "macrotask
queue" callback, we now have only "Deno.core.eventLoopTick" callback,
which is responsible for doing the same actions previous 3 callbacks.

On each of the event loop we were doing at least 2 boundary crosses
(timers macrotask queue callback and unhandled promise rejection
callback) and up to 4 crosses if there were op response and next tick
callbacks coming from Node.js compatibility layer. Now this is all done
in a single callback.

Closes https://github.com/denoland/deno/issues/18620
This commit is contained in:
Bartek Iwańczuk 2023-04-14 02:41:32 +02:00 committed by GitHub
parent d192d84a0e
commit cb2ca234bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 126 additions and 173 deletions

View file

@ -6,3 +6,4 @@ error: Uncaught (in worker "") Error
at handleTimerMacrotask (ext:deno_web/02_timers.js:[WILDCARD])
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl (ext:runtime/11_workers.js:[WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -1,3 +1,3 @@
[WILDCARD]error: Uncaught (in worker "") Module not found "file:///[WILDCARD]/workers/doesnt_exist.js".
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at Worker.#pollControl[WILDCARD]

View file

@ -2,3 +2,4 @@ error: Uncaught (in worker "") Requires read access to "[WILDCARD]local_file.ts"
at blob:null/[WILDCARD]:1:8
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -2,3 +2,4 @@ error: Uncaught (in worker "") Requires net access to "example.com", run again w
at blob:null/[WILDCARD]:1:8
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -2,3 +2,4 @@ error: Uncaught (in worker "") Requires read access to "[WILDCARD]local_file.ts"
at data:application/javascript;base64,[WILDCARD]:1:8
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -2,3 +2,4 @@ error: Uncaught (in worker "") Requires net access to "example.com", run again w
at data:application/javascript;base64,aW1wb3J0ICJodHRwczovL2V4YW1wbGUuY29tL3NvbWUvZmlsZS50cyI7:1:8
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -4,3 +4,4 @@ await import("https://example.com/some/file.ts");
at async http://localhost:4545/workers/dynamic_remote.ts:2:1
[WILDCARD]error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -2,3 +2,4 @@ error: Uncaught (in worker "") Requires net access to "example.com", run again w
at http://localhost:4545/workers/static_remote.ts:2:8
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -5,3 +5,4 @@ error: Uncaught (in worker "foo") (in promise) Error: bar
at [WILDCARD]/async_error.ts:[WILDCARD]
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -3,3 +3,4 @@
at [WILDCARD]
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -5,3 +5,4 @@ error: Uncaught (in worker "foo") Error: bar
at [WILDCARD]
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])

View file

@ -5,5 +5,7 @@
at [WILDCARD]/workers/error.ts:[WILDCARD]
error: Uncaught (in worker "baz") (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl ([WILDCARD])
at eventLoopTick (ext:core/01_core.js:[WILDCARD])