Skip to content

Commit e18f61b

Browse files
committed
Improve parallelism
1 parent 53a1ff2 commit e18f61b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/stream.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ const { getError } = require('./error')
1212
// call to those functions would be more efficient that creating lots of
1313
// child processes through streaming.
1414
const execStream = function(mapFunc, opts) {
15-
const optsA = { ...DEFAULT_OPTS, ...opts }
15+
const { maxConcurrency, ...optsA } = { ...DEFAULT_OPTS, ...opts }
1616

1717
// `maxConcurrency` `through2` option is not specified because `gulp.src()`
1818
// always has a `highWaterMark` of `16` meaning only 16 files are processed
1919
// at a time in parallel. `maxConcurrency` can then only be used to decrease
2020
// that level of parallelism but `16` is already quite low.
21-
return through.obj(execVinyl.bind(null, { mapFunc, opts: optsA }))
21+
return through.obj(
22+
{ maxConcurrency },
23+
execVinyl.bind(null, { mapFunc, opts: optsA }),
24+
)
2225
}
2326

2427
const DEFAULT_OPTS = {
@@ -29,6 +32,8 @@ const DEFAULT_OPTS = {
2932
stderr: 'pipe',
3033
// Prevents echoing by default because it would be done on each iteration.
3134
echo: false,
35+
// The default is 16 which is too low
36+
maxConcurrency: 100,
3237
}
3338

3439
// eslint-disable-next-line max-params, promise/prefer-await-to-callbacks

0 commit comments

Comments
 (0)