RFR: 8315923: pretouch_memory by atomic-add-0 fragments huge pages unexpectedly [v3]
Thomas Stuefe
stuefe at openjdk.org
Mon Oct 9 10:08:14 UTC 2023
On Mon, 9 Oct 2023 07:57:04 GMT, Liming Liu <duke at openjdk.org> wrote:
> > PretouchTask attempts to parallelize the pretouching. How well does that work with the use of MADV_POPULATE_WRITE?
>
> I tested it on 64c aarch64 machines with 24GB heaps, 64 gc threads and kernel 6.1, and the startup time of JVM was changed from 0.27s to 0.33s when transparent huge pages (THP) were disabled, while the startup time was reduced from 3.54s to 0.33s when THP were used. The point of the use of MADV_POPULATE_WRITE is to avoid kernel from copying small pages around to form a huge page, and this behavior was cause by https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3917c80280c9
I would only use the system call for pre-touching if we actually use THPs.
Since THPs can be unconditionally enabled without user setting a flag, I'd do:
if (HugePages::thp_mode() == THPMode::always || UseTransparentHugePages) {
madvise...
} else {
use old method
}
Note: if THPs are disabled on the system, VM sets UseTransparentHugePages to false. So we have to deal with just 2 states:
THPs always mode, UTHP can be 1 or 0
THPs madvise mode, UTHP must be 1, otherwise VM does not use THPs
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15781#issuecomment-1752654923
More information about the hotspot-runtime-dev
mailing list