@aztec/end-to-end 0.0.1-commit.808bf7f90 → 0.0.1-commit.8227e42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/e2e_fees/fees_test.js +1 -1
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/shared/jest_setup.js +10 -1
- package/dest/test-wallet/worker_wallet.js +1 -1
- package/package.json +40 -40
- package/src/e2e_fees/fees_test.ts +1 -1
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/shared/jest_setup.ts +16 -1
- package/src/test-wallet/worker_wallet.ts +1 -1
|
@@ -216,7 +216,7 @@ import { FeeJuicePortalTestingHarnessFactory } from '../shared/gas_portal_test_h
|
|
|
216
216
|
const block = await this.aztecNode.getBlock(blockNumber);
|
|
217
217
|
// @todo @lherskind As we deal with #13601
|
|
218
218
|
// Right now the value is from `FeeLib.sol`
|
|
219
|
-
const L1_GAS_PER_EPOCH_VERIFIED =
|
|
219
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 3600000n;
|
|
220
220
|
// We round up
|
|
221
221
|
const mulDiv = (a, b, c)=>a * b / c + (a * b % c > 0n ? 1n : 0n);
|
|
222
222
|
const { baseFee } = await this.rollupContract.getL1FeesAt(block.header.globalVariables.timestamp);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Samples event-loop utilization, delay histogram, and heap usage per test, writing columnar text to a file. */
|
|
2
|
+
export declare class EluMonitor {
|
|
3
|
+
private filePath;
|
|
4
|
+
private intervalMs;
|
|
5
|
+
private timer;
|
|
6
|
+
private lastELU;
|
|
7
|
+
private histogram;
|
|
8
|
+
private testName;
|
|
9
|
+
private testStart;
|
|
10
|
+
private eluSamples;
|
|
11
|
+
constructor(filePath: string, intervalMs?: number);
|
|
12
|
+
/** Begin sampling for a test. Writes a header line and starts the periodic sampler. */
|
|
13
|
+
startTest(testName: string): void;
|
|
14
|
+
/** Stop sampling and write a summary line. */
|
|
15
|
+
stopTest(): void;
|
|
16
|
+
/** Alias for stopTest — call on process exit to flush any remaining data. */
|
|
17
|
+
stop(): void;
|
|
18
|
+
private sample;
|
|
19
|
+
private writeSummary;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWx1X21vbml0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maXh0dXJlcy9lbHVfbW9uaXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxpSEFBaUg7QUFDakgscUJBQWEsVUFBVTtJQUNyQixPQUFPLENBQUMsUUFBUSxDQUFTO0lBQ3pCLE9BQU8sQ0FBQyxVQUFVLENBQVM7SUFDM0IsT0FBTyxDQUFDLEtBQUssQ0FBNkM7SUFDMUQsT0FBTyxDQUFDLE9BQU8sQ0FBbUM7SUFDbEQsT0FBTyxDQUFDLFNBQVMsQ0FBb0I7SUFDckMsT0FBTyxDQUFDLFFBQVEsQ0FBcUI7SUFDckMsT0FBTyxDQUFDLFNBQVMsQ0FBcUI7SUFDdEMsT0FBTyxDQUFDLFVBQVUsQ0FBZ0I7SUFFbEMsWUFBWSxRQUFRLEVBQUUsTUFBTSxFQUFFLFVBQVUsQ0FBQyxFQUFFLE1BQU0sRUFJaEQ7SUFFRCx1RkFBdUY7SUFDdkYsU0FBUyxDQUFDLFFBQVEsRUFBRSxNQUFNLEdBQUcsSUFBSSxDQW1CaEM7SUFFRCw4Q0FBOEM7SUFDOUMsUUFBUSxJQUFJLElBQUksQ0FtQmY7SUFFRCwrRUFBNkU7SUFDN0UsSUFBSSxJQUFJLElBQUksQ0FFWDtJQUVELE9BQU8sQ0FBQyxNQUFNO0lBOEJkLE9BQU8sQ0FBQyxZQUFZO0NBbUJyQiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elu_monitor.d.ts","sourceRoot":"","sources":["../../src/fixtures/elu_monitor.ts"],"names":[],"mappings":"AAKA,iHAAiH;AACjH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAA6C;IAC1D,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,UAAU,CAAgB;IAElC,YAAY,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAIhD;IAED,uFAAuF;IACvF,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAmBhC;IAED,8CAA8C;IAC9C,QAAQ,IAAI,IAAI,CAmBf;IAED,+EAA6E;IAC7E,IAAI,IAAI,IAAI,CAEX;IAED,OAAO,CAAC,MAAM;IA8Bd,OAAO,CAAC,YAAY;CAmBrB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { appendFileSync } from 'node:fs';
|
|
2
|
+
import { monitorEventLoopDelay, performance } from 'node:perf_hooks';
|
|
3
|
+
const NANOS_PER_MS = 1_000_000;
|
|
4
|
+
/** Samples event-loop utilization, delay histogram, and heap usage per test, writing columnar text to a file. */ export class EluMonitor {
|
|
5
|
+
filePath;
|
|
6
|
+
intervalMs;
|
|
7
|
+
timer;
|
|
8
|
+
lastELU;
|
|
9
|
+
histogram;
|
|
10
|
+
testName;
|
|
11
|
+
testStart;
|
|
12
|
+
eluSamples = [];
|
|
13
|
+
constructor(filePath, intervalMs){
|
|
14
|
+
this.filePath = filePath;
|
|
15
|
+
this.intervalMs = intervalMs ?? 2000;
|
|
16
|
+
this.histogram = monitorEventLoopDelay({
|
|
17
|
+
resolution: 20
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Begin sampling for a test. Writes a header line and starts the periodic sampler. */ startTest(testName) {
|
|
21
|
+
this.stopTest();
|
|
22
|
+
this.testName = testName;
|
|
23
|
+
this.testStart = performance.now();
|
|
24
|
+
this.eluSamples = [];
|
|
25
|
+
appendFileSync(this.filePath, `\n=== Test: ${testName} ===\n`);
|
|
26
|
+
appendFileSync(this.filePath, padColumns('TIME', 'ELU', 'EL_DLY_P50', 'EL_DLY_P99', 'EL_DLY_MAX', 'HEAP_MB') + '\n');
|
|
27
|
+
this.lastELU = performance.eventLoopUtilization();
|
|
28
|
+
this.histogram.enable();
|
|
29
|
+
this.timer = setInterval(()=>this.sample(), this.intervalMs);
|
|
30
|
+
// Allow the process to exit even if the timer is still running.
|
|
31
|
+
this.timer.unref();
|
|
32
|
+
}
|
|
33
|
+
/** Stop sampling and write a summary line. */ stopTest() {
|
|
34
|
+
if (!this.timer) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Take a final sample before stopping.
|
|
38
|
+
this.sample();
|
|
39
|
+
clearInterval(this.timer);
|
|
40
|
+
this.timer = undefined;
|
|
41
|
+
this.histogram.disable();
|
|
42
|
+
this.histogram.reset();
|
|
43
|
+
this.writeSummary();
|
|
44
|
+
this.lastELU = undefined;
|
|
45
|
+
this.testName = undefined;
|
|
46
|
+
this.testStart = undefined;
|
|
47
|
+
this.eluSamples = [];
|
|
48
|
+
}
|
|
49
|
+
/** Alias for stopTest — call on process exit to flush any remaining data. */ stop() {
|
|
50
|
+
this.stopTest();
|
|
51
|
+
}
|
|
52
|
+
sample() {
|
|
53
|
+
const newELU = performance.eventLoopUtilization();
|
|
54
|
+
const delta = performance.eventLoopUtilization(newELU, this.lastELU);
|
|
55
|
+
this.lastELU = newELU;
|
|
56
|
+
const elu = delta.utilization;
|
|
57
|
+
this.eluSamples.push(elu);
|
|
58
|
+
const p50 = this.histogram.percentile(50) / NANOS_PER_MS;
|
|
59
|
+
const p99 = this.histogram.percentile(99) / NANOS_PER_MS;
|
|
60
|
+
const max = this.histogram.max / NANOS_PER_MS;
|
|
61
|
+
const heapMb = Math.round(process.memoryUsage().heapUsed / (1024 * 1024));
|
|
62
|
+
const now = new Date();
|
|
63
|
+
const time = [
|
|
64
|
+
now.getHours(),
|
|
65
|
+
now.getMinutes(),
|
|
66
|
+
now.getSeconds()
|
|
67
|
+
].map((n)=>String(n).padStart(2, '0')).join(':');
|
|
68
|
+
const line = padColumns(time, elu.toFixed(2), `${p50.toFixed(1)}ms`, `${p99.toFixed(1)}ms`, `${max.toFixed(1)}ms`, String(heapMb));
|
|
69
|
+
appendFileSync(this.filePath, line + '\n');
|
|
70
|
+
// Reset histogram so next sample only reflects the new interval.
|
|
71
|
+
this.histogram.reset();
|
|
72
|
+
}
|
|
73
|
+
writeSummary() {
|
|
74
|
+
if (this.eluSamples.length === 0 || this.testStart === undefined) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const mean = this.eluSamples.reduce((a, b)=>a + b, 0) / this.eluSamples.length;
|
|
78
|
+
const maxElu = Math.max(...this.eluSamples);
|
|
79
|
+
const sorted = [
|
|
80
|
+
...this.eluSamples
|
|
81
|
+
].sort((a, b)=>a - b);
|
|
82
|
+
const p90Elu = sorted[Math.floor(sorted.length * 0.9)] ?? maxElu;
|
|
83
|
+
const durationS = ((performance.now() - this.testStart) / 1000).toFixed(1);
|
|
84
|
+
let summary = `--- Summary: mean_elu=${mean.toFixed(2)} max_elu=${maxElu.toFixed(2)} p90_elu=${p90Elu.toFixed(2)} duration=${durationS}s`;
|
|
85
|
+
if (maxElu > 0.85) {
|
|
86
|
+
summary += ' WARNING:ELU>0.85';
|
|
87
|
+
}
|
|
88
|
+
summary += ' ---\n';
|
|
89
|
+
appendFileSync(this.filePath, summary);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function padColumns(...cols) {
|
|
93
|
+
const widths = [
|
|
94
|
+
11,
|
|
95
|
+
7,
|
|
96
|
+
12,
|
|
97
|
+
12,
|
|
98
|
+
12,
|
|
99
|
+
8
|
|
100
|
+
];
|
|
101
|
+
return cols.map((col, i)=>col.padEnd(widths[i] ?? 10)).join('');
|
|
102
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
-
import { beforeEach, expect } from '@jest/globals';
|
|
2
|
+
import { afterEach, beforeEach, expect } from '@jest/globals';
|
|
3
3
|
import { basename } from 'path';
|
|
4
|
+
import { EluMonitor } from '../fixtures/elu_monitor.js';
|
|
5
|
+
const eluMonitor = process.env.ELU_MONITOR_FILE ? new EluMonitor(process.env.ELU_MONITOR_FILE, Number(process.env.ELU_MONITOR_INTERVAL_MS) || undefined) : undefined;
|
|
6
|
+
if (eluMonitor) {
|
|
7
|
+
process.on('exit', ()=>eluMonitor.stop());
|
|
8
|
+
}
|
|
4
9
|
beforeEach(()=>{
|
|
5
10
|
const { testPath, currentTestName } = expect.getState();
|
|
6
11
|
if (!testPath || !currentTestName) {
|
|
@@ -8,4 +13,8 @@ beforeEach(()=>{
|
|
|
8
13
|
}
|
|
9
14
|
const logger = createLogger(`e2e:${basename(testPath).replace('.test.ts', '')}`);
|
|
10
15
|
logger.info(`Running test: ${currentTestName}`);
|
|
16
|
+
eluMonitor?.startTest(currentTestName);
|
|
17
|
+
});
|
|
18
|
+
afterEach(()=>{
|
|
19
|
+
eluMonitor?.stopTest();
|
|
11
20
|
});
|
|
@@ -39,7 +39,7 @@ const WORKER_READY_TIMEOUT_MS = 120_000;
|
|
|
39
39
|
...process.stderr.isTTY || process.env.FORCE_COLOR ? {
|
|
40
40
|
FORCE_COLOR: '1'
|
|
41
41
|
} : {},
|
|
42
|
-
LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? '
|
|
42
|
+
LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? 'warn'
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
const connector = new NodeConnector(worker);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/end-to-end",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.8227e42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"inherits": [
|
|
@@ -26,45 +26,45 @@
|
|
|
26
26
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
30
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
31
|
-
"@aztec/aztec": "0.0.1-commit.
|
|
32
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
33
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
34
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
35
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
36
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
37
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
38
|
-
"@aztec/bot": "0.0.1-commit.
|
|
39
|
-
"@aztec/cli": "0.0.1-commit.
|
|
40
|
-
"@aztec/constants": "0.0.1-commit.
|
|
41
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
42
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
43
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
44
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
45
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
46
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
47
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
48
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
49
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
50
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
51
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
52
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
53
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
54
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
55
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
56
|
-
"@aztec/prover-node": "0.0.1-commit.
|
|
57
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
58
|
-
"@aztec/sequencer-client": "0.0.1-commit.
|
|
59
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
60
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
61
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
62
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
63
|
-
"@aztec/validator-client": "0.0.1-commit.
|
|
64
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
65
|
-
"@aztec/wallet-sdk": "0.0.1-commit.
|
|
66
|
-
"@aztec/wallets": "0.0.1-commit.
|
|
67
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
29
|
+
"@aztec/accounts": "0.0.1-commit.8227e42",
|
|
30
|
+
"@aztec/archiver": "0.0.1-commit.8227e42",
|
|
31
|
+
"@aztec/aztec": "0.0.1-commit.8227e42",
|
|
32
|
+
"@aztec/aztec-node": "0.0.1-commit.8227e42",
|
|
33
|
+
"@aztec/aztec.js": "0.0.1-commit.8227e42",
|
|
34
|
+
"@aztec/bb-prover": "0.0.1-commit.8227e42",
|
|
35
|
+
"@aztec/bb.js": "0.0.1-commit.8227e42",
|
|
36
|
+
"@aztec/blob-client": "0.0.1-commit.8227e42",
|
|
37
|
+
"@aztec/blob-lib": "0.0.1-commit.8227e42",
|
|
38
|
+
"@aztec/bot": "0.0.1-commit.8227e42",
|
|
39
|
+
"@aztec/cli": "0.0.1-commit.8227e42",
|
|
40
|
+
"@aztec/constants": "0.0.1-commit.8227e42",
|
|
41
|
+
"@aztec/entrypoints": "0.0.1-commit.8227e42",
|
|
42
|
+
"@aztec/epoch-cache": "0.0.1-commit.8227e42",
|
|
43
|
+
"@aztec/ethereum": "0.0.1-commit.8227e42",
|
|
44
|
+
"@aztec/foundation": "0.0.1-commit.8227e42",
|
|
45
|
+
"@aztec/kv-store": "0.0.1-commit.8227e42",
|
|
46
|
+
"@aztec/l1-artifacts": "0.0.1-commit.8227e42",
|
|
47
|
+
"@aztec/merkle-tree": "0.0.1-commit.8227e42",
|
|
48
|
+
"@aztec/node-keystore": "0.0.1-commit.8227e42",
|
|
49
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.8227e42",
|
|
50
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.8227e42",
|
|
51
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.8227e42",
|
|
52
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.8227e42",
|
|
53
|
+
"@aztec/p2p": "0.0.1-commit.8227e42",
|
|
54
|
+
"@aztec/protocol-contracts": "0.0.1-commit.8227e42",
|
|
55
|
+
"@aztec/prover-client": "0.0.1-commit.8227e42",
|
|
56
|
+
"@aztec/prover-node": "0.0.1-commit.8227e42",
|
|
57
|
+
"@aztec/pxe": "0.0.1-commit.8227e42",
|
|
58
|
+
"@aztec/sequencer-client": "0.0.1-commit.8227e42",
|
|
59
|
+
"@aztec/simulator": "0.0.1-commit.8227e42",
|
|
60
|
+
"@aztec/slasher": "0.0.1-commit.8227e42",
|
|
61
|
+
"@aztec/stdlib": "0.0.1-commit.8227e42",
|
|
62
|
+
"@aztec/telemetry-client": "0.0.1-commit.8227e42",
|
|
63
|
+
"@aztec/validator-client": "0.0.1-commit.8227e42",
|
|
64
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.8227e42",
|
|
65
|
+
"@aztec/wallet-sdk": "0.0.1-commit.8227e42",
|
|
66
|
+
"@aztec/wallets": "0.0.1-commit.8227e42",
|
|
67
|
+
"@aztec/world-state": "0.0.1-commit.8227e42",
|
|
68
68
|
"@iarna/toml": "^2.2.5",
|
|
69
69
|
"@jest/globals": "^30.0.0",
|
|
70
70
|
"@noble/curves": "=1.0.0",
|
|
@@ -275,7 +275,7 @@ export class FeesTest {
|
|
|
275
275
|
|
|
276
276
|
// @todo @lherskind As we deal with #13601
|
|
277
277
|
// Right now the value is from `FeeLib.sol`
|
|
278
|
-
const L1_GAS_PER_EPOCH_VERIFIED =
|
|
278
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 3600000n;
|
|
279
279
|
|
|
280
280
|
// We round up
|
|
281
281
|
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { appendFileSync } from 'node:fs';
|
|
2
|
+
import { type EventLoopUtilization, type IntervalHistogram, monitorEventLoopDelay, performance } from 'node:perf_hooks';
|
|
3
|
+
|
|
4
|
+
const NANOS_PER_MS = 1_000_000;
|
|
5
|
+
|
|
6
|
+
/** Samples event-loop utilization, delay histogram, and heap usage per test, writing columnar text to a file. */
|
|
7
|
+
export class EluMonitor {
|
|
8
|
+
private filePath: string;
|
|
9
|
+
private intervalMs: number;
|
|
10
|
+
private timer: ReturnType<typeof setInterval> | undefined;
|
|
11
|
+
private lastELU: EventLoopUtilization | undefined;
|
|
12
|
+
private histogram: IntervalHistogram;
|
|
13
|
+
private testName: string | undefined;
|
|
14
|
+
private testStart: number | undefined;
|
|
15
|
+
private eluSamples: number[] = [];
|
|
16
|
+
|
|
17
|
+
constructor(filePath: string, intervalMs?: number) {
|
|
18
|
+
this.filePath = filePath;
|
|
19
|
+
this.intervalMs = intervalMs ?? 2000;
|
|
20
|
+
this.histogram = monitorEventLoopDelay({ resolution: 20 });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Begin sampling for a test. Writes a header line and starts the periodic sampler. */
|
|
24
|
+
startTest(testName: string): void {
|
|
25
|
+
this.stopTest();
|
|
26
|
+
|
|
27
|
+
this.testName = testName;
|
|
28
|
+
this.testStart = performance.now();
|
|
29
|
+
this.eluSamples = [];
|
|
30
|
+
|
|
31
|
+
appendFileSync(this.filePath, `\n=== Test: ${testName} ===\n`);
|
|
32
|
+
appendFileSync(
|
|
33
|
+
this.filePath,
|
|
34
|
+
padColumns('TIME', 'ELU', 'EL_DLY_P50', 'EL_DLY_P99', 'EL_DLY_MAX', 'HEAP_MB') + '\n',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
this.lastELU = performance.eventLoopUtilization();
|
|
38
|
+
this.histogram.enable();
|
|
39
|
+
|
|
40
|
+
this.timer = setInterval(() => this.sample(), this.intervalMs);
|
|
41
|
+
// Allow the process to exit even if the timer is still running.
|
|
42
|
+
this.timer.unref();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Stop sampling and write a summary line. */
|
|
46
|
+
stopTest(): void {
|
|
47
|
+
if (!this.timer) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Take a final sample before stopping.
|
|
52
|
+
this.sample();
|
|
53
|
+
|
|
54
|
+
clearInterval(this.timer);
|
|
55
|
+
this.timer = undefined;
|
|
56
|
+
this.histogram.disable();
|
|
57
|
+
this.histogram.reset();
|
|
58
|
+
|
|
59
|
+
this.writeSummary();
|
|
60
|
+
|
|
61
|
+
this.lastELU = undefined;
|
|
62
|
+
this.testName = undefined;
|
|
63
|
+
this.testStart = undefined;
|
|
64
|
+
this.eluSamples = [];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Alias for stopTest — call on process exit to flush any remaining data. */
|
|
68
|
+
stop(): void {
|
|
69
|
+
this.stopTest();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private sample(): void {
|
|
73
|
+
const newELU = performance.eventLoopUtilization();
|
|
74
|
+
const delta = performance.eventLoopUtilization(newELU, this.lastELU);
|
|
75
|
+
this.lastELU = newELU;
|
|
76
|
+
|
|
77
|
+
const elu = delta.utilization;
|
|
78
|
+
this.eluSamples.push(elu);
|
|
79
|
+
|
|
80
|
+
const p50 = this.histogram.percentile(50) / NANOS_PER_MS;
|
|
81
|
+
const p99 = this.histogram.percentile(99) / NANOS_PER_MS;
|
|
82
|
+
const max = this.histogram.max / NANOS_PER_MS;
|
|
83
|
+
const heapMb = Math.round(process.memoryUsage().heapUsed / (1024 * 1024));
|
|
84
|
+
|
|
85
|
+
const now = new Date();
|
|
86
|
+
const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(n => String(n).padStart(2, '0')).join(':');
|
|
87
|
+
|
|
88
|
+
const line = padColumns(
|
|
89
|
+
time,
|
|
90
|
+
elu.toFixed(2),
|
|
91
|
+
`${p50.toFixed(1)}ms`,
|
|
92
|
+
`${p99.toFixed(1)}ms`,
|
|
93
|
+
`${max.toFixed(1)}ms`,
|
|
94
|
+
String(heapMb),
|
|
95
|
+
);
|
|
96
|
+
appendFileSync(this.filePath, line + '\n');
|
|
97
|
+
|
|
98
|
+
// Reset histogram so next sample only reflects the new interval.
|
|
99
|
+
this.histogram.reset();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private writeSummary(): void {
|
|
103
|
+
if (this.eluSamples.length === 0 || this.testStart === undefined) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const mean = this.eluSamples.reduce((a, b) => a + b, 0) / this.eluSamples.length;
|
|
108
|
+
const maxElu = Math.max(...this.eluSamples);
|
|
109
|
+
const sorted = [...this.eluSamples].sort((a, b) => a - b);
|
|
110
|
+
const p90Elu = sorted[Math.floor(sorted.length * 0.9)] ?? maxElu;
|
|
111
|
+
const durationS = ((performance.now() - this.testStart) / 1000).toFixed(1);
|
|
112
|
+
|
|
113
|
+
let summary = `--- Summary: mean_elu=${mean.toFixed(2)} max_elu=${maxElu.toFixed(2)} p90_elu=${p90Elu.toFixed(2)} duration=${durationS}s`;
|
|
114
|
+
if (maxElu > 0.85) {
|
|
115
|
+
summary += ' WARNING:ELU>0.85';
|
|
116
|
+
}
|
|
117
|
+
summary += ' ---\n';
|
|
118
|
+
|
|
119
|
+
appendFileSync(this.filePath, summary);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function padColumns(...cols: string[]): string {
|
|
124
|
+
const widths = [11, 7, 12, 12, 12, 8];
|
|
125
|
+
return cols.map((col, i) => col.padEnd(widths[i] ?? 10)).join('');
|
|
126
|
+
}
|
package/src/shared/jest_setup.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
2
|
|
|
3
|
-
import { beforeEach, expect } from '@jest/globals';
|
|
3
|
+
import { afterEach, beforeEach, expect } from '@jest/globals';
|
|
4
4
|
import { basename } from 'path';
|
|
5
5
|
|
|
6
|
+
import { EluMonitor } from '../fixtures/elu_monitor.js';
|
|
7
|
+
|
|
8
|
+
const eluMonitor = process.env.ELU_MONITOR_FILE
|
|
9
|
+
? new EluMonitor(process.env.ELU_MONITOR_FILE, Number(process.env.ELU_MONITOR_INTERVAL_MS) || undefined)
|
|
10
|
+
: undefined;
|
|
11
|
+
|
|
12
|
+
if (eluMonitor) {
|
|
13
|
+
process.on('exit', () => eluMonitor.stop());
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
beforeEach(() => {
|
|
7
17
|
const { testPath, currentTestName } = expect.getState();
|
|
8
18
|
if (!testPath || !currentTestName) {
|
|
@@ -10,4 +20,9 @@ beforeEach(() => {
|
|
|
10
20
|
}
|
|
11
21
|
const logger = createLogger(`e2e:${basename(testPath).replace('.test.ts', '')}`);
|
|
12
22
|
logger.info(`Running test: ${currentTestName}`);
|
|
23
|
+
eluMonitor?.startTest(currentTestName);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
eluMonitor?.stopTest();
|
|
13
28
|
});
|
|
@@ -70,7 +70,7 @@ export class WorkerWallet implements Wallet {
|
|
|
70
70
|
env: {
|
|
71
71
|
...parentEnv,
|
|
72
72
|
...(process.stderr.isTTY || process.env.FORCE_COLOR ? { FORCE_COLOR: '1' } : {}),
|
|
73
|
-
LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? '
|
|
73
|
+
LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? 'warn',
|
|
74
74
|
},
|
|
75
75
|
});
|
|
76
76
|
|