From dc3fe95720c21a004d89cc62875c9351b1fb5cbe Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Tue, 5 Nov 2024 12:09:50 -0700 Subject: [PATCH] ci(NODE-6501): use latest node in spec benchmarks (#4314) --- .evergreen/config.in.yml | 7 +++---- .evergreen/config.yml | 7 +++---- test/benchmarks/mongoBench/constants.js | 6 +++++- test/benchmarks/mongoBench/runner.js | 20 +++++++++++++++----- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.evergreen/config.in.yml b/.evergreen/config.in.yml index fa4884a05ba..45e10f5f66f 100644 --- a/.evergreen/config.in.yml +++ b/.evergreen/config.in.yml @@ -1147,7 +1147,7 @@ tasks: - func: bootstrap kms servers - func: "run serverless tests" - - name: run-spec-benchmark-tests-node-18-server-6.0 + - name: run-spec-benchmark-tests-node-server tags: - run-spec-benchmark-tests - performance @@ -1157,8 +1157,7 @@ tasks: type: setup params: updates: - - { key: NODE_LTS_VERSION, value: v18.16.0 } - - { key: NPM_VERSION, value: "9" } + - { key: NODE_LTS_VERSION, value: v22.11.0 } - { key: VERSION, value: v6.0-perf } - { key: TOPOLOGY, value: server } - { key: AUTH, value: noauth } @@ -1616,4 +1615,4 @@ buildvariants: display_name: Performance Test run_on: rhel90-dbx-perf-large tasks: - - run-spec-benchmark-tests-node-18-server-6.0 + - run-spec-benchmark-tests-node-server diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 01306ba9bc8..b99fcdef22a 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1108,7 +1108,7 @@ tasks: - func: install dependencies - func: bootstrap kms servers - func: run serverless tests - - name: run-spec-benchmark-tests-node-18-server-6.0 + - name: run-spec-benchmark-tests-node-server tags: - run-spec-benchmark-tests - performance @@ -1118,8 +1118,7 @@ tasks: type: setup params: updates: - - {key: NODE_LTS_VERSION, value: v18.16.0} - - {key: NPM_VERSION, value: '9'} + - {key: NODE_LTS_VERSION, value: v22.11.0} - {key: VERSION, value: v6.0-perf} - {key: TOPOLOGY, value: server} - {key: AUTH, value: noauth} @@ -4547,7 +4546,7 @@ buildvariants: display_name: Performance Test run_on: rhel90-dbx-perf-large tasks: - - run-spec-benchmark-tests-node-18-server-6.0 + - run-spec-benchmark-tests-node-server - name: rhel80-large-gallium display_name: rhel8 Node16 run_on: rhel80-large diff --git a/test/benchmarks/mongoBench/constants.js b/test/benchmarks/mongoBench/constants.js index 305f8c562f5..4065d97719a 100644 --- a/test/benchmarks/mongoBench/constants.js +++ b/test/benchmarks/mongoBench/constants.js @@ -12,8 +12,12 @@ const DEFAULT_MAX_EXECUTION_TIME = const DEFAULT_MIN_EXECUTION_COUNT = Number.parseInt(process.env.DRIVER_BENCH_MIN_EX_COUNT, 10) || 100; +const DEFAULT_MAX_EXECUTION_COUNT = + Number.parseInt(process.env.DRIVER_BENCH_MAX_EX_COUNT, 10) || 10000000; + module.exports = { DEFAULT_MIN_EXECUTION_COUNT, DEFAULT_MIN_EXECUTION_TIME, - DEFAULT_MAX_EXECUTION_TIME + DEFAULT_MAX_EXECUTION_TIME, + DEFAULT_MAX_EXECUTION_COUNT }; diff --git a/test/benchmarks/mongoBench/runner.js b/test/benchmarks/mongoBench/runner.js index 064f51dec58..745cefa74e8 100644 --- a/test/benchmarks/mongoBench/runner.js +++ b/test/benchmarks/mongoBench/runner.js @@ -39,7 +39,7 @@ function calculateMicroBench(benchmark, data) { const rawData = data.rawData; const count = data.count; - const sortedData = [].concat(rawData).sort(); + const sortedData = [].concat(rawData).sort((a, b) => a - b); const percentiles = PERCENTILES.reduce((acc, pct) => { acc[pct] = sortedData[percentileIndex(pct, count)]; @@ -57,6 +57,7 @@ class Runner { this.minExecutionTime = options.minExecutionTime || CONSTANTS.DEFAULT_MIN_EXECUTION_TIME; this.maxExecutionTime = options.maxExecutionTime || CONSTANTS.DEFAULT_MAX_EXECUTION_TIME; this.minExecutionCount = options.minExecutionCount || CONSTANTS.DEFAULT_MIN_EXECUTION_COUNT; + this.maxExecutionCount = options.maxExecutionCount || CONSTANTS.DEFAULT_MAX_EXECUTION_COUNT; this.reporter = options.reporter || function () { @@ -126,6 +127,7 @@ class Runner { for (const [name, benchmark] of benchmarks) { this.reporter(` Executing Benchmark "${name}"`); result[name] = await this._runBenchmark(benchmark); + this.reporter(` Executed Benchmark "${name}" =`, result[name]); } return result; @@ -162,12 +164,17 @@ class Runner { const minExecutionCount = this.minExecutionCount; const minExecutionTime = this.minExecutionTime; const maxExecutionTime = this.maxExecutionTime; + const maxExecutionAttempts = this.maxExecutionCount; let time = performance.now() - start; let count = 1; const taskTimer = benchmark._taskType === 'sync' ? timeSyncTask : timeAsyncTask; - while (time < maxExecutionTime && (time < minExecutionTime || count < minExecutionCount)) { + while ( + time < maxExecutionTime && + (time < minExecutionTime || count < minExecutionCount) && + count <= maxExecutionAttempts + ) { await benchmark.beforeTask.call(ctx); const executionTime = await taskTimer(benchmark.task, ctx); rawData.push(executionTime); @@ -181,9 +188,12 @@ class Runner { }; } - _errorHandler(e) { - console.error(e); - return NaN; + _errorHandler(error) { + this.reporter(`Error: ${error.name} - ${error.message} - ${error.stack}`); + for (let error = error.cause; error != null; error = error.cause) { + this.reporter(`Caused by: ${error.name} - ${error.message} - ${error.stack}`); + } + throw error; } }