Skip to content

Use os.availableParallelism() instead of os.cpus().length#5091

Merged
dmichon-msft merged 2 commits intomicrosoft:mainfrom
dmichon-msft:available-parallelism
Jan 30, 2025
Merged

Use os.availableParallelism() instead of os.cpus().length#5091
dmichon-msft merged 2 commits intomicrosoft:mainfrom
dmichon-msft:available-parallelism

Conversation

@dmichon-msft
Copy link
Contributor

Summary

Prefer using os.availableParallelism() to os.cpus().length

The former API was introduced in NodeJS 18 and performs a lot less work than the latter.

Details

In Node 22, os.cpus() opens several files to read info about each CPU on every invocation.

How it was tested

Build, since this API is used to determine parallelism of Rush, as well as various unit tests.

Impacted documentation

Only a few method comments where the default comes from this method.

@dmichon-msft dmichon-msft merged commit e34cf0f into microsoft:main Jan 30, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants