Skip to content

Use nprocessors as default_max_cpu for M:N scheduler#17100

Merged
nobu merged 3 commits into
ruby:masterfrom
thekuwayama:improvement__using_SC_NPROCESSORS_ONLN
Jun 6, 2026
Merged

Use nprocessors as default_max_cpu for M:N scheduler#17100
nobu merged 3 commits into
ruby:masterfrom
thekuwayama:improvement__using_SC_NPROCESSORS_ONLN

Conversation

@thekuwayama
Copy link
Copy Markdown
Contributor

@thekuwayama thekuwayama commented May 23, 2026

Hi!

This PR proposes to remove the hardcoded default_max_cpu value.
Instead, default_max_cpu will be initialized using the value returned by sysconf(_SC_NPROCESSORS_ONLN).

default_max_cpu has a default value that is hardcoded to 8, with a TODO: CPU num? comment. This PR

  • sets default_max_cpu to the value returned by sysconf(_SC_NPROCESSORS_ONLN)
    • to use the number of online CPUs instead of a fixed value
  • fallbacks to 8 for platforms where _SC_NPROCESSORS_ONLN is unavailable

If you intentionally (temporarily) hardcoded it to 8, please close this pull request.

thekuwayama and others added 3 commits May 23, 2026 18:55
Resolves the `TODO: CPU num?`. Uses `sysconf(_SC_NPROCESSORS_ONLN)` with
a fallback to 8, guarded by `#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)`.
…NLN)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thekuwayama thekuwayama changed the title Improvement using sc nprocessors onln Use nprocessors as default_max_cpu for M:N scheduler May 23, 2026
@nobu nobu requested a review from ko1 May 23, 2026 23:10
@nobu nobu merged commit e98f95b into ruby:master Jun 6, 2026
122 of 124 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants