俗话说的好,净信书不如无书。怀揣着怀疑,翻阅了诸多权威文献。这里总结了自己工作、学习中做性能调优时经常翻阅的文献,希望能为大家带来方便。如果在阅读过程中有什么不清楚的,也欢迎大家留言,一同探讨。
(1) http://www.oracle.com/technetwork/java/javase/tech/exactoptions-jsp-141536.html
我们都知道,JVM spec,早期sun的实现叫hot spot。这篇文章主要列举了一些与EVM对应的参数及其详解
(2) http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
着重关注一下下面的说明:
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.
(3) http://www.oracle.com/technetwork/java/javase/trouble-138361.html
这个链接主要是关于Troubleshooting Java™ SE的,调优方面主要关注目录中加粗部分,如下:
Contents of This Page
Troubleshooting Guides
Quick Tips!
Troubleshooting Tools
Pertinent Articles
Pertinent Blogs
Pertinent Forum Sites
(4) http://www.ibm.com/developerworks/cn/java/j-nativememory-linux/#resources
主要讲解了windows,linux平台上JVM内存分配的内在原理
如何debug OOM问题
如何写出高质量代码
(7) http://www.azulsystems.com/resources/presentations#springone2011
主要阐述了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
(8) http://blogs.oracle.com/jonthecollector/entry/our_collectors
2008年的文章,讲解了sun的垃圾收集器代码框架,还不错~
最近在看,不错的官方资料
(10) http://www.javaworld.com/javaworld/javatips/jw-javatip92.html
(11) http://www.ibm.com/developerworks/forums/forum.jspa?forumID=843
(12) http://www.ibm.com/developerworks/java/library/j-codetoheap/index.html
(13) http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136373.html
(14 )http://java.sun.com/performance/reference/whitepapers/tuning.html
(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.*Error 5. out of memory in Native Code (C-heap)!
贴几个case:
1.
[Full GC[PSYoungGen: 279700K->267300K(358400K)][ParOldGen: 685165K->685165K(685170K)]964865K->964865K(1043570K)
[PSPermGen: 32390K->32390K(65536K)],0.2499342 secs]
[Times: user=0.08 sys=0.00, real=0.05 secs]
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[Full GC[PSYoungGen: 0K->0K(141632K)][ParOldGen: 132538K->132538K(350208K)]32538K->32538K(491840K)
[PSPermGen: 65536K->65536K(65536K)],0.2430136 secs]
[Times: user=0.37 sys=0.00, real=0.24 secs]
java.lang.OutOfMemoryError: PermGen space
-Xss256k
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:+CMSParallelRemarkEnabled
-XX:+UseCMSCompactAtFullCollection
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+UseFastAccessorMethods
注意: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),无奈如果希望全盘看懂那些汇编代码还是有些够呛,毕竟自己那些汇编知识毕业后都还回去了,也没有系统的拾起来过。