RFR: 8252973: ZGC: Implement Large Pages support on Windows

Stefan Karlsson stefank at openjdk.java.net
Tue Nov 17 07:12:04 UTC 2020


On Tue, 17 Nov 2020 00:16:50 GMT, Monica Beckwith <mbeckwit at openjdk.org> wrote:

>> Please review this patch to add large pages support to ZGC on Windows.
>> 
>> The patch uses a shared AWE section to reserve, commit, and map memory. I've split the code into two implementations, one for the old small pages support, and one for the large pages support. The large pages implementation is chosen if the required APIs are available, memory locking privileges has been setup in Windows (standard requirement for enabling large pages), and the user has selected large pages.
>> 
>> Comparing the small and large pages implementations:
>> 
>> The AWE API requires that the AWE section is provided during the memory reservation stage, and also when committing memory. Previously, ZGC has not needed to share information between the virtual memory layer and the physical memory layer, so there's no straight forward way to pass the section over to the physical memory layer. To keep this dependency local to the Windows implementation, I've chose to use a global reference to the section.
>> 
>> There's no need to use the placeholder API. The placeholders were needed to atomically replace a memory reservation with committed memory and at the same time support memory mapping. The placeholders needed to be dynamically split and coalesced, and some extra infrastructure were added for that. This is not needed with the AWE APIs, and makes that implementation a bit easier to understand IMHO.
>> 
>> When committing memory, the small pages implementation creates one paging file handle per ZGranule (2MB). This allows us to commit/uncommit at arbitrary 2MB boundaries. In the AWE implementation, it's very similar, but whereas the previous implementation chose to use a 2MB boundary, the AWE requires us to keep track of on handle per physical page (2MB again).
>> 
>> The shared AWE memory APIs are available since Windows version 1809. Thanks to Microsoft (@mo-beck and the memory management team) for describing how these APIs could be used to implement the operations we require to support large pages on Windows.
>
> - LGTM.
> - I wanted to add that over the weekend, I took the PR for a spin on my Windows+Arm64 server. I ran SPECJBB2015 in the default (HBIR_RT) and also with PRESET higher IR. Each was run 5 times using the JBB script `:: Number of successive runs set NUM_OF_RUNS=5` and found the run-to-run variance to be less than 2% for all metrics.
> - I also tested this on an x86-64 with different older versions of Windows. And here's an output from one of them with Windows version < 1803:
> `[0.018s][error][gc] Failed to lookup symbol: VirtualAlloc2
> Error occurred during initialization of VM
> ZGC requires Windows version 1803 or later`

Thanks for reviewing @mo-beck!

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

PR: https://git.openjdk.java.net/jdk/pull/1184



More information about the hotspot-gc-dev mailing list