I am trying to measure the performance gain of using large memory pages in Windows 7 HotSpot JVM. In order to do that, I need to monitor the JVM memory usage to make sure that Large Pages are actually utilized. Unfortunately, I can't find away to achieve that. Below is a description of the setup and trials I have done:
Environment Setup
I am using 64-bit Windows 7 ultimate edition for my tests. "Lock pages in memory" Windows security policy is enabled as described in Java Support for Large Memory Pages. I also verified that Large Pages feature is enabled by running java version command as the following:
java -XX:+UseLargePages -version
Where I get the following results, which dedicate that large pages feature is enabled:
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
I used this sample Java program from this video in all my trials to consume all the memory available for the java heap:
public class InfinteStringHashmap {
public static void main(String[] args) throws Exception{
Map<Long, String> map = new HashMap<Long, String>();
for(long i=1; true; i++){
StringBuilder sb = new StringBuilder();
for(long j=0;j<i;j++) sb.append(" ");
map.put(i, sb.toString());
if(i % 1000 == 0){
System.out.print(".");
Thread.sleep(1000);
}
}
}
}
I ran this sample program using the following command (with a fixed heap size of 512m for example):
java -Xms512m -Xmx512m -XX:+UseLargePages InfinteStringHashmap
I also tried other heap sizes as small as 12MB and as large as 10GB. Please note that I run my test application immediately after restarting the machine to make sure my free RAM memory is not fragmented.
Failed trials to monitor the memory
In order to verify whether Large Memory Pages are used or not, I tried:
Edit: I tried the following tools that were suggested in the comments:
Java Mission Controller: Doesn't provide page size info.
Process Explorer: same as above
Is there away to measure the page size of a process or monitor the usage of large memory pages in Windows ??
The easy way to monitor Heap usage is by using a commercial APM (Application Performance management tool) such as CA Wily APM, AppDynamics, New Relic, Riverbed, etc. APM tools not only monitor the heap usage, but you can also configure the tool to Alert you when Heap usage is not normal.
This is because the JVM steadily increases heap usage percentage until the garbage collection process frees up memory again. High heap usage occurs when the garbage collection process cannot keep up. An indicator of high heap usage is when the garbage collection is incapable of reducing the heap usage to around 30%.
I think that your test method is not appropriate. You use the Large Memory Pages when you want to optimize the TLB:
A Translation-Lookaside Buffer (TLB) is a page translation cache that holds the most-recently used virtual-to-physical address translations. TLB is a scarce system resource. A TLB miss can be costly as the processor must then read from the hierarchical page table, which may require multiple memory accesses. By using bigger page size, a single TLB entry can represent larger memory range. There will be less pressure on TLB and memory-intensive applications may have better performance.
You can use [JVisualVM], to profile your application. but in case of your test you create new objects. Im not an expert here but for mz understanding of TBL, you should load data from memory to structure that should be in the buffer. If is not there i should be loaded.
In theory a test that measure time for constant number of operations should be sufficient to see influence of the VM parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With