Skip to content

Commit 90cc399

Browse files
committed
wip
1 parent adb15fe commit 90cc399

File tree

3 files changed

+65
-59
lines changed

3 files changed

+65
-59
lines changed

src/cmap/connect.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,18 @@ export async function makeSocket(options: MakeConnectionOptions): Promise<Stream
387387
resolve(socket);
388388
} else {
389389
const connectEvent = useTLS ? 'secureConnect' : 'connect';
390+
const start = performance.now();
390391
socket
391392
.once(connectEvent, () => resolve(socket))
392393
.once('error', error => reject(connectionFailureError('error', error)))
393-
.once('timeout', () => reject(connectionFailureError('timeout')))
394+
.once('timeout', () => {
395+
const end = performance.now();
396+
return reject(
397+
new MongoNetworkTimeoutError(
398+
`socket.connect() timed out! connectTimeoutMS=${connectTimeoutMS}ms, socket.setTimeout fired after ${end - start}ms.`
399+
)
400+
);
401+
})
394402
.once('close', () => reject(connectionFailureError('close')));
395403

396404
if (options.cancellationToken != null) {

test/benchmarks/driverBench/index.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ let bsonType = 'js-bson';
1010
// TODO(NODE-4606): test against different driver configurations in CI
1111

1212
const { writeFile } = require('fs/promises');
13-
const { makeParallelBenchmarks, makeSingleBench, makeMultiBench } = require('../mongoBench/suites');
13+
const {
14+
makeParallelBenchmarks /* makeSingleBench, makeMultiBench*/
15+
} = require('../mongoBench/suites');
1416
const { MONGODB_CLIENT_OPTIONS } = require('./common');
1517

1618
const hw = os.cpus();
@@ -33,27 +35,23 @@ function average(arr) {
3335
}
3436

3537
const benchmarkRunner = new Runner()
36-
.suite('singleBench', suite => makeSingleBench(suite))
37-
.suite('multiBench', suite => makeMultiBench(suite))
38+
// .suite('singleBench', suite => makeSingleBench(suite))
39+
// .suite('multiBench', suite => makeMultiBench(suite))
3840
.suite('parallel', suite => makeParallelBenchmarks(suite));
3941

4042
benchmarkRunner
4143
.run()
4244
.then(microBench => {
43-
const singleBench = average([
44-
microBench.singleBench.findOne,
45-
microBench.singleBench.smallDocInsertOne,
46-
microBench.singleBench.largeDocInsertOne
47-
]);
48-
const multiBench = average(Object.values(microBench.multiBench));
49-
50-
// ldjsonMultiFileUpload and ldjsonMultiFileExport cause connection errors.
51-
// While we investigate, we will use the last known good values:
52-
// https://spruce.mongodb.com/task/mongo_node_driver_next_performance_tests_run_spec_benchmark_tests_node_server_4bc3e500b6f0e8ab01f052c4a1bfb782d6a29b4e_f168e1328f821bbda265e024cc91ae54_24_11_18_15_37_24/logs?execution=0
45+
// const singleBench = average([
46+
// microBench.singleBench.findOne,
47+
// microBench.singleBench.smallDocInsertOne,
48+
// microBench.singleBench.largeDocInsertOne
49+
// ]);
50+
// const multiBench = average(Object.values(microBench.multiBench));
5351

5452
const parallelBench = average([
55-
microBench.parallel.ldjsonMultiFileUpload ?? 44.02343490518617,
56-
microBench.parallel.ldjsonMultiFileExport ?? 31.83182984813926,
53+
microBench.parallel.ldjsonMultiFileUpload,
54+
microBench.parallel.ldjsonMultiFileExport,
5755
microBench.parallel.gridfsMultiFileUpload,
5856
microBench.parallel.gridfsMultiFileDownload
5957
]);
@@ -63,23 +61,23 @@ benchmarkRunner
6361
microBench.multiBench.findManyAndEmptyCursor,
6462
microBench.multiBench.gridFsDownload,
6563
microBench.parallel.gridfsMultiFileDownload,
66-
microBench.parallel.ldjsonMultiFileExport ?? 31.83182984813926
64+
microBench.parallel.ldjsonMultiFileExport
6765
]);
6866
const writeBench = average([
6967
microBench.singleBench.smallDocInsertOne,
7068
microBench.singleBench.largeDocInsertOne,
7169
microBench.multiBench.smallDocBulkInsert,
7270
microBench.multiBench.largeDocBulkInsert,
7371
microBench.multiBench.gridFsUpload,
74-
microBench.parallel.ldjsonMultiFileUpload ?? 44.02343490518617,
72+
microBench.parallel.ldjsonMultiFileUpload,
7573
microBench.parallel.gridfsMultiFileUpload
7674
]);
7775

7876
const driverBench = average([readBench, writeBench]);
7977

8078
const benchmarkResults = {
81-
singleBench,
82-
multiBench,
79+
// singleBench,
80+
// multiBench,
8381
parallelBench,
8482
readBench,
8583
writeBench,

test/benchmarks/mongoBench/suites/parallelBench.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ const {
1313
dropBucket,
1414
initCollection,
1515
initDb,
16-
connectClient
16+
connectClient,
17+
dropCollection,
18+
createCollection
1719
} = require('../../driverBench/common');
1820
const { pipeline } = require('stream/promises');
1921
const { EJSON } = require('bson');
@@ -34,7 +36,6 @@ async function clearTemporaryDirectory() {
3436
await Promise.all(files.map(file => rm(file)));
3537
}
3638

37-
// eslint-disable-next-line no-unused-vars
3839
async function ldjsonMultiUpload() {
3940
const directory = resolve(benchmarkFileDirectory, 'ldjson_multi');
4041
const files = await readdir(directory);
@@ -63,7 +64,6 @@ async function ldjsonMultiUpload() {
6364
await Promise.all(uploads);
6465
}
6566

66-
// eslint-disable-next-line no-unused-vars
6767
async function ldjsonMultiExport() {
6868
const skips = Array.from({ length: 100 }, (_, index) => index * 5000);
6969

@@ -113,43 +113,43 @@ async function gridfsMultiFileDownload() {
113113
* @returns Benchmark
114114
*/
115115
function makeParallelBenchmarks(suite) {
116-
// .benchmark('ldjsonMultiFileUpload', benchmark =>
117-
// // https://github.com/mongodb/specifications/blob/master/source/benchmarking/benchmarking.rst#ldjson-multi-file-import
118-
// benchmark
119-
// .taskSize(565)
120-
// .setup(makeClient)
121-
// .setup(connectClient)
122-
// .setup(initDb)
123-
// .setup(dropDb)
124-
// .beforeTask(initCollection)
125-
// .beforeTask(dropCollection)
126-
// .beforeTask(createCollection)
127-
// .task(ldjsonMultiUpload)
128-
// .teardown(dropDb)
129-
// .teardown(disconnectClient)
130-
// )
131-
// .benchmark('ldjsonMultiFileExport', benchmark =>
132-
// // https://github.com/mongodb/specifications/blob/master/source/benchmarking/benchmarking.rst#ldjson-multi-file-export
133-
// benchmark
134-
// .taskSize(565)
135-
// .setup(makeClient)
136-
// .setup(connectClient)
137-
// .setup(initDb)
138-
// .setup(dropDb)
139-
// .beforeTask(initCollection)
140-
// .beforeTask(dropCollection)
141-
// .beforeTask(createCollection)
142-
// .beforeTask(ldjsonMultiUpload)
143-
// .beforeTask(initTemporaryDirectory)
144-
// .task(ldjsonMultiExport)
145-
// .afterTask(clearTemporaryDirectory)
146-
// .teardown(dropDb)
147-
// .teardown(async function () {
148-
// await rm(this.temporaryDirectory, { recursive: true, force: true });
149-
// })
150-
// .teardown(disconnectClient)
151-
// )
152116
return suite
117+
.benchmark('ldjsonMultiFileUpload', benchmark =>
118+
// https://github.com/mongodb/specifications/blob/master/source/benchmarking/benchmarking.rst#ldjson-multi-file-import
119+
benchmark
120+
.taskSize(565)
121+
.setup(makeClient)
122+
.setup(connectClient)
123+
.setup(initDb)
124+
.setup(dropDb)
125+
.beforeTask(initCollection)
126+
.beforeTask(dropCollection)
127+
.beforeTask(createCollection)
128+
.task(ldjsonMultiUpload)
129+
.teardown(dropDb)
130+
.teardown(disconnectClient)
131+
)
132+
.benchmark('ldjsonMultiFileExport', benchmark =>
133+
// https://github.com/mongodb/specifications/blob/master/source/benchmarking/benchmarking.rst#ldjson-multi-file-export
134+
benchmark
135+
.taskSize(565)
136+
.setup(makeClient)
137+
.setup(connectClient)
138+
.setup(initDb)
139+
.setup(dropDb)
140+
.beforeTask(initCollection)
141+
.beforeTask(dropCollection)
142+
.beforeTask(createCollection)
143+
.beforeTask(ldjsonMultiUpload)
144+
.beforeTask(initTemporaryDirectory)
145+
.task(ldjsonMultiExport)
146+
.afterTask(clearTemporaryDirectory)
147+
.teardown(dropDb)
148+
.teardown(async function () {
149+
await rm(this.temporaryDirectory, { recursive: true, force: true });
150+
})
151+
.teardown(disconnectClient)
152+
)
153153
.benchmark('gridfsMultiFileUpload', benchmark =>
154154
// https://github.com/mongodb/specifications/blob/master/source/benchmarking/benchmarking.rst#gridfs-multi-file-upload
155155
benchmark

0 commit comments

Comments
 (0)