JAVA confusing number of logical processors on Windows system having more than 64 logical processors

81 Views Asked by At

On our Windows Server 2019, we have 36 cores and 72 logical processors, as seen in Task Manager CPU performance window. And, also, if from command prompt, if I run the command.

echo %NUMBER_OF_PROCESSORS%

It tells me 72. However, from within Java program, if I run the following code snippet,

    int cores = Runtime.getRuntime().availableProcessors();
    String procrs = System.getenv("NUMBER_OF_PROCESSORS");

the value of cores and procrs show me, as 36, each. Same system variable, NUMBER_OF_PROCESSORS is showing me different result from a command prompt vs from within Java program. Why?

I understand, the system variable, NUMBER_OF_PROCESSORS gets automatically set and does not need to be manually intervened ever. Microsoft documentation link on processor groups stated that:

Support for systems that have more than 64 logical processors is based on the concept of a processor group, which is a static set of up to 64 logical processors that is treated as a single scheduling entity. Processor groups are numbered starting with 0. Systems with fewer than 64 logical processors always have a single group, Group 0.

Is this the reason of showing me 36 from within my Java code snippet?

0

There are 0 best solutions below