JDK-8220153 : Shenandoah does not work with TransparentHugePages properly
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 8-shenandoah,11-shenandoah,12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-03-05
  • Updated: 2019-07-29
  • Resolved: 2019-03-10
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 12 JDK 13
12.0.2Fixed 13 b12Fixed
Related Reports
Blocks :  
Blocks :  
Relates :  
Relates :  
Description
Take this:

public class Hello {
	public static void main(String... args) throws Throwable {
		System.out.println("Hello World");
		System.in.read();
	}
}

Config system to accept THP:

$ cat /sys/kernel/mm/transparent_hugepage/{enabled,defrag}
always [madvise] never
always defer defer+madvise [madvise] never

Run with:

$ java -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx100g -Xms100g -XX:+AlwaysPreTouch -XX:+UseTransparentHugePages Hello

Observe heap mapping in /proc/$pid/smaps:

7fd958000000-7ff2bc000000 rw-p 00000000 00:00 0 
Size:           106496000 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Rss:              315712 kB
Pss:              315712 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:    315712 kB
Referenced:       315712 kB
Anonymous:        315712 kB
LazyFree:              0 kB
AnonHugePages:         0 kB
ShmemPmdMapped:        0 kB
Shared_Hugetlb:        0 kB
Private_Hugetlb:       0 kB
Swap:                  0 kB
SwapPss:               0 kB
Locked:                0 kB
VmFlags: rd wr mr mw me ac sd 

It is not really committed (RSS/PSS is low), and no THP is used (AnonHugePages is zero).

JDK-8213927 fixed the similar issue in G1, we need to fix it in Shenandoah as well.

On one hand, this is AlwaysPreTouch problem, but we also have to communicate heap alignment to heap reservation code to use any flavor of large pages.
Comments
Fix Request Backporting this patch fixes the performance problem with Shenandoah. Patch applies cleanly to 12u on top of JDK-8220350, passes hotspot_gc_shenandoah and manual testing with +UseTHP. Change is contained in Shenandoah code.
12-03-2019

RFR: https://mail.openjdk.java.net/pipermail/shenandoah-dev/2019-March/009013.html
08-03-2019

After patch: 7eed30000000-7f0694000000 rw-p 00000000 00:00 0 Size: 106496000 kB KernelPageSize: 4 kB MMUPageSize: 4 kB Rss: 106496000 kB Pss: 106496000 kB Shared_Clean: 0 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirty: 106496000 kB Referenced: 105991768 kB Anonymous: 106496000 kB LazyFree: 0 kB AnonHugePages: 104769536 kB ShmemPmdMapped: 0 kB Shared_Hugetlb: 0 kB Private_Hugetlb: 0 kB Swap: 0 kB SwapPss: 0 kB Locked: 0 kB
05-03-2019

Candidate fix in testing: http://cr.openjdk.java.net/~shade/8220153/webrev.01/
05-03-2019