From 9bbaef74f53c03dc9aaf513c63c56ef86a7a39e5 Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Thu, 17 Oct 2024 03:43:33 -0400 Subject: [PATCH] attemptGarbageCollection during and after test cases Runs attemptGarbageCollection() after every 250 subcases, as well as after every case. --- src/common/internal/test_group.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/common/internal/test_group.ts b/src/common/internal/test_group.ts index aaaec9fe3f3a..dd136dbeeae9 100644 --- a/src/common/internal/test_group.ts +++ b/src/common/internal/test_group.ts @@ -31,6 +31,7 @@ import { stringifyPublicParamsUniquely, } from '../internal/query/stringify_params.js'; import { validQueryPart } from '../internal/query/validQueryPart.js'; +import { attemptGarbageCollection } from '../util/collect_garbage.js'; import { DeepReadonly } from '../util/types.js'; import { assert, unreachable } from '../util/util.js'; @@ -598,6 +599,7 @@ class RunCaseSpecific implements RunCase { if (this.subcases) { let totalCount = 0; let skipCount = 0; + let finishedCount = 0; // If there are too many subcases in flight, starting the next subcase will register // `resolvePromiseBlockingSubcase` and wait until `subcaseFinishedCallback` is called. @@ -605,6 +607,12 @@ class RunCaseSpecific implements RunCase { let resolvePromiseBlockingSubcase: (() => void) | undefined = undefined; const subcaseFinishedCallback = () => { subcasesInFlight -= 1; + + finishedCount++; + if (finishedCount % 250 == 0) { + attemptGarbageCollection(); + } + // If there is any subcase waiting on a previous subcase to finish, // unblock it now, and clear the resolve callback. if (resolvePromiseBlockingSubcase) { @@ -741,6 +749,8 @@ class RunCaseSpecific implements RunCase { }; logToWebSocket(JSON.stringify(msg)); } + + attemptGarbageCollection(); } }