@naturalcycles/nodejs-lib 13.19.0 → 13.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,10 @@ export interface TransformMapOptions<IN = any, OUT = IN> {
18
18
  /**
19
19
  * Number of concurrently pending promises returned by `mapper`.
20
20
  *
21
- * @default 16 (to match default highWatermark option for objectMode streams)
21
+ * Default is 32.
22
+ * It was recently changed up from 16, after some testing that shown that
23
+ * for simple low-cpu mapper functions 32 produces almost 2x throughput.
24
+ * For example, in scenarios like streaming a query from Datastore.
22
25
  */
23
26
  concurrency?: number;
24
27
  /**
@@ -83,7 +86,7 @@ export interface TransformMapStatsSummary extends TransformMapStats {
83
86
  *
84
87
  * Only works in objectMode (due to through2Concurrent).
85
88
  *
86
- * Concurrency defaults to 16.
89
+ * Concurrency defaults to 32.
87
90
  *
88
91
  * If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
89
92
  */
@@ -15,12 +15,12 @@ const stream_util_1 = require("../stream.util");
15
15
  *
16
16
  * Only works in objectMode (due to through2Concurrent).
17
17
  *
18
- * Concurrency defaults to 16.
18
+ * Concurrency defaults to 32.
19
19
  *
20
20
  * If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
21
21
  */
22
22
  function transformMap(mapper, opt = {}) {
23
- const { concurrency = 16, predicate, // we now default to "no predicate" (meaning pass-everything)
23
+ const { concurrency = 32, predicate, // we now default to "no predicate" (meaning pass-everything)
24
24
  errorMode = js_lib_1.ErrorMode.THROW_IMMEDIATELY, flattenArrayOutput, onError, onDone, metric = 'stream', logger = console, } = opt;
25
25
  const started = Date.now();
26
26
  let index = -1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.19.0",
3
+ "version": "13.20.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "docs-serve": "vuepress dev docs",
@@ -40,7 +40,10 @@ export interface TransformMapOptions<IN = any, OUT = IN> {
40
40
  /**
41
41
  * Number of concurrently pending promises returned by `mapper`.
42
42
  *
43
- * @default 16 (to match default highWatermark option for objectMode streams)
43
+ * Default is 32.
44
+ * It was recently changed up from 16, after some testing that shown that
45
+ * for simple low-cpu mapper functions 32 produces almost 2x throughput.
46
+ * For example, in scenarios like streaming a query from Datastore.
44
47
  */
45
48
  concurrency?: number
46
49
 
@@ -117,7 +120,7 @@ export interface TransformMapStatsSummary extends TransformMapStats {
117
120
  *
118
121
  * Only works in objectMode (due to through2Concurrent).
119
122
  *
120
- * Concurrency defaults to 16.
123
+ * Concurrency defaults to 32.
121
124
  *
122
125
  * If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
123
126
  */
@@ -126,7 +129,7 @@ export function transformMap<IN = any, OUT = IN>(
126
129
  opt: TransformMapOptions<IN, OUT> = {},
127
130
  ): TransformTyped<IN, OUT> {
128
131
  const {
129
- concurrency = 16,
132
+ concurrency = 32,
130
133
  predicate, // we now default to "no predicate" (meaning pass-everything)
131
134
  errorMode = ErrorMode.THROW_IMMEDIATELY,
132
135
  flattenArrayOutput,