ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:65142] [ruby-trunk - Feature #10267] [Open] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
@ 2014-09-20  2:49 ` akr
  2014-09-20  4:03   ` [ruby-core:65144] " Eric Wong
  2014-09-20  4:12 ` [ruby-core:65145] [ruby-trunk - Feature #10267] " normalperson
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: akr @ 2014-09-20  2:49 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been reported by Akira Tanaka.

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65144] Re: [ruby-trunk - Feature #10267] [Open] Number of processors
  2014-09-20  2:49 ` [ruby-core:65142] [ruby-trunk - Feature #10267] [Open] Number of processors akr
@ 2014-09-20  4:03   ` Eric Wong
  2014-09-20  5:28     ` [ruby-core:65151] " KOSAKI Motohiro
  0 siblings, 1 reply; 17+ messages in thread
From: Eric Wong @ 2014-09-20  4:03 UTC (permalink / raw
  To: Ruby developers

akr@fsij.org wrote:
> matz accepted this feature including the method name,
> Etc.nprocessors_online.

I think the name is too long.  How about naming it after the GNU
coreutils nproc(1) command?

	Etc.nproc(:online)

I think it is important to be able to get all CPUs, not just
online CPUs, too (to workaround old SMP bugs in the kernel):

	Etc.nproc(:all)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65145] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
  2014-09-20  2:49 ` [ruby-core:65142] [ruby-trunk - Feature #10267] [Open] Number of processors akr
@ 2014-09-20  4:12 ` normalperson
  2014-09-20  6:00 ` [ruby-core:65156] " normalperson
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: normalperson @ 2014-09-20  4:12 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Eric Wong.


 akr@fsij.org wrote:
 > matz accepted this feature including the method name,
 > Etc.nprocessors_online.
 
 I think the name is too long.  How about naming it after the GNU
 coreutils nproc(1) command?
 
 	Etc.nproc(:online)
 
 I think it is important to be able to get all CPUs, not just
 online CPUs, too (to workaround old SMP bugs in the kernel):
 
 	Etc.nproc(:all)

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-48996

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65151] Re: [ruby-trunk - Feature #10267] [Open] Number of processors
  2014-09-20  4:03   ` [ruby-core:65144] " Eric Wong
@ 2014-09-20  5:28     ` KOSAKI Motohiro
  2014-09-20  5:57       ` [ruby-core:65155] " Eric Wong
  0 siblings, 1 reply; 17+ messages in thread
From: KOSAKI Motohiro @ 2014-09-20  5:28 UTC (permalink / raw
  To: Ruby developers

On Sat, Sep 20, 2014 at 1:03 PM, Eric Wong <normalperson@yhbt.net> wrote:
> akr@fsij.org wrote:
>> matz accepted this feature including the method name,
>> Etc.nprocessors_online.
>
> I think the name is too long.  How about naming it after the GNU
> coreutils nproc(1) command?
>
>         Etc.nproc(:online)

This is an option. But "proc" is not unclear on ruby context. It is sometimes
procedure, and it is sometimes process. I like processor or cpu.


> I think it is important to be able to get all CPUs, not just
> online CPUs, too

> (to workaround old SMP bugs in the kernel):

What bug?


>         Etc.nproc(:all)

I don't think this is useful. I'd like to explain some kernel internal.
Now, Linux has three type of number of cpus.

1) online
2) present
3) possible

"online" mean cpu is equipped into the cpu socket and work. this value
is mutable when you change
cpu online/offline status. (btw, when cpu detect some failure, it may
become offline automatically)

"present" mean cpu is equipped and doesn't work (offline). This value is mutable
when you add or remove physical cpu (high-end machine only) or logical cpu (only
some hypervisor support it)

"possible" mean how much cpus could be supported by your firmware.
I.e. upper limit
of dynamic cpu adding.

"all" is not clear to me.

