mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 11:47:23 +02:00
fix(core): use os.availableParallelism()
for SSG worker threads count (#10915)
This commit is contained in:
parent
cd2792775e
commit
c5a793de9d
1 changed files with 9 additions and 3 deletions
|
@ -80,11 +80,17 @@ function getNumberOfThreads(pathnames: string[]) {
|
||||||
if (typeof SSGWorkerThreadCount !== 'undefined') {
|
if (typeof SSGWorkerThreadCount !== 'undefined') {
|
||||||
return SSGWorkerThreadCount;
|
return SSGWorkerThreadCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See also https://github.com/tinylibs/tinypool/pull/108
|
||||||
|
const cpuCount =
|
||||||
|
// TODO Docusaurus v4: bump node, availableParallelism() now always exists
|
||||||
|
typeof os.availableParallelism === 'function'
|
||||||
|
? os.availableParallelism()
|
||||||
|
: os.cpus().length;
|
||||||
|
|
||||||
return inferNumberOfThreads({
|
return inferNumberOfThreads({
|
||||||
pageCount: pathnames.length,
|
pageCount: pathnames.length,
|
||||||
// TODO use "physical CPUs" instead of "logical CPUs" (like Tinypool does)
|
cpuCount,
|
||||||
// See also https://github.com/tinylibs/tinypool/pull/108
|
|
||||||
cpuCount: os.cpus().length,
|
|
||||||
// These are "magic value" that we should refine based on user feedback
|
// These are "magic value" that we should refine based on user feedback
|
||||||
// Local tests show that it's not worth spawning new workers for few pages
|
// Local tests show that it's not worth spawning new workers for few pages
|
||||||
minPagesPerCpu: 100,
|
minPagesPerCpu: 100,
|
||||||
|
|
Loading…
Add table
Reference in a new issue