From 4e04f9106a6dc64216e1969914d28cbd768d705e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 11 Sep 2023 03:08:25 +0200 Subject: [PATCH 1/3] perf(test): lower base overhead --- cli/js/40_testing.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index 37eb6be8f5dc29..c3c5c584af9af6 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -5,7 +5,7 @@ const ops = core.ops; import { setExitHandler } from "ext:runtime/30_os.js"; import { Console } from "ext:deno_console/01_console.js"; import { serializePermissions } from "ext:runtime/10_permissions.js"; -import { setTimeout } from "ext:deno_web/02_timers.js"; +import { setTimeoutUnclamped } from "ext:deno_web/02_timers.js"; import { assert } from "ext:deno_web/00_infra.js"; const primordials = globalThis.__bootstrap.primordials; const { @@ -50,7 +50,7 @@ function opSanitizerDelay() { hasSetOpSanitizerDelayMacrotask = true; } return new Promise((resolve) => { - setTimeout(() => { + setTimeoutUnclamped(() => { ArrayPrototypePush(opSanitizerDelayResolveQueue, resolve); }, 1); }); From 73af5ecbaacb81b38dbdf258ac8110a3bc3655c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 11 Sep 2023 05:06:21 +0200 Subject: [PATCH 2/3] try spinning event loop between tests --- cli/js/40_testing.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index c3c5c584af9af6..af390eee56c9c3 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -44,15 +44,20 @@ let hasSetOpSanitizerDelayMacrotask = false; // will have an associated op. An additional `setTimeout` of 0 is needed // before that, though, in order to give time for worker message ops to finish // (since timeouts of 0 don't queue tasks in the timer queue immediately). -function opSanitizerDelay() { +async function opSanitizerDelay() { if (!hasSetOpSanitizerDelayMacrotask) { core.setMacrotaskCallback(handleOpSanitizerDelayMacrotask); hasSetOpSanitizerDelayMacrotask = true; } + + // Spin the event loop for a little bit to let all async ops settle. + for (let i = 0; i < 100; i++) { + await core.opAsync("op_void_async_deferred"); + } return new Promise((resolve) => { - setTimeoutUnclamped(() => { - ArrayPrototypePush(opSanitizerDelayResolveQueue, resolve); - }, 1); + ArrayPrototypePush(opSanitizerDelayResolveQueue, () => { + resolve(); + }); }); } From e8ec59d5d218715dbd3a4aa544fec132f5f02a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 11 Sep 2023 05:09:32 +0200 Subject: [PATCH 3/3] lint --- cli/js/40_testing.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index af390eee56c9c3..b2739dea575ebd 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -5,7 +5,6 @@ const ops = core.ops; import { setExitHandler } from "ext:runtime/30_os.js"; import { Console } from "ext:deno_console/01_console.js"; import { serializePermissions } from "ext:runtime/10_permissions.js"; -import { setTimeoutUnclamped } from "ext:deno_web/02_timers.js"; import { assert } from "ext:deno_web/00_infra.js"; const primordials = globalThis.__bootstrap.primordials; const { @@ -55,9 +54,7 @@ async function opSanitizerDelay() { await core.opAsync("op_void_async_deferred"); } return new Promise((resolve) => { - ArrayPrototypePush(opSanitizerDelayResolveQueue, () => { - resolve(); - }); + ArrayPrototypePush(opSanitizerDelayResolveQueue, resolve); }); }