@turntrout/subfont 1.5.0 → 1.5.1
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.
package/lib/concurrencyLimit.js
CHANGED
|
@@ -4,7 +4,9 @@ const os = require('os');
|
|
|
4
4
|
const WORKER_MEMORY_BYTES = 50 * 1024 * 1024; // 50 MB
|
|
5
5
|
|
|
6
6
|
function getMaxConcurrency() {
|
|
7
|
-
|
|
7
|
+
const byMemory = Math.floor(os.freemem() / WORKER_MEMORY_BYTES);
|
|
8
|
+
const byCpu = os.cpus().length * 4;
|
|
9
|
+
return Math.max(1, Math.min(byMemory, byCpu));
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
module.exports = { WORKER_MEMORY_BYTES, getMaxConcurrency };
|
|
@@ -111,7 +111,7 @@ module.exports = function parseCommandLineOptions(argv) {
|
|
|
111
111
|
},
|
|
112
112
|
})
|
|
113
113
|
.options('concurrency', {
|
|
114
|
-
describe: `Maximum number of worker threads for parallel font tracing. Defaults to the number of CPU cores (max 8). Upper bound: ${maxConcurrency} (based on
|
|
114
|
+
describe: `Maximum number of worker threads for parallel font tracing. Defaults to the number of CPU cores (max 8). Upper bound: ${maxConcurrency} (based on free memory and CPU count)`,
|
|
115
115
|
type: 'number',
|
|
116
116
|
})
|
|
117
117
|
.check((argv) => {
|
|
@@ -121,7 +121,7 @@ module.exports = function parseCommandLineOptions(argv) {
|
|
|
121
121
|
}
|
|
122
122
|
if (argv.concurrency > maxConcurrency) {
|
|
123
123
|
throw new Error(
|
|
124
|
-
`--concurrency must not exceed ${maxConcurrency} (each worker uses ~50 MB;
|
|
124
|
+
`--concurrency must not exceed ${maxConcurrency} (each worker uses ~50 MB; ${Math.round(os.freemem() / (1024 * 1024 * 1024))} GB free, ${os.cpus().length} CPUs)`
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
127
|
}
|
package/lib/subfont.js
CHANGED
|
@@ -49,7 +49,7 @@ module.exports = async function subfont(
|
|
|
49
49
|
const maxConcurrency = getMaxConcurrency();
|
|
50
50
|
if (concurrency !== undefined && concurrency > maxConcurrency) {
|
|
51
51
|
throw new UsageError(
|
|
52
|
-
`--concurrency must not exceed ${maxConcurrency} (each worker uses ~50 MB;
|
|
52
|
+
`--concurrency must not exceed ${maxConcurrency} (each worker uses ~50 MB; ${Math.round(os.freemem() / (1024 * 1024 * 1024))} GB free, ${os.cpus().length} CPUs)`
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
package/lib/subsetGeneration.js
CHANGED
package/lib/wasmQueue.js
CHANGED
package/package.json
CHANGED