If you elaborate why you need nproc(:all), I may be able to suggest better name.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65155] Re: [ruby-trunk - Feature #10267] [Open] Number of processors
  2014-09-20  5:28     ` [ruby-core:65151] " KOSAKI Motohiro
@ 2014-09-20  5:57       ` Eric Wong
  0 siblings, 0 replies; 17+ messages in thread
From: Eric Wong @ 2014-09-20  5:57 UTC (permalink / raw
  To: Ruby developers

KOSAKI Motohiro <kosaki.motohiro@gmail.com> wrote:
> On Sat, Sep 20, 2014 at 1:03 PM, Eric Wong <normalperson@yhbt.net> wrote:
> > akr@fsij.org wrote:
> >> matz accepted this feature including the method name,
> >> Etc.nprocessors_online.
> >
> > I think the name is too long.  How about naming it after the GNU
> > coreutils nproc(1) command?
> >
> >         Etc.nproc(:online)
> 
> This is an option. But "proc" is not unclear on ruby context. It is sometimes
> procedure, and it is sometimes process. I like processor or cpu.

OK.  I mainly want the ability to specify type as arg.

> > I think it is important to be able to get all CPUs, not just
> > online CPUs, too
> 
> > (to workaround old SMP bugs in the kernel):
> 
> What bug?

Anything which may involve synchronizing with softirq or workqueues, I
think...  I suppose my fix in 128dd1759d96ad36c379240f8b9463e8acfd37a1
(missing barrier in EPOLL_CTL_MOD) is one example.  I was never able to
reproduce that bug on my HW, but it worries me because some users are
still on old kernels and potentially affected.

> >         Etc.nproc(:all)
> 
> I don't think this is useful. I'd like to explain some kernel internal.
> Now, Linux has three type of number of cpus.
> 
> 1) online
> 2) present
> 3) possible

I think these names are fine for Ruby.

> "all" is not clear to me.
> 
> If you elaborate why you need nproc(:all), I may be able to suggest better
> name.

I just chose "all" because it matched the nproc(1) --all option
and didn't want to use Linux-specific naming.
But online/present/possible is fine, for now, too.

We could also have extra options like:

:cores - exclude HyperThread  (probably useful for Intel users)
:physical - number of sockets (maybe for affinity)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65156] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
  2014-09-20  2:49 ` [ruby-core:65142] [ruby-trunk - Feature #10267] [Open] Number of processors akr
  2014-09-20  4:12 ` [ruby-core:65145] [ruby-trunk - Feature #10267] " normalperson
@ 2014-09-20  6:00 ` normalperson
  2014-09-22  3:08 ` [ruby-core:65198] " akr
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: normalperson @ 2014-09-20  6:00 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Eric Wong.


 KOSAKI Motohiro <kosaki.motohiro@gmail.com> wrote:
 > On Sat, Sep 20, 2014 at 1:03 PM, Eric Wong <normalperson@yhbt.net> wrote:
 > > akr@fsij.org wrote:
 > >> matz accepted this feature including the method name,
 > >> Etc.nprocessors_online.
 > >
 > > I think the name is too long.  How about naming it after the GNU
 > > coreutils nproc(1) command?
 > >
 > >         Etc.nproc(:online)
 > 
 > This is an option. But "proc" is not unclear on ruby context. It is sometimes
 > procedure, and it is sometimes process. I like processor or cpu.
 
 OK.  I mainly want the ability to specify type as arg.
 
 > > I think it is important to be able to get all CPUs, not just
 > > online CPUs, too
 > 
 > > (to workaround old SMP bugs in the kernel):
 > 
 > What bug?
 
 Anything which may involve synchronizing with softirq or workqueues, I
 think...  I suppose my fix in 128dd1759d96ad36c379240f8b9463e8acfd37a1
 (missing barrier in EPOLL_CTL_MOD) is one example.  I was never able to
 reproduce that bug on my HW, but it worries me because some users are
 still on old kernels and potentially affected.
 
 > >         Etc.nproc(:all)
 > 
 > I don't think this is useful. I'd like to explain some kernel internal.
 > Now, Linux has three type of number of cpus.
 > 
 > 1) online
 > 2) present
 > 3) possible
 
 I think these names are fine for Ruby.
 
 > "all" is not clear to me.
 > 
 > If you elaborate why you need nproc(:all), I may be able to suggest better
 > name.
 
 I just chose "all" because it matched the nproc(1) --all option
 and didn't want to use Linux-specific naming.
 But online/present/possible is fine, for now, too.
 
 We could also have extra options like:
 
 :cores - exclude HyperThread  (probably useful for Intel users)
 :physical - number of sockets (maybe for affinity)

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49001

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65198] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-09-20  6:00 ` [ruby-core:65156] " normalperson
@ 2014-09-22  3:08 ` akr
  2014-09-22  3:14   ` [ruby-core:65200] " Eric Wong
  2014-09-22  3:20 ` [ruby-core:65202] " normalperson
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: akr @ 2014-09-22  3:08 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Akira Tanaka.

File etc-nprocessors2.patch added

Eric Wong wrote:
> akr@fsij.org wrote:
>  > matz accepted this feature including the method name,
>  > Etc.nprocessors_online.
>  
>  I think the name is too long.  How about naming it after the GNU
>  coreutils nproc(1) command?
>  
>  	Etc.nproc(:online)

I feel "proc" as process.

>  I think it is important to be able to get all CPUs, not just
>  online CPUs, too (to workaround old SMP bugs in the kernel):
>  
>  	Etc.nproc(:all)

I (and kosaki-san) agreed that the most important number of processors is
the number of online processors.

