Skip to content

Commit af059a7

Browse files
committed
Support Alpha architecture for processor_count
Alpha machines with Linux do have /proc/cpuinfo but its format is different from normal Linux machines, and most specifically the processor entry is missing. Moreover, Alpha machines can be configured to compartimentalize their CPUs into different machines leading to further confusion when reading /proc/cpuinfo. Using /usr/bin/nproc seems to be the most reliable method of determining the number of processors on Alpha. Since reading /proc/cpuinfo is not reliable this patch places the nproc method before trying /proc/cpuinfo. For futher reference see our downstream bug report at https://bugs.gentoo.org/show_bug.cgi?id=587986
1 parent 83718fc commit af059a7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Support Alpha with `Concurrent::processor_count`
2+
13
## Current Release v1.0.2 (2 May 2016)
24

35
* Fix bug with `Concurrent::Map` MRI backend `#inspect` method

lib/concurrent/utility/processor_counter.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def initialize
2828
# processor", which taked into account hyperthreading.
2929
#
3030
# * AIX: /usr/sbin/pmcycles (AIX 5+), /usr/sbin/lsdev
31+
# * Alpha: /usr/bin/nproc (/proc/cpuinfo exists but cannot be used)
3132
# * BSD: /sbin/sysctl
3233
# * Cygwin: /proc/cpuinfo
3334
# * Darwin: /usr/bin/hwprefs, /usr/sbin/sysctl
@@ -84,6 +85,8 @@ def compute_processor_count
8485
result = WIN32OLE.connect("winmgmts://").ExecQuery(
8586
"select NumberOfLogicalProcessors from Win32_Processor")
8687
result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
88+
elsif File.executable?("/usr/bin/nproc")
89+
IO.popen("/usr/bin/nproc --all").read.to_i
8790
elsif File.readable?("/proc/cpuinfo")
8891
IO.read("/proc/cpuinfo").scan(/^processor/).size
8992
elsif File.executable?("/usr/bin/hwprefs")

0 commit comments

Comments
 (0)