@@ -16,6 +16,10 @@ import { loadAndParse } from '../utils.mjs';
1616
1717const availableGenerators = Object . keys ( publicGenerators ) ;
1818
19+ // Half of available logical CPUs guarantees in general all physical CPUs are being used
20+ // which in most scenarios is the best way to maximize performance
21+ const optimalThreads = Math . floor ( cpus ( ) . length / 2 ) + 1 ;
22+
1923/**
2024 * @typedef {Object } Options
2125 * @property {Array<string>|string } input - Specifies the glob/path for input files.
@@ -26,6 +30,7 @@ const availableGenerators = Object.keys(publicGenerators);
2630 * @property {string } typeMap - Specifies the path to the Node.js Type Map.
2731 * @property {string } [gitRef] - Git ref/commit URL.
2832 * @property {number } [threads] - Number of threads to allow.
33+ * @property {number } [chunkSize] - Number of items to process per worker thread.
2934 */
3035
3136/**
@@ -61,10 +66,20 @@ export default {
6166 } ,
6267 threads : {
6368 flags : [ '-p' , '--threads <number>' ] ,
69+ desc : 'Number of worker threads to use' ,
6470 prompt : {
6571 type : 'text' ,
6672 message : 'How many threads to allow' ,
67- initialValue : String ( Math . max ( cpus ( ) . length , 1 ) ) ,
73+ initialValue : String ( Math . max ( optimalThreads , 1 ) ) ,
74+ } ,
75+ } ,
76+ chunkSize : {
77+ flags : [ '--chunk-size <number>' ] ,
78+ desc : 'Number of items to process per worker thread (default: auto)' ,
79+ prompt : {
80+ type : 'text' ,
81+ message : 'Items per worker thread' ,
82+ initialValue : '10' ,
6883 } ,
6984 } ,
7085 version : {
@@ -149,6 +164,7 @@ export default {
149164 releases,
150165 gitRef : opts . gitRef ,
151166 threads : parseInt ( opts . threads , 10 ) ,
167+ chunkSize : parseInt ( opts . chunkSize , 10 ) ,
152168 index,
153169 typeMap,
154170 } ) ;
0 commit comments