I'm not sure that other numbers (all, cores, etc.) is actually useful for
Ruby programming.

However I think the method name can be changed to
Etc.nprocessors.

If someone succeeds to pursuade matz that other numbers are also important, 
we can add an optional argument as Etc.nprocessors(type).


----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49037

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65200] Re: [ruby-trunk - Feature #10267] Number of processors
  2014-09-22  3:08 ` [ruby-core:65198] " akr
@ 2014-09-22  3:14   ` Eric Wong
  0 siblings, 0 replies; 17+ messages in thread
From: Eric Wong @ 2014-09-22  3:14 UTC (permalink / raw
  To: Ruby developers

akr@fsij.org wrote:
> However I think the method name can be changed to
> Etc.nprocessors.
> 
> If someone succeeds to pursuade matz that other numbers are also important, 
> we can add an optional argument as Etc.nprocessors(type).

OK, I think Etc.nprocessors gives room for future changes in case
other types are accepted.

In your patch2, the test is still using the old name.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65202] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-09-22  3:08 ` [ruby-core:65198] " akr
@ 2014-09-22  3:20 ` normalperson
  2014-09-22  3:22 ` [ruby-core:65203] " akr
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: normalperson @ 2014-09-22  3:20 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Eric Wong.


 akr@fsij.org wrote:
 > However I think the method name can be changed to
 > Etc.nprocessors.
 > 
 > If someone succeeds to pursuade matz that other numbers are also important, 
 > we can add an optional argument as Etc.nprocessors(type).
 
 OK, I think Etc.nprocessors gives room for future changes in case
 other types are accepted.
 
 In your patch2, the test is still using the old name.

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49040

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65203] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-09-22  3:20 ` [ruby-core:65202] " normalperson
@ 2014-09-22  3:22 ` akr
  2014-10-01 21:00 ` [ruby-core:65347] " kosaki.motohiro
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: akr @ 2014-09-22  3:22 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Akira Tanaka.

File etc-nprocessors3.patch added

Eric Wong wrote:

>  In your patch2, the test is still using the old name.

Oops.  Fixed.


----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49041

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)
etc-nprocessors3.patch (2.29 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65347] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-09-22  3:22 ` [ruby-core:65203] " akr
@ 2014-10-01 21:00 ` kosaki.motohiro
  2014-10-01 21:09   ` [ruby-core:65348] " Eric Wong
  2014-10-01 21:20 ` [ruby-core:65351] " normalperson
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: kosaki.motohiro @ 2014-10-01 21:00 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Motohiro KOSAKI.

File etc-nprocessors-kosaki.patch added

> 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.)

I wrote an incrementa patch on top of akr's etc-nprocessors3.patch for this purpose.
(see attached etc-nprocessors-kosaki.patch file.)

Comments are welcome!


