[GHC] #8594: sysctl name "hw.ncpu" (HW_NCPU) is deprecated in Mac OS X

GHC ghc-devs at haskell.org
Wed Dec 4 06:08:02 UTC 2013


#8594: sysctl name "hw.ncpu" (HW_NCPU) is deprecated in Mac OS X
-----------------------------------+------------------------------------
        Reporter:  kseo            |            Owner:  simonmar
            Type:  task            |           Status:  new
        Priority:  normal          |        Milestone:
       Component:  Runtime System  |          Version:  7.6.3
      Resolution:                  |         Keywords:
Operating System:  MacOS X         |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown    |       Difficulty:  Unknown
       Test Case:                  |       Blocked By:
        Blocking:                  |  Related Tickets:
-----------------------------------+------------------------------------

Comment (by carter):

 I think logicalcpu counts the number of hyperthreaded cores, and
 physicalcpu is the number of cores (ignoring hyperthreading), which should
 be half that number.

 I checked this on my macbook air (which has 2 cores, but 4 via hyper
 threading)

 {{{
 carter repoScratcher/ghc ‹master› »  sysctl hw.physicalcpu
 hw.physicalcpu: 2
 carter repoScratcher/ghc ‹master› »  sysctl hw.logicalcpu
 hw.logicalcpu: 4

 }}}


 I think  the _max variants is because using the Instruments App, you can
 tell OS X to disable hardware multithreading/ adjust the number of cores
 the OS scheduler sees.

 I just disabled the hyperthreading using Instruments, and now i get

 {{{

 carter repoScratcher/ghc ‹master› » sysctl hw.logicalcpu
 hw.logicalcpu: 2
 }}}


 So i think the not max variants make sense, namely hw.logicalcpu ,
 because that actually reflects the number of logical cores the OS sees.


 for general use, using the hyperthreaded cores is probably the right
 default, rather than not. Admittedly, on parallel computations that are
 memory bound, hyperthreading can either boon or a curse, and perhaps this
 is worth benchmarking!

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8594#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list