Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 82c8b90

Browse files
feat: default stream concurrency to 32 (up from 16)
1 parent 1ca08c2 commit 82c8b90

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/adapter/file/localFile.persistence.plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class LocalFilePersistencePlugin implements FileDBPersistencePlugin {
7171
}
7272

7373
async saveFiles(ops: DBSaveBatchOperation<any>[]): Promise<void> {
74-
await pMap(ops, async op => await this.saveFile(op.table, op.rows), { concurrency: 16 })
74+
await pMap(ops, async op => await this.saveFile(op.table, op.rows), { concurrency: 32 })
7575
}
7676

7777
async saveFile<ROW extends ObjectWithId>(table: string, rows: ROW[]): Promise<void> {

src/commondao/common.dao.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export interface CommonDaoStreamOptions<IN>
321321

322322
/**
323323
* When chunkSize is set - this option controls how many chunks to run concurrently.
324-
* Defaults to 16, "the magic number of JavaScript concurrency".
324+
* Defaults to 32.
325325
*/
326326
chunkConcurrency?: number
327327
}

src/commondao/common.dao.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM> {
920920
* "Streaming" is implemented by buffering incoming rows into **batches**
921921
* (of size opt.chunkSize, which defaults to 500),
922922
* and then executing db.saveBatch(chunk) with the concurrency
923-
* of opt.chunkConcurrency (which defaults to 16).
923+
* of opt.chunkConcurrency (which defaults to 32).
924924
*/
925925
streamSaveTransform(opt: CommonDaoStreamSaveOptions<DBM> = {}): Transform[] {
926926
this.requireWriteAccess()
@@ -936,7 +936,7 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM> {
936936
const excludeFromIndexes = opt.excludeFromIndexes || this.cfg.excludeFromIndexes
937937
const { beforeSave } = this.cfg.hooks!
938938

939-
const { chunkSize = 500, chunkConcurrency = 16, errorMode } = opt
939+
const { chunkSize = 500, chunkConcurrency = 32, errorMode } = opt
940940

941941
return [
942942
transformMap<BM, DBM>(
@@ -1019,7 +1019,7 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM> {
10191019
let deleted = 0
10201020

10211021
if (opt.chunkSize) {
1022-
const { chunkSize, chunkConcurrency = 16 } = opt
1022+
const { chunkSize, chunkConcurrency = 32 } = opt
10231023

10241024
await _pipeline([
10251025
this.cfg.db.streamQuery<DBM>(q.select(['id']), opt),

src/kv/commonKeyValueDao.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export class CommonKeyValueDao<T> {
224224
}
225225
},
226226
{
227-
concurrency: 16,
227+
concurrency: 32,
228228
},
229229
)
230230
}
@@ -248,7 +248,7 @@ export class CommonKeyValueDao<T> {
248248
}
249249
},
250250
{
251-
concurrency: 16,
251+
concurrency: 32,
252252
},
253253
)
254254
}

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,9 @@
884884
zod "^3.20.2"
885885

886886
"@naturalcycles/nodejs-lib@^13.0.1", "@naturalcycles/nodejs-lib@^13.0.2", "@naturalcycles/nodejs-lib@^13.1.1":
887-
version "13.19.0"
888-
resolved "https://registry.yarnpkg.com/@naturalcycles/nodejs-lib/-/nodejs-lib-13.19.0.tgz#c5705a2636718e85b6aef8cb40fe19500d18d5ea"
889-
integrity sha512-kc7Sx95amibbj6jHTej7UC1z1BVNBrSraEurcCWbKBnJWBAsp2f52yc5stnehOwD9J8cXm7DJtWdVdwwArpkiw==
887+
version "13.20.0"
888+
resolved "https://registry.yarnpkg.com/@naturalcycles/nodejs-lib/-/nodejs-lib-13.20.0.tgz#8d97cef2f685b387559d5be78d91f942d411d92f"
889+
integrity sha512-qUmYEK2m58N2MwMXri+zqL/bJvc58FqBx1aV31Xtu6BiGMyRUZrqls+SuYCUW+/oJj9ULWFcBL08AHSbLnWC9A==
890890
dependencies:
891891
"@naturalcycles/js-lib" "^14.0.0"
892892
"@types/js-yaml" "^4.0.9"

0 commit comments

Comments
 (0)