Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): use os.availableParallelism() for SSG worker threads count #10915

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/docusaurus/src/ssg/ssgExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ function getNumberOfThreads(pathnames: string[]) {
if (typeof SSGWorkerThreadCount !== 'undefined') {
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({
pageCount: pathnames.length,
// TODO use "physical CPUs" instead of "logical CPUs" (like Tinypool does)
// See also https://github.com/tinylibs/tinypool/pull/108
cpuCount: os.cpus().length,
cpuCount,
// 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
minPagesPerCpu: 100,
Expand Down
Loading