Reputation: 3
Recently I have noticed that in Linux distros we have huge page memories that can be set to always to allow the system to use huge pages all the time, madvise to let the applications to determine if they want to use huge pages, or never.
This capability some times can reduce the application performance.
In JVM we have two parameters than can be activated to control this OS capability.
LargePageHeapSizeThreshold: If this value is less than MaxHeapSize JVM uses Large Page Size.
UseTransparentHugePages: It is a boolean that can be true or false.
My question is that is setting the LargePageHeapSizeThreshold to a value less than MaxHeapSize activates the huge page even if the UseTransparentHugePages=false?
Does setting huge page size to always in linux activates the JVM to use large page even if UseTransparentHugePages=false?
Upvotes: 0
Views: 1090
Reputation: 98495
is setting the LargePageHeapSizeThreshold to a value less than MaxHeapSize activates the huge page even if the UseTransparentHugePages=false?
No, it works the other way round: if the maximum heap size is smaller than LargePageHeapSizeThreshold
, large pages are disabled by default.
However, this applies only to the 'client' VM, which has no C2 or Graal compiler (a quite exotic case nowadays). So, in the most popular versions of JVM the flag LargePageHeapSizeThreshold
affects nothing at all.
Does setting huge page size to always in linux activates the JVM to use large page even if UseTransparentHugePages=false?
I assume you mean the following setting:
echo always >/sys/kernel/mm/transparent_hugepage/enabled
In this mode Linux attempts to allocate huge pages for anonymous memory mappings (including Java Heap and Code Cache) without application even knowing about huge pages. So, yes - JVM may benefit from this option even when it does not care about huge pages itself.
On the other hand, it is not guaranteed that Java Heap will always use huge pages in this mode. If Linux fails to allocate huge pages for a memory region (e.g. because of the fragmentation), it will silently fall back to using normal pages.
Upvotes: 2