Skip to content

Commit c5a793d

Browse files
authored
fix(core): use os.availableParallelism() for SSG worker threads count (#10915)
1 parent cd27927 commit c5a793d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/docusaurus/src/ssg/ssgExecutor.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ function getNumberOfThreads(pathnames: string[]) {
8080
if (typeof SSGWorkerThreadCount !== 'undefined') {
8181
return SSGWorkerThreadCount;
8282
}
83+
84+
// See also https://github.com/tinylibs/tinypool/pull/108
85+
const cpuCount =
86+
// TODO Docusaurus v4: bump node, availableParallelism() now always exists
87+
typeof os.availableParallelism === 'function'
88+
? os.availableParallelism()
89+
: os.cpus().length;
90+
8391
return inferNumberOfThreads({
8492
pageCount: pathnames.length,
85-
// TODO use "physical CPUs" instead of "logical CPUs" (like Tinypool does)
86-
// See also https://github.com/tinylibs/tinypool/pull/108
87-
cpuCount: os.cpus().length,
93+
cpuCount,
8894
// These are "magic value" that we should refine based on user feedback
8995
// Local tests show that it's not worth spawning new workers for few pages
9096
minPagesPerCpu: 100,

0 commit comments

Comments
 (0)