[concurrency-interest] Any support to determine the number of processors ?

Brian Goetz brian@quiotix.com
Tue, 22 Jul 2003 17:38:57 -0700

>         When working with a pool of threads, you can decide to optimize 
> its size according to the number of processors of your computer and to 
> the tasks realized. This way you should be able to optimize the 
> processing and you would avoid involving the user in configurating some 
> resource file while default values can apply automatically. I was 
> searching in the JSR 166 for a method giving access to number of logical 
> and physical processors. On some recent Intel processors, like PIV or 
> Xeon, the hyperthreading technology let's you execute up to 2 threads 
> simultaneously 
> <http://www.intel.com/technology/hyperthread/index.htm?iid=ipp_srvr_proc_xeon+feature_f2htt&>http://www.intel.com/technology/hyperthread/index.htm?iid=ipp_srvr_proc_xeon+feature_f2htt&. 
> I don't know about SPARC processors or other models.

This is a more complicated issue than it might immediately 
appear.  Clearly, number of available processors is one of the important 
inputs in determining a sensible thread pool size.  On the other hand, the 
choice of size of thread pools really is a _deployment_ time decision, not 
a development time decision.  In most enterprise applications, the 
application deployer will have more information available with which to 
make a sensible decision (specific hardware information, other applications 
running on the same server, administrative policies, etc) than will the 
developer.  So having the developer "auto-size" these pools may encourage 
making these formulas hard-coded within applications, instead of exposing 
them and letting the application deployer make those decisions.

Facilities like Xeon HT further complicate the question -- is a Xeon HT one 
processor, or two?  It depends on the question that you're really trying to 
answer, and I'm sure you could pose questions that support either answer as 
the "right, obvious, most sensible" answer.

Brian Goetz
Quiotix Corporation
brian@quiotix.com           Tel: 650-843-1300            Fax: 650-324-8032