俗話說的好,淨信書不如無書。懷揣着懷疑,翻閱了諸多權威文獻。這裡總結了自己工作、學習中做性能調優時經常翻閱的文獻,希望能為大家帶來友善。如果在閱讀過程中有什麼不清楚的,也歡迎大家留言,一同探讨。
我們都知道,jvm spec,早期sun的實作叫hot spot。這篇文章主要列舉了一些與evm對應的參數及其詳解
着重關注一下下面的說明:
the options are loosely grouped into three categories.
behavioral options change the basic behavior of the vm.
performance tuning options are knobs which can be used to tune vm performance.
debugging options generally enable tracing, printing, or output of vm information.
這個連結主要是關于troubleshooting java™ se的,調優方面主要關注目錄中加粗部分,如下:
contents of this page
troubleshooting guides
quick tips!
troubleshooting tools
pertinent articles
pertinent blogs
pertinent forum sites
主要講解了windows,linux平台上jvm記憶體配置設定的内在原理
如何debug oom問題
如何寫出高品質代碼
主要闡述了jvm一些特性(自java2以來),如方法内聯(you can either make a method look attractive to the vm to inline or manually inline a method if it doesn't break your object model.),streamlined locks,adaptive optimization,improved garbage collection,fast thread synchronization,just-in-time compilers
2008年的文章,講解了sun的垃圾收集器代碼架構,還不錯~
最近在看,不錯的官方資料
(11) http://www.ibm.com/developerworks/forums/forum.jspa?forumid=843
(15) http://www.ibm.com/developerworks/java/library/j-codetoheap/index.html
(16) http://www.oracle.com/technetwork/java/tuning-139912.html
(17) http://www.oracle.com/technetwork/java/tuning-139912.html#section4.2.5
java 對象存儲結構,非常實用,關注cache perf.的同學可以借此了解如何讓java對象的排兵布陣符合cache line
(18) http://apacheignite.gridgain.org/docs/jvm-and-system-tuning
這個也是我在小組裡面建立的調優參考規格
(19) https://engineering.linkedin.com/performance/optimizing-linux-memory-management-low-latency-high-throughput-databases
server spike problems because of many page scan and low memory usage
(20) http://jprante.github.io/lessons/2012/07/26/mmap-with-lucene.html
(21)https://community.oracle.com/thread/3786750?start=0&tstart=0
兩篇跟offheap 的hugepage相關的文章
程序映射
下面是一些常見oom問題
1. java.lang.outofmemoryerror: java heap space
2. java.lang.outofmemoryerror: permgen space
3. java.lang.outofmemoryerror: unable to create new native thread
4. java.lang.stackoverflowerror 5. out of memory in native code (c-heap)!
貼幾個case:
1.
2.
3. cms垃圾收集機制下,工業基準參數(根據業務調整)
xmx6g -xms6g -xmn256m
-xx:permsize=128m -xx:maxpermsize=256m
-xss256k
-xx:+disableexplicitgc
-xx:+useconcmarksweepgc
-xx:+useparnewgc
-xx:+cmsparallelremarkenabled
-xx:+usecmscompactatfullcollection
-xx:+usecmsinitiatingoccupancyonly
-xx:cmsinitiatingoccupancyfraction=75
-xx:+usefastaccessormethods
-xx:+cmspermgensweepingenabled
-xx:+heapdumponoutofmemoryerror
-xx:+printcommandlineflags
注意:useparnewgc(parnew+serial old),該選項實際上被後面的并發标記gc(parnew + cms +serial old)選項覆寫掉了~有些參數,尤其是帶radio或threshold的,比方說maxtenuringthreshold,initialtenuringthreshold,initialsurvivorratio,minsurvivorratio, survivorratio,maxheapfreeratio,minheapfreeratio,newratio,我們需要針對具體應用調優,記住,調優是件很伽利略的事情~
後記:在nio使用場景比較多的情況下,-xx:+disableexplicitgc可能會有副作用。如果擔心system.gc()調用造成fullgc頻繁,可以嘗試xx:+explicitgcinvokesconcurrent參數。在full gc的時候會對old gen做reference processing,進而能觸發基于phantomreference的清理對象cleaner對已死的directbytebuffer對象做清理工作。
最近在研究jit運作期性能優化,發現了jitwatch這個不錯的工具,記錄一下(關于jitwatch的更詳細的功能,可以參看這裡的視訊)。本來呢,通過hsdis插件獲得hotspot執行時産生的彙編代碼也是一種不錯的選擇(如早期,我就喜歡這樣玩,java -server -xx:+unlockexperimentalvmoptions -xx:+unlockdiagnosticvmoptions -xx:+printassembly -xx:+debugnonsafepoints demovolotile > demo.assembly),無奈如果希望全盤看懂那些彙編代碼還是有些夠嗆,畢竟自己那些彙編知識畢業後都還回去了,也沒有系統的拾起來過。