btw, in akr-san's etc-nprocessor3.patch, Changelog still reference an old name.

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49160

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)
etc-nprocessors3.patch (2.29 KB)
etc-nprocessors-kosaki.patch (3.06 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65348] Re: [ruby-trunk - Feature #10267] Number of processors
  2014-10-01 21:00 ` [ruby-core:65347] " kosaki.motohiro
@ 2014-10-01 21:09   ` Eric Wong
  0 siblings, 0 replies; 17+ messages in thread
From: Eric Wong @ 2014-10-01 21:09 UTC (permalink / raw
  To: Ruby developers

kosaki.motohiro@gmail.com wrote:
> I wrote an incrementa patch on top of akr's etc-nprocessors3.patch for this purpose.
> (see attached etc-nprocessors-kosaki.patch file.)
> 
> Comments are welcome!

Minor: we need to call CPU_FREE in the unlikely case sched_getaffinity
fails.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65351] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2014-10-01 21:00 ` [ruby-core:65347] " kosaki.motohiro
@ 2014-10-01 21:20 ` normalperson
  2014-10-01 21:49 ` [ruby-core:65352] " kosaki.motohiro
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: normalperson @ 2014-10-01 21:20 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Eric Wong.


 kosaki.motohiro@gmail.com wrote:
 > I wrote an incrementa patch on top of akr's etc-nprocessors3.patch for this purpose.
 > (see attached etc-nprocessors-kosaki.patch file.)
 > 
 > Comments are welcome!
 
 Minor: we need to call CPU_FREE in the unlikely case sched_getaffinity
 fails.

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49161

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)
etc-nprocessors3.patch (2.29 KB)
etc-nprocessors-kosaki.patch (3.06 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65352] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-10-01 21:20 ` [ruby-core:65351] " normalperson
@ 2014-10-01 21:49 ` kosaki.motohiro
  2014-10-02  3:23 ` [ruby-core:65359] [ruby-trunk - Feature #10267] [Closed] " akr
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: kosaki.motohiro @ 2014-10-01 21:49 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Motohiro KOSAKI.

File etc-nprocessors-kosaki2.patch added

Thanks Eric.
I also found a design issue in my patch. So, I wrote v2 patch from scratch. 



----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49163

* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)
etc-nprocessors3.patch (2.29 KB)
etc-nprocessors-kosaki.patch (3.06 KB)
etc-nprocessors-kosaki2.patch (3.68 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65359] [ruby-trunk - Feature #10267] [Closed] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2014-10-01 21:49 ` [ruby-core:65352] " kosaki.motohiro
@ 2014-10-02  3:23 ` akr
  2014-10-02  3:26 ` [ruby-core:65360] [ruby-trunk - Feature #10267] " akr
  2014-10-15  9:44 ` [ruby-core:65724] " akr
  11 siblings, 0 replies; 17+ messages in thread
From: akr @ 2014-10-02  3:23 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Akira Tanaka.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r47761.

----------
* ext/etc/etc.c (etc_nprocessors): New method.
  Accepted by matz at RubyKaigi 2014.
  [ruby-core:65142] [Feature #10267]

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49165

* Author: Akira Tanaka
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)
etc-nprocessors3.patch (2.29 KB)
etc-nprocessors-kosaki.patch (3.06 KB)
etc-nprocessors-kosaki2.patch (3.68 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65360] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2014-10-02  3:23 ` [ruby-core:65359] [ruby-trunk - Feature #10267] [Closed] " akr
@ 2014-10-02  3:26 ` akr
  2014-10-15  9:44 ` [ruby-core:65724] " akr
  11 siblings, 0 replies; 17+ messages in thread
From: akr @ 2014-10-02  3:26 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Akira Tanaka.


Ok.

It seems that there is no problem with the method name, Etc.nprocessors.

So I committed my patch (etc-nprocessors3.patch).

Please commit your patch, kosaki-san.
(I didn't commit the patch just because separate commits makes "svn ann" more clearer.)

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49166

* Author: Akira Tanaka
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)
etc-nprocessors3.patch (2.29 KB)
etc-nprocessors-kosaki.patch (3.06 KB)
etc-nprocessors-kosaki2.patch (3.68 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-core:65724] [ruby-trunk - Feature #10267] Number of processors
       [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2014-10-02  3:26 ` [ruby-core:65360] [ruby-trunk - Feature #10267] " akr
@ 2014-10-15  9:44 ` akr
  11 siblings, 0 replies; 17+ messages in thread
From: akr @ 2014-10-15  9:44 UTC (permalink / raw
  To: ruby-core

Issue #10267 has been updated by Akira Tanaka.


It seems kosaki-san is busy.

I committed etc-nprocessors-kosaki2.patch at r47939.

----------------------------------------
Feature #10267: Number of processors
https://bugs.ruby-lang.org/issues/10267#change-49458

* Author: Akira Tanaka
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
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-nprocessors2.patch (2.31 KB)
etc-nprocessors3.patch (2.29 KB)
etc-nprocessors-kosaki.patch (3.06 KB)
etc-nprocessors-kosaki2.patch (3.68 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-10-15 10:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-10267.20140920024949@ruby-lang.org>
2014-09-20  2:49 ` [ruby-core:65142] [ruby-trunk - Feature #10267] [Open] Number of processors akr
2014-09-20  4:03   ` [ruby-core:65144] " Eric Wong
2014-09-20  5:28     ` [ruby-core:65151] " KOSAKI Motohiro
2014-09-20  5:57       ` [ruby-core:65155] " Eric Wong
2014-09-20  4:12 ` [ruby-core:65145] [ruby-trunk - Feature #10267] " normalperson
2014-09-20  6:00 ` [ruby-core:65156] " normalperson
2014-09-22  3:08 ` [ruby-core:65198] " akr
2014-09-22  3:14   ` [ruby-core:65200] " Eric Wong
2014-09-22  3:20 ` [ruby-core:65202] " normalperson
2014-09-22  3:22 ` [ruby-core:65203] " akr
2014-10-01 21:00 ` [ruby-core:65347] " kosaki.motohiro
2014-10-01 21:09   ` [ruby-core:65348] " Eric Wong
2014-10-01 21:20 ` [ruby-core:65351] " normalperson
2014-10-01 21:49 ` [ruby-core:65352] " kosaki.motohiro
2014-10-02  3:23 ` [ruby-core:65359] [ruby-trunk - Feature #10267] [Closed] " akr
2014-10-02  3:26 ` [ruby-core:65360] [ruby-trunk - Feature #10267] " akr
2014-10-15  9:44 ` [ruby-core:65724] " akr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).