JVM Large Pages in Linux (huge page)
+. memory space / number of large memory pages
- each huge page size : 16 MB
- jvm heap size : 2048 MB
- jvm instances : 4
> total memory space for jvm heap
: 2048 MB * 4 (jvm) = 8 GB
total memory space for huge page
: (1024 (1kb) * 1024 (1mb) * 1024 (1gb) * 2 (jvm heap) * 4 (jvm count)) - 1 = 8589934591
total huge page number
: 1024 (1gb) * 2 (jvm heap) * 4 (jvm count) / 16 (huge page size) = 512
+. allocate the shared memory segement
#. echo 8589934591 > /proc/sys/kernel/shmmax (temporary configuration)
#. vi /etc/sysctl.conf (permanent configuration)
kernel.shmmax = 8589934591
+. set the number of huge pages
#. echo 512 > /proc/sys/vm/nr_hugepages (temporary configuration)
#. vi /etc/sysctl.conf (permanent configuration)
vm.nr_hugepages = 512
+. set the user group to access the huge pages (ex. user's group id : 1001)
#. echo 1001 > /proc/sys/vm/hugetlb_shm_group (temporary configuration)
#. vi /etc/sysctl.conf (permanent configuration)
vm.hugetlb_shm_group = 1001
+. run jvm with huge page support option
> java -Xlp -Xmn1400m -Xms2048m -Xmx2048m -XlockReservation -Xnoloa -XtlhPrefetch -Xaggressive -Xcompressedrefs -Xconcurrentlevel0
> java -d64 -server -Xms2048m -Xmx2048m -Xss192k -XX:+UseLargePages -XX:LargePageSizeInBytes=2m -XX:+UseParNewGC
+. check the huge pages in memory
#. cat /proc/meminfo | grep Huge