RFR: 6942632: Hotspot should be able to use more than 64 logical processors on Windows [v19]

David Holmes dholmes at openjdk.org
Tue Apr 30 04:08:07 UTC 2024


On Mon, 29 Apr 2024 15:34:37 GMT, Saint Wesonga <duke at openjdk.org> wrote:

>> Windows processor groups support a maximum of 64 logical processors per processor group. OpenJDK currently uses the GetSystemInfo API to get the number of processors on the system. GetSystemInfo only returns the number of processors in the current processor group, which is at most 64. Therefore, OpenJDK needs to be updated to support the use of all available processors across all Windows processor groups. However, this should only be done when running on Windows 11 or Windows Server 2022 or later Windows operating systems.
>> 
>> Starting with Windows 11 and Windows Server 2022, applications are no longer constrained by default to a single processor group. Instead, processes and their threads have processor affinities that by default span all processors in the system, across multiple groups on machines with more than 64 processors. This is in contrast to previous operating system versions where the processor group affinity APIs needed to be used to assign each thread a specific processor group. See https://learn.microsoft.com/en-us/windows/win32/procthread/processor-groups#behavior-starting-with-windows-11-and-windows-server-2022
>> 
>> The key changes required are:
>> 
>> 1. Detecting Windows 11 or Windows Server 2022 or later.
>> 1. Using the The GetLogicalProcessorInformationEx function to correctly retrieve the total number of processors available on the system. This function was introduced in Windows 7 so its availability needs to be explicitly determined.
>> 1. Updating the calculation of the number of active processors.
>>     1. Processor affinities can be set in a Windows job object and if the JVM is launched in a job object, these affinities restrict the processors that the JVM can use (regardless of how many processors the system has).
>>     1. The JVM can also be launched from the command prompt by using the "start" command to set processor affinities instead of using a job object. This command sets the process group affinity of the new process to a single processor group (since the affinity mask is a 64-bit value). The affinity mask passed to the "start" command explicitly sets the number of available processors for the JVM and is necessarily at most 64, even if the machine has more than 64 processors.
>>     1. If no affinity restrictions are present (i.e. there is no job object in use and an affinity setting command was not used), then all cores on the system will be available to the JVM.
>> 
>> ### Test Scenarios
>> This simple Java program can be use...
>
> Saint Wesonga has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix command line used to launch java

Thanks for adding the test but it needs to be adapted to how we write/execute the tests today. See comments below.

test/hotspot/jtreg/runtime/6942632/GetAvailableProcessors.java line 1:

> 1: /*

Note we do not us the bugid in the path when creating tests these days. Please place the test under runtime/os/windows/

test/hotspot/jtreg/runtime/6942632/GetAvailableProcessors.sh line 1:

> 1: #

We also do not use shell scripts like this for new tests if we can avoid it. The compilation should be done via jtreg. The exec'ing of processes should be via the ProcessTools test library.

test/hotspot/jtreg/runtime/6942632/exeGetProcessorInfo.c line 1:

> 1: /*

The compilation of the native part of this test should only happen on windows. You need to add appropriate instructions to build it, and appropriate instructions to exclude it on non-windows in make/test/JtregNativeHotspot.gmk. Then you don't need the win64 ifdef guards.

-------------

Changes requested by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/17576#pullrequestreview-2030152692
PR Review Comment: https://git.openjdk.org/jdk/pull/17576#discussion_r1584095585
PR Review Comment: https://git.openjdk.org/jdk/pull/17576#discussion_r1584097820
PR Review Comment: https://git.openjdk.org/jdk/pull/17576#discussion_r1584099657


More information about the hotspot-runtime-dev mailing list