JDK-8324817 : Parallel GC does not pre-touch all heap pages when AlwaysPreTouch enabled and large page disabled
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 21,22,23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-01-29
  • Updated: 2025-06-04
  • Resolved: 2024-02-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 23
21.0.4-oracleFixed 23 b09Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
AlwaysPreTouch requires all freshly committed pages to be pre-touched. While currently PS GC does not pre-touch heap pages with -XX:+AlwaysPreTouch.
This issue is related to JDK-8315923, which fixes it when huge pages are used. But the bug still stands if regular page are used. For example, on linux we can reproduce this bug when /sys/kernel/mm/transparent_hugepage/enabled is madvise or never, but cannot reproduce when it is always.

A simple way to reproduce, please make sure large pages are NOT used.
Just run a test with the following parameters
-XX:+AlwaysPreTouch -Xms31g -Xmx31g  -XX:+UseParallelGC
There is no pre-touching during heap initialing stage. After initialization, RSS of the test process is much smaller than memory committed.
On the contrary, using -XX:+UseG1GC and run the test again
-XX:+AlwaysPreTouch -Xms31g -Xmx31g  -XX:+UseG1GC
it takes several seconds to pre-touch heap pages during initialization, and RSS usage after initialization is similar to memory committed. This is the expected behavior of  AlwaysPreTouch

This issue related to JDK-8283935, which uses alignment() instead of os::vm_page_size() as pre-touching step size. The value of alignment() is usually bigger than OS page size, which causes most heap pages are not pre-touched.


Comments
[jdk21u-fix-request] Approval Request from Liang Mao Clean backport of fix of pretouch for parallel gc. The original issue is reproduced with linux/aarch64 and fix is verified. The risk is quite low since it only fixed the granularity of pretouch size and won't have any other affection.
22-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/280 Date: 2024-02-22 09:21:24 +0000
22-02-2024

Changeset: 80642dd7 Author: Wang Zhuo <wzhuo@openjdk.org> Committer: Denghui Dong <ddong@openjdk.org> Date: 2024-02-05 06:19:02 +0000 URL: https://git.openjdk.org/jdk/commit/80642dd7af3fcc7c042f11798c5cc899e20b9368
05-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17610 Date: 2024-01-29 08:34:37 +0000
29-01-2024