diff options
author | Luca Casonato <hello@lcas.dev> | 2023-09-16 07:48:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-16 07:48:31 +0200 |
commit | 430b63c2c4d6567a77e77980058ef13b45a9f30e (patch) | |
tree | 714fef4813a5614ccdd17b681f30e3bd0b4057bd /ext/broadcast_channel/01_broadcast_channel.js | |
parent | bf0760411336ce5ebb1c103f766c8154af478414 (diff) |
perf: improve async op santizer speed and accuracy (#20501)
This commit improves async op sanitizer speed by only delaying metrics
collection if there are pending ops. This
results in a speedup of around 30% for small CPU bound unit tests.
It performs this check and possible delay on every collection now,
fixing an issue with parent test leaks into steps.
Diffstat (limited to 'ext/broadcast_channel/01_broadcast_channel.js')
-rw-r--r-- | ext/broadcast_channel/01_broadcast_channel.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/broadcast_channel/01_broadcast_channel.js b/ext/broadcast_channel/01_broadcast_channel.js index ab315eaa6..e5e4169b6 100644 --- a/ext/broadcast_channel/01_broadcast_channel.js +++ b/ext/broadcast_channel/01_broadcast_channel.js @@ -15,8 +15,9 @@ import DOMException from "ext:deno_web/01_dom_exception.js"; const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeIndexOf, - ArrayPrototypeSplice, ArrayPrototypePush, + ArrayPrototypeSplice, + PromisePrototypeThen, Symbol, Uint8Array, } = primordials; @@ -70,7 +71,7 @@ function dispatch(source, name, data) { // for that reason: it lets promises make forward progress but can // still starve other parts of the event loop. function defer(go) { - setTimeout(go, 1); + PromisePrototypeThen(core.ops.op_void_async_deferred(), () => go()); } class BroadcastChannel extends EventTarget { |