Skip to content

Commit

Permalink
Merge 5f99ba9 into 3320c20
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Jul 26, 2022
2 parents 3320c20 + 5f99ba9 commit f294d6b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -39,7 +39,7 @@
"@types/chai": "4.2.0",
"@types/chai-as-promised": "^7.1.2",
"@types/mocha": "^8.0.3",
"@types/node": "^14.14.17",
"@types/node": "^18.6.1",
"@types/sinon": "^9.0.0",
"@typescript-eslint/eslint-plugin": "5.26.0",
"@typescript-eslint/parser": "5.26.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/clock/LocalClock.ts
Expand Up @@ -14,7 +14,7 @@ import {IBeaconClock} from "./interface.js";
export class LocalClock implements IBeaconClock {
private readonly config: IChainForkConfig;
private readonly genesisTime: number;
private timeoutId: number;
private timeoutId: NodeJS.Timeout;
private readonly emitter: ChainEventEmitter;
private readonly signal: AbortSignal;
private _currentSlot: number;
Expand Down
24 changes: 14 additions & 10 deletions packages/beacon-node/test/memory/testRunnerMemory.ts
Expand Up @@ -8,6 +8,10 @@ export type TestRunnerMemoryOpts<T> = {
convergeFactor?: number;
};

if (global.gc === undefined) {
throw Error("Must enable global.gc");
}

export async function testRunnerMemoryGc<T>(opts: TestRunnerMemoryOpts<T>): Promise<void> {
const {
getInstance,
Expand All @@ -25,11 +29,11 @@ export async function testRunnerMemoryGc<T>(opts: TestRunnerMemoryOpts<T>): Prom
const usedMemoryArr: number[] = [];

for (let n = 0; n < rounds; n++) {
global.gc();
global.gc();
global.gc?.();
global.gc?.();
await new Promise((r) => setTimeout(r, 100));
global.gc();
global.gc();
global.gc?.();
global.gc?.();

const totalUsedMemoryPrev = computeUsedMemory(process.memoryUsage());

Expand All @@ -38,11 +42,11 @@ export async function testRunnerMemoryGc<T>(opts: TestRunnerMemoryOpts<T>): Prom
refs.push(getInstance(i));
}

global.gc();
global.gc();
global.gc?.();
global.gc?.();
await new Promise((r) => setTimeout(r, 100));
global.gc();
global.gc();
global.gc?.();
global.gc?.();

const totalUsedMemory = computeUsedMemory(process.memoryUsage());

Expand Down Expand Up @@ -98,8 +102,8 @@ export function testRunnerMemory<T>(opts: TestRunnerMemoryOpts<T>): number {
// local vars will get garbage collected and won't show up in the .m result

if (i % sampleEvery === 0) {
global.gc();
global.gc();
global.gc?.();
global.gc?.();

const memoryUsage = process.memoryUsage();
const usedMemory = computeUsedMemory(memoryUsage);
Expand Down
13 changes: 9 additions & 4 deletions yarn.lock
Expand Up @@ -2573,9 +2573,9 @@
integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg==

"@types/minipass@*":
version "2.2.0"
resolved "https://registry.npmjs.org/@types/minipass/-/minipass-2.2.0.tgz"
integrity sha512-wuzZksN4w4kyfoOv/dlpov4NOunwutLA/q7uc00xU02ZyUY+aoM5PWIXEKBMnm0NHd4a+N71BMjq+x7+2Af1fg==
version "3.1.2"
resolved "https://registry.yarnpkg.com/@types/minipass/-/minipass-3.1.2.tgz#e2d7f9df0698aff421dcf145b4fc05b8183b9030"
integrity sha512-foLGjgrJkUjLG/o2t2ymlZGEoBNBa/TfoUZ7oCTkOjP1T43UGBJspovJou/l3ZuHvye2ewR5cZNtp2zyWgILMA==
dependencies:
"@types/node" "*"

Expand All @@ -2602,7 +2602,7 @@
"@types/node" "*"
form-data "^3.0.0"

"@types/node@*", "@types/node@^14.14.17":
"@types/node@*":
version "14.14.43"
resolved "https://registry.npmjs.org/@types/node/-/node-14.14.43.tgz"
integrity sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ==
Expand All @@ -2617,6 +2617,11 @@
resolved "https://registry.npmjs.org/@types/node/-/node-16.6.2.tgz"
integrity sha512-LSw8TZt12ZudbpHc6EkIyDM3nHVWKYrAvGy6EAJfNfjusbwnThqjqxUKKRwuV3iWYeW/LYMzNgaq3MaLffQ2xA==

"@types/node@^18.6.1":
version "18.6.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.6.1.tgz#828e4785ccca13f44e2fb6852ae0ef11e3e20ba5"
integrity sha512-z+2vB6yDt1fNwKOeGbckpmirO+VBDuQqecXkgeIqDlaOtmKn6hPR/viQ8cxCfqLU4fTlvM3+YjM367TukWdxpg==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz"
Expand Down

0 comments on commit f294d6b

Please sign in to comment.