Skip to content

Commit 885bc91

Browse files
committed
chore: add readme and prints
1 parent df3ea32 commit 885bc91

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

test/benchmarks/driverBench/index.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const MongoBench = require('../mongoBench');
44
const os = require('node:os');
5+
const util = require('node:util');
56
const process = require('node:process');
67

78
const Runner = MongoBench.Runner;
@@ -11,7 +12,15 @@ let bsonType = 'js-bson';
1112

1213
const { writeFile } = require('fs/promises');
1314
const { makeParallelBenchmarks, makeSingleBench, makeMultiBench } = require('../mongoBench/suites');
14-
const { MONGODB_CLIENT_OPTIONS } = require('./common');
15+
const {
16+
MONGODB_CLIENT_OPTIONS,
17+
MONGODB_DRIVER_PATH,
18+
MONGODB_DRIVER_VERSION,
19+
MONGODB_DRIVER_REVISION,
20+
MONGODB_BSON_PATH,
21+
MONGODB_BSON_VERSION,
22+
MONGODB_BSON_REVISION
23+
} = require('./common');
1524

1625
const hw = os.cpus();
1726
const ram = os.totalmem() / 1024 ** 3;
@@ -24,7 +33,10 @@ const systemInfo = () =>
2433
`- arch: ${os.arch()}`,
2534
`- os: ${process.platform} (${os.release()})`,
2635
`- ram: ${platform.ram}`,
27-
`- node: ${process.version}\n`
36+
`- node: ${process.version}`,
37+
`- driver: ${MONGODB_DRIVER_VERSION} (${MONGODB_DRIVER_REVISION}): ${MONGODB_DRIVER_PATH}`,
38+
` - options ${util.inspect(MONGODB_CLIENT_OPTIONS)}`,
39+
`- bson: ${MONGODB_BSON_VERSION} (${MONGODB_BSON_REVISION}): (${MONGODB_BSON_PATH})\n`
2840
].join('\n');
2941
console.log(systemInfo());
3042

test/readme.md

+42
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,48 @@ beforeEach(() => {
241241
});
242242
```
243243

244+
## Running Benchmarks
245+
246+
Refer to the `run-spec-benchmark-tests-node-server` task for Node.js version, MongoDB server version, and platform that we run benchmarks against in CI.
247+
248+
The server is run in standalone mode and the server versions are aliased by this script: https://github.com/mongodb-labs/drivers-evergreen-tools/blob/5048cca80e9ca62642409de2d401058bbd7057fa/.evergreen/mongodl.py#L58 check the latest version to see what alias the driver is running against.
249+
250+
The host used is described here: https://spruce.mongodb.com/distro/rhel90-dbx-perf-large/settings/general (Auth required to view)
251+
252+
It is best to try reproductions against as similar a deployment as possible to isolate regressions.
253+
254+
### Configuration
255+
256+
The benchmarks can be directed to test different settings and driver versions.
257+
258+
The following are environment variables and how the benchmark runner uses them:
259+
260+
- `MONGODB_DRIVER_PATH` - if set MUST be set to the directory a driver version is in, usually another clone of the driver checked out to a different revision.
261+
- `MONGODB_CLIENT_OPTIONS` - if set MUST be a JSON string that will be parsed and passed as the second argument to the MongoClient constructor.
262+
- `MONGODB_URI` - if set MUST be a valid MongoDB connection string and it will be used as the host the benchmarks will run against.
263+
264+
It may be desirable to test how changes to `BSON` impact the driver's performance.
265+
266+
To do this:
267+
- clone the changed version of BSON
268+
- run the build script for that repo (usually done by `npm install` for you)
269+
- run `npm link`
270+
- over in the driver repo run `npm link bson`
271+
272+
When you run the benchmarks verify that the BSON version has been picked by the version references that are printed out:
273+
274+
```md
275+
- cpu: Apple M1 Max
276+
- cores: 10
277+
- arch: arm64
278+
- os: darwin (23.6.0)
279+
- ram: 32GB
280+
- node: v22.6.0
281+
- driver: 6.11.0 (df3ea32a9): .../mongodb
282+
- options {}
283+
- bson: 6.10.1 (installed from npm): (.../mongodb/node_modules/bson)
284+
```
285+
244286
## Testing with Special Environments
245287

246288
In order to test some features, you will need to generate and set a specialized group of environment variables. The subsections below will walk you through how to generate and set the environment variables for these features.

0 commit comments

Comments
 (0)