Configuring LargePages

Discussion in 'Performance Tweaking' started by Bestle, Apr 13, 2013.

  1. Bestle

    Patron

    My machine currently has 32GB of unusable memory.

    I want to allocate 16GB to the JVM and as such will require 16GB of Large Pages.

    I configured the amount of hugepages available in linux like so:

    Code (Text):
    sysctl -w vm.nr_hugepages=8192
    Now the problem is, that when I try and launch my server using the -XX:+UseLargePages parameter I get an error about not being able to reserve enough memory.

    I read somewhere that I need to correctly configure my shmmax value which is currently 68719476736.

    Does anyone know what I need to change to get it to launch correctly with large pages?
     
  2. Did you also allow the minecraft user access to largepages? Look up the group that minecraft belongs to by typing 'groups', look up that group in /etc/group, then

    vm.hugetlb_shm_group = (gid)
     
  3. Puremin0rez

    Moderator

    Anyone happen to have a nice guide for setting up such a thing? Wanted to get into Huge Pages someday and now seems like a good time.
     
  4. PhanaticD

    Patron

    there was a whole thread about people discussing it, all sorts of guides were linked, im too lazy to find it for you though
     
  5. http://dino.ciuffetti.info/2011/07/howto-java-huge-pages-linux/
    Explains it in a general circumstance not specified to minecraft.
    However im still confused (perhaps because i just woke up)
    My box has 64 GB of ram. atm im not using largepages (and for what reason im not certain) my server cannot allocate all of its usefulness. I dont wanna mess anything memory-wise with my server up to the point where im not knowledgeable enough to fix it.

    atm my start params are as follows:
    Code (Text):
    java -server -Xincgc -Xmx54G -Xms1G -Xmn512M -XX:NewRatio=2 -XX:CMSFullGCsBeforeCompaction=1 -XX:SoftRefLRUPolicyMSPerMB=2048 -XX:+CMSParallelRemarkEnabled -XX:+UseParNewGC -XX:+UseAdaptiveSizePolicy -XX:+DisableExplicitGC -Xnoclassgc -oss4M -ss4M -XX:+UseFastAccessorMethods -XX:CMSInitiatingOccupancyFraction=90 -XX:+UseConcMarkSweepGC -XX:UseSSE=4 -XX:+UseCMSCompactAtFullCollection -XX:ParallelGCThreads=4 -XX:+AggressiveOpts -cp "craftbukkit.jar" -jar "craftbukkit.jar"
     
  6. Ouch, try my startup parameters, or simply skip them, ther's a few silly things in there, keep in mind it's also for 32GB of RAM, so you should double all the M sizes.

    Code (Text):
    java -server -Xmn512M -Xmx30720M -Xms1024M -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=8 -XX:+CMSParallelRemarkEnabled -XX:+DisableExplicitGC -XX:MaxGCPauseMillis=50 -XX:SurvivorRatio=16 -XX:TargetSurvivorRatio=90 -XX:+UseFastAccessorMethods -XX:+AggressiveOpts -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:MaxTenuringThreshold=15 -XX:UseSSE=4 -XX:+UseLargePages -Djline.teminal=jline.UnsupportedTerminal -jar "{JAR}" nogui
    A few things to keep in mind, this is designed for an 8 thread CPU (4 core with hyperthreading, which is any E3 CPU,) it also uses SSE4, so be sure to have Java 7 and an SSE4 compatible CPU, and finally, replace {JAR} with your jar name.
     
  7. Java should auto-detect SSE and use it appropriately. First make sure sse4 is in /proc/cpuinfo. You can verify with

    jinfo -flag UseSSE `pgrep java`

    assuming you only have one java process running, else use the PID.

    You probably also do not need to specify GC threads, Java should automatically detect that. As for the rest of the spew, I can only advise that if you do not know EXACTLY what a flag does, you shouldn't use it.
     
  8. Hi, i have a question.
    I know that largepages can't be accesed by applications that do not support them but... if i have 16gb of total ram and i assign 6gb to largepages and 8gb to my server, it takes 6gb from largepages and 2gb of normal ram or it takes the 8gb my server and uses the 6gb of largepages for performance support? (14gb)


    For thar startup script it will take 8Gb or 14gb (8gb +6Gb from largepages)?
    java -Xms2G -Xmx8G -XX:+UseLargePages -XX:LargePageSizeInBytes=2m -jar spigot.jar

    Thanks.