Skip to content

Commit 20f7db7

Browse files
authored
chore(NODE-6870): add tags to normalized_throughput (#4478)
1 parent af30db9 commit 20f7db7

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

.evergreen/config.in.yml

+12
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ functions:
109109
- .evergreen/run-tests.sh
110110

111111
"perf send":
112+
- command: s3.put
113+
params:
114+
aws_key: ${aws_key}
115+
aws_secret: ${aws_secret}
116+
local_file: src/test/benchmarks/driver_bench/results.json
117+
optional: true
118+
# TODO NODE-4707 - change upload directory to ${UPLOAD_BUCKET}
119+
remote_file: mongo-node-driver/${revision}/${version_id}/results.${task_name}.json
120+
bucket: mciuploads
121+
permissions: public-read
122+
content_type: application/json
123+
display_name: "Performance Results"
112124
- command: subprocess.exec
113125
params:
114126
working_dir: src

.evergreen/config.yml

+11
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ functions:
8181
args:
8282
- .evergreen/run-tests.sh
8383
perf send:
84+
- command: s3.put
85+
params:
86+
aws_key: ${aws_key}
87+
aws_secret: ${aws_secret}
88+
local_file: src/test/benchmarks/driver_bench/results.json
89+
optional: true
90+
remote_file: mongo-node-driver/${revision}/${version_id}/results.${task_name}.json
91+
bucket: mciuploads
92+
permissions: public-read
93+
content_type: application/json
94+
display_name: Performance Results
8495
- command: subprocess.exec
8596
params:
8697
working_dir: src

.evergreen/perf-send.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env bash
22

3-
set -euox pipefail
3+
set -euo pipefail
44

55
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
66

77
TARGET_FILE=$(realpath "${TARGET_FILE:-./test/benchmarks/driver_bench/results.json}")
88

9+
set -o xtrace
10+
911
node ./.evergreen/perf_send.mjs $TARGET_FILE

test/benchmarks/driver_bench/src/main.mts

+28-19
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ for (const [suite, benchmarks] of Object.entries(tests)) {
110110
console.groupEnd();
111111
}
112112

113+
const metricInfoFilterByName =
114+
(testName: string) =>
115+
({ info: { test_name } }: MetricInfo) =>
116+
test_name === testName;
117+
118+
const isMBsMetric = ({ name }: Metric) => name === 'megabytes_per_second';
119+
113120
function calculateCompositeBenchmarks(results: MetricInfo[]) {
114121
const composites = {
115122
singleBench: ['findOne', 'smallDocInsertOne', 'largeDocInsertOne'],
@@ -144,13 +151,6 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
144151
]
145152
};
146153

147-
const aMetricInfo =
148-
(testName: string) =>
149-
({ info: { test_name } }: MetricInfo) =>
150-
test_name === testName;
151-
152-
const anMBsMetric = ({ name }: Metric) => name === 'megabytes_per_second';
153-
154154
let readBenchResult;
155155
let writeBenchResult;
156156

@@ -162,10 +162,10 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
162162

163163
let sum = 0;
164164
for (const testName of compositeTests) {
165-
const testScore = results.find(aMetricInfo(testName));
165+
const testScore = results.find(metricInfoFilterByName(testName));
166166
assert.ok(testScore, `${compositeName} suite requires ${testName} for composite score`);
167167

168-
const metric = testScore.metrics.find(anMBsMetric);
168+
const metric = testScore.metrics.find(isMBsMetric);
169169
assert.ok(metric, `${testName} is missing a megabytes_per_second metric`);
170170

171171
sum += metric.value;
@@ -199,31 +199,40 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
199199
}
200200

201201
function calculateNormalizedResults(results: MetricInfo[]): MetricInfo[] {
202-
const baselineBench = results.find(r => r.info.test_name === 'cpuBaseline');
203-
const pingBench = results.find(r => r.info.test_name === 'ping');
202+
const baselineBench = results.find(metricInfoFilterByName('cpuBaseline'));
203+
const pingBench = results.find(metricInfoFilterByName('ping'));
204204

205205
assert.ok(pingBench, 'ping bench results not found!');
206-
assert.ok(baselineBench, 'baseline results not found!');
207-
const pingThroughput = pingBench.metrics[0].value;
208-
const cpuBaseline = baselineBench.metrics[0].value;
206+
assert.ok(baselineBench, 'cpuBaseline results not found!');
207+
208+
const cpuBaseline = baselineBench.metrics.find(isMBsMetric);
209+
const pingThroughput = pingBench.metrics.find(isMBsMetric);
210+
211+
assert.ok(cpuBaseline, 'cpu benchmark does not have a MB/s metric');
212+
assert.ok(pingThroughput, 'ping does not have a MB/s metric');
209213

210214
for (const bench of results) {
211215
if (bench.info.test_name === 'cpuBaseline') continue;
216+
217+
const currentMetric = bench.metrics.find(isMBsMetric);
218+
assert.ok(currentMetric, `${bench.info.test_name} does not have a MB/s metric`);
219+
212220
if (bench.info.test_name === 'ping') {
213221
bench.metrics.push({
214222
name: 'normalized_throughput',
215-
value: bench.metrics[0].value / cpuBaseline,
223+
value: currentMetric.value / cpuBaseline.value,
216224
metadata: {
225+
tags: currentMetric.metadata.tags,
217226
improvement_direction: 'up'
218227
}
219228
});
220-
}
221-
// Compute normalized_throughput of benchmarks against ping bench
222-
else {
229+
} else {
230+
// Compute normalized_throughput of benchmarks against ping bench
223231
bench.metrics.push({
224232
name: 'normalized_throughput',
225-
value: bench.metrics[0].value / pingThroughput,
233+
value: currentMetric.value / pingThroughput.value,
226234
metadata: {
235+
tags: currentMetric.metadata.tags,
227236
improvement_direction: 'up'
228237
}
229238
});

0 commit comments

Comments
 (0)