[External] : Re: Wither transparent huge pages for the heap?
Stefan Johansson
stefan.johansson at oracle.com
Thu Nov 6 09:43:26 UTC 2025
Hi Peter,
G1 was the only collector really affected by the bug, apart from the
logging not showing the desired page size. The other collectors still
used transparent huge pages for their mapping, even if the page size
reported in the logs did not reflect that. This is the reason for the
bug and release note only talking about G1.
But you are correct, the code changes affect all GCs and the logging
will be "fixed" for the other GCs as well. When using transparent huge
pages this logging should be seen as the desired page size, because we
can't guarantee that the mappings actually get backed by huge pages
(it's up to the kernel). The best way to check this (or at least one
way) is to look in /proc/<pid>/smaps and verify that the mappings have a
1 for the THPeligible field, if so the mapping can use THP and if the
field AnonHugePages show something larger than 0 they are actually used.
Regarding the workaround, as you noted, it will not help the logging,
but it will ensure G1 is using transparent huge pages and getting better
performance.
Cheers,
Stefan
On 2025-11-06 01:00, Peter Kessler OS wrote:
>
> The title of JDK-8366434 <https://bugs.openjdk.org/browse/JDK-8366434>
> suggests the issue only affects G1, but I find it also affects ParallelGC:
>
> $ "${OPENJDK_DIR}"/ jdk-25.0.1/bin/java -showversion
> -XX:+UseParallelGC -XX:+UseTransparentHugePages -Xms12g -Xmx12g
> -Xlog:pagesize=info -cp ~/Play/Java HelloWorld
>
> [0.001s][info][pagesize] Explicit hugepage support:
>
> [0.001s][info][pagesize] hugepage size: 2M
>
> [0.001s][info][pagesize] hugepage size: 512M
>
> [0.001s][info][pagesize] hugepage size: 16G
>
> [0.001s][info][pagesize] default hugepage size: 512M
>
> [0.001s][info][pagesize] Transparent hugepage (THP) support:
>
> [0.001s][info][pagesize] THP mode: always
>
> [0.001s][info][pagesize] THP pagesize: 512M
>
> [0.001s][info][pagesize] Shared memory transparent hugepage (THP) support:
>
> [0.001s][info][pagesize] Shared memory THP mode: never
>
> [0.001s][info][pagesize] JVM will attempt to prevent THPs in thread
> stacks.
>
> [0.001s][info][pagesize] UseLargePages=1, UseTransparentHugePages=1
>
> [0.001s][info][pagesize] Large page support enabled. Usable page
> sizes: 64k, 512M. Default large page size: 512M.
>
> [0.002s][info][pagesize] CodeHeap 'profiled nmethods': min=2496K
> max=118272K base=0x00004000108d0000 size=118272K page_size=64K
>
> [0.002s][info][pagesize] CodeHeap 'non-nmethods': min=2496K max=9152K
> base=0x0000400017c50000 size=9152K page_size=64K
>
> [0.002s][info][pagesize] CodeHeap 'non-profiled nmethods': min=2496K
> max=118336K base=0x0000400018540000 size=118336K page_size=64K
>
> [0.002s][info][pagesize] Heap: min=12G max=12G base=0x0000000500000000
> size=12G page_size=64K
>
> [0.002s][info][pagesize] Card Table: min=24M max=24M
> base=0x0000400001ee0000 size=24M page_size=64K
>
> [0.004s][info][pagesize] Mark Bitmap: min=192M max=192M
> base=0x0000400025000000 size=192M page_size=64K
>
> [0.004s][info][pagesize] Parallel Compact Data: min=960K max=960K
> base=0x00004000038f0000 size=960K page_size=64K
>
> openjdk version "25.0.1" 2025-10-21
>
> OpenJDK Runtime Environment (build 25.0.1+8-27)
>
> OpenJDK 64-Bit Server VM (build 25.0.1+8-27, mixed mode, sharing)
>
> Hello world!
>
> The Release Note <https://bugs.openjdk.org/browse/JDK-8366564> says
>
> A workaround to allow the use of transparent huge pages with G1 is to
> configure the THP mode as `always`:
> ```
> # echo always > /sys/kernel/mm/transparent_hugepage/enabled
> ```
>
> but I observe the issue (see above) even though my system has
> transparent huge pages configured to "always":
>
> $ cat /sys/kernel/mm/transparent_hugepage/enabled
>
> [always] madvise never
>
> It looks like code changes
> <https://urldefense.com/v3/__https://github.com/openjdk/jdk25u/commit/a66fe2a8765c085b8faeb9c89751306b834935ce__;!!ACWV5N9M2RV99hQ!I3aw69n0QwouHq93Is1Dkya_UbiVCL8IBlGtqUnC8-TD1ov2SvHcaN3g_nvnxhvDWkIVR-l393WuYOSX6v77twiwtBUTxHmFnECdcQ$>
> affect code shared by all (?) the collectors, so a fix for G1GC
> probably fixes ParallelGC, even if the description only covers G1G1.
> The tests in there seem capable of testing SerialGC, ParallelGC, and
> G1GC, so that is reassuring.
>
> I will wait patiently for JDK 25.0.2.
>
> ... peter
>
> *From: *Stefan Johansson <stefan.johansson at oracle.com>
> *Date: *Tuesday, November 4, 2025 at 01:38
> *To: *Peter Kessler OS <peter.kessler at os.amperecomputing.com>,
> "hotspot-gc-use at openjdk.java.net" <hotspot-gc-use at openjdk.java.net>
> *Subject: *Re: Wither transparent huge pages for the heap?
>
> Hi Peter,
>
> This is a known issue [1], and we found the problem a bit to late for
> the fix to be included in the initial release of JDK 25. See the JBS
> issue [2] for more details.
>
> The fix for the problem is scheduled to be released in JDK 25.0.2. The
> workaround (which is not optimal) is to configure the THP mode to
> 'always' in:
> /sys/kernel/mm/transparent_hugepage/enabled
>
> This will make the heap be backed by transparent huge pages. When
> configured as 'always' you don't need the -XX:+UseTransparentHugePages
> flag. The logs won't reflect the actual page size used if I'm not
> mistaken, but you can use OS tools to verify that transparent huge
> pages are used for the heap.
>
> Hope this helps,
> Stefan
>
> [1] https://www.oracle.com/java/technologies/javase/25-relnote-issues.html
> [2] https://bugs.openjdk.org/browse/JDK-8366434
>
> On 2025-11-03 21:55, Peter Kessler OS wrote:
>
> Between JDK-24 (24.0.2+12-54, dba 24.0.2) and JDK-25 (25.0.1+8-27,
> dba 25.0.1), running an application on a machine with 64KiB system
> page size and 512MiB transparent huge pages, I see this difference:
>
> $ "${OPENJDK_DIR}"/jdk-24.0.2/bin/java -showversion
> -XX:+UseTransparentHugePages -Xmx12g -Xms12g -Xlog:pagesize=info
> HelloWorld
>
> [0.001s][info][pagesize] Explicit hugepage support:
>
> [0.001s][info][pagesize] hugepage size: 2M
>
> [0.001s][info][pagesize] hugepage size: 512M
>
> [0.001s][info][pagesize] hugepage size: 16G
>
> [0.001s][info][pagesize] default hugepage size: 512M
>
> [0.001s][info][pagesize] Transparent hugepage (THP) support:
>
> [0.001s][info][pagesize] THP mode: always
>
> [0.001s][info][pagesize] THP pagesize: 512M
>
> [0.001s][info][pagesize] Shared memory transparent hugepage (THP)
> support:
>
> [0.001s][info][pagesize] Shared memory THP mode: never
>
> [0.001s][info][pagesize] JVM will attempt to prevent THPs in
> thread stacks.
>
> [0.001s][info][pagesize] UseLargePages=1, UseTransparentHugePages=1
>
> [0.001s][info][pagesize] Large page support enabled. Usable page
> sizes: 64k, 512M. Default large page size: 512M.
>
> [0.002s][info][pagesize] CodeHeap 'profiled nmethods': min=2496K
> max=118272K base=0x00004000108d0000 size=118272K page_size=64K
>
> [0.002s][info][pagesize] CodeHeap 'non-nmethods': min=2496K
> max=9152K base=0x0000400017c50000 size=9152K page_size=64K
>
> [0.002s][info][pagesize] CodeHeap 'non-profiled nmethods':
> min=2496K max=118336K base=0x0000400018540000 size=118336K
> page_size=64K
>
> [0.003s][info][pagesize] Heap: min=12G max=12G
> base=0x0000000500000000 size=12G page_size=512M
>
> [0.003s][info][pagesize] Block Offset Table: req_size=24M
> req_page_size=64K base=0x0000400024440000 size=24M page_size=64K
>
> [0.003s][info][pagesize] Card Table: req_size=24M
> req_page_size=64K base=0x0000400025c40000 size=24M page_size=64K
>
> [0.003s][info][pagesize] Mark Bitmap: req_size=192M
> req_page_size=64K base=0x0000400027440000 size=192M page_size=64K
>
> openjdk version "24.0.2" 2025-07-15
>
> OpenJDK Runtime Environment (build 24.0.2+12-54)
>
> OpenJDK 64-Bit Server VM (build 24.0.2+12-54, mixed mode, sharing)
>
> Hello world!
>
> versus
>
> $ "${OPENJDK_DIR}"/jdk-25.0.1/bin/java -showversion
> -XX:+UseTransparentHugePages -Xmx12g -Xms12g -Xlog:pagesize=info
> HelloWorld
>
> [0.001s][info][pagesize] Explicit hugepage support:
>
> [0.001s][info][pagesize] hugepage size: 2M
>
> [0.001s][info][pagesize] hugepage size: 512M
>
> [0.001s][info][pagesize] hugepage size: 16G
>
> [0.001s][info][pagesize] default hugepage size: 512M
>
> [0.001s][info][pagesize] Transparent hugepage (THP) support:
>
> [0.001s][info][pagesize] THP mode: always
>
> [0.001s][info][pagesize] THP pagesize: 512M
>
> [0.001s][info][pagesize] Shared memory transparent hugepage (THP)
> support:
>
> [0.001s][info][pagesize] Shared memory THP mode: never
>
> [0.001s][info][pagesize] JVM will attempt to prevent THPs in
> thread stacks.
>
> [0.001s][info][pagesize] UseLargePages=1, UseTransparentHugePages=1
>
> [0.001s][info][pagesize] Large page support enabled. Usable page
> sizes: 64k, 512M. Default large page size: 512M.
>
> [0.002s][info][pagesize] CodeHeap 'profiled nmethods': min=2496K
> max=118272K base=0x00004000108d0000 size=118272K page_size=64K
>
> [0.002s][info][pagesize] CodeHeap 'non-nmethods': min=2496K
> max=9152K base=0x0000400017c50000 size=9152K page_size=64K
>
> [0.002s][info][pagesize] CodeHeap 'non-profiled nmethods':
> min=2496K max=118336K base=0x0000400018540000 size=118336K
> page_size=64K
>
> [0.003s][info][pagesize] Heap: min=12G max=12G
> base=0x0000000500000000 size=12G page_size=64K
>
> [0.003s][info][pagesize] Block Offset Table: req_size=24M
> req_page_size=64K base=0x0000400024550000 size=24M page_size=64K
>
> [0.003s][info][pagesize] Card Table: req_size=24M
> req_page_size=64K base=0x0000400025d50000 size=24M page_size=64K
>
> [0.003s][info][pagesize] Mark Bitmap: req_size=192M
> req_page_size=64K base=0x0000400027550000 size=192M page_size=64K
>
> openjdk version "25.0.1" 2025-10-21
>
> OpenJDK Runtime Environment (build 25.0.1+8-27)
>
> OpenJDK 64-Bit Server VM (build 25.0.1+8-27, mixed mode, sharing)
>
> Hello world!
>
> Why am I not getting 512MiB pages for my heap in JDK-25, when I
> was getting 512MiB pages for my heap in JDK-24? Maybe more to the
> point: How do I get transparent huge pages for my heap in JDK-25?
>
> ... peter
>
>
>
> _______________________________________________
>
> hotspot-gc-use mailing list
>
> hotspot-gc-use at openjdk.org
>
> https://mail.openjdk.org/mailman/listinfo/hotspot-gc-use
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-gc-use/attachments/20251106/7826dc04/attachment-0001.htm>
More information about the hotspot-gc-use
mailing list