Project

General

Profile

Actions

Feature #10267

closed

Number of processors

Added by akr (Akira Tanaka) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:65142]

Description

How about a method to obtain number of processors?

Several committers discussed this feature at RubyKaigi 2014.

The number is important to use all available processing power.
Too few processes doesn't use all processors.
Too much processes wastes processing power.

For example, test/lib/test/unit has -j N option for
parallel tests and N is the number of processes to run simultaneously.
But we must specify N explicitly.
I think it should have reasonable default.

I propose a primitive method to obtain number of processors for such purpose:
Etc.nprocessors_online.

It is implemented using sysconf(_SC_NPROCESSORS_ONLN).
It is not standardized but available on many platforms:
GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD,
OpenIndiana, Mac OS X and AIX.

usa-san said he will implement on Windows (after this feature is implemented).

kosaki-san said he will improve the method for container on GNU/Linux.
(If a process is run in a container, usable number of processors may be restricted.
So sysconf(_SC_NPROCESSORS_ONLN) may be not approprate.)

matz accepted this feature including the method name,
Etc.nprocessors_online.

However kosaki-san said he will try to find better name
(by survey container technology).
So I'm waiting.


Files

etc-nprocessors.patch (1.91 KB) etc-nprocessors.patch akr (Akira Tanaka), 09/20/2014 02:45 AM
etc-nprocessors2.patch (2.31 KB) etc-nprocessors2.patch akr (Akira Tanaka), 09/22/2014 03:07 AM
etc-nprocessors3.patch (2.29 KB) etc-nprocessors3.patch akr (Akira Tanaka), 09/22/2014 03:22 AM
etc-nprocessors-kosaki.patch (3.06 KB) etc-nprocessors-kosaki.patch kosaki (Motohiro KOSAKI), 10/01/2014 08:56 PM
etc-nprocessors-kosaki2.patch (3.68 KB) etc-nprocessors-kosaki2.patch kosaki (Motohiro KOSAKI), 10/01/2014 09:48 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0