Skip to content

Commit

Permalink
attemptGarbageCollection during and after test cases
Browse files Browse the repository at this point in the history
Runs attemptGarbageCollection() after every 250 subcases, as well as
after every case.
  • Loading branch information
kainino0x committed Oct 17, 2024
1 parent ecefa0d commit 9bbaef7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/common/internal/test_group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -598,13 +599,20 @@ 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.
let subcasesInFlight = 0;
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) {
Expand Down Expand Up @@ -741,6 +749,8 @@ class RunCaseSpecific implements RunCase {
};
logToWebSocket(JSON.stringify(msg));
}

attemptGarbageCollection();
}
}

Expand Down

0 comments on commit 9bbaef7

Please sign in to comment.