[12] RFR(S): 8208277: Code cache heap (-XX:ReservedCodeCacheSize) doesn't work with 1GB LargePages

Tobias Hartmann tobias.hartmann at oracle.com
Tue Dec 4 16:34:24 UTC 2018


Hi,

please review the following patch:
https://bugs.openjdk.java.net/browse/JDK-8208277
http://cr.openjdk.java.net/~thartmann/8208277/webrev.00/

The code cache does not use 1GB pages even if the InitialCodeCacheSize is set to 1GB. The reason for
this is the logic in CodeCache::page_size which sets the page size such that the code cache contains
at least 8 pages to allow for an incremental commit of memory (otherwise, with a 1GB code cache and
1GB pages, all the memory would be committed right from the beginning).

I've fixed this by setting the minimum number of pages to 1 if ReservedCodeCacheSize is equal to
InitialCodeCacheSize. I've also disabled code cache segmentation if the code cache does not at least
contain 8 pages because segmentation would otherwise disable the advantage of huge pages.

Without my fix, only one 1GB page is used for the Java heap:

-sh-4.1# base/jdk-12/fastdebug/bin/java -Xmx1g -Xms1g -XX:+AlwaysPreTouch -XX:+UseG1GC
-XX:+UseLargePages -XX:ReservedCodeCacheSize=1G -XX:InitialCodeCacheSize=1G Test &
[1] 1961
-sh-4.1# grep huge /proc/*/numa_maps
/proc/1961/numa_maps:c0000000 default file=/anon_hugepage\040(deleted) huge anon=1 dirty=1 N0=1
-sh-4.1# grep Huge /proc/meminfo
HugePages_Total:      20
HugePages_Free:       19
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB

With my fix, two 1GB pages are used (one for the heap and one for the code cache):

-sh-4.1# fix/jdk-12/fastdebug/bin/java -Xmx1g -Xms1g -XX:+AlwaysPreTouch -XX:+UseG1GC
-XX:+UseLargePages -XX:ReservedCodeCacheSize=1G -XX:InitialCodeCacheSize=1G Test &[1] 13813
-sh-4.1# grep huge /proc/*/numa_maps
/proc/13813/numa_maps:c0000000 default file=/anon_hugepage\040(deleted) huge anon=1 dirty=1 N0=1
/proc/13813/numa_maps:7f3400000000 default file=/anon_hugepage\040(deleted) huge anon=1 dirty=1 N0=1
-sh-4.1# grep Huge /proc/meminfo
HugePages_Total:      20
HugePages_Free:       18
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB

If InitialCodeCacheSize is set to the default, the code cache will not use 1GB pages to allow
incremental committing of memory.

Thanks,
Tobias


More information about the hotspot-dev mailing list