JVM调优文献参考

       俗话说的好,净信书不如无书。怀揣着怀疑,翻阅了诸多权威文献。这里总结了自己工作、学习中做性能调优时经常翻阅的文献,希望能为大家带来方便。如果在阅读过程中有什么不清楚的,也欢迎大家留言,一同探讨。

(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内存分配的内在原理

(5) http://publib.boulder.ibm.com/infocenter/javasdk/tools/index.jsp?topic=/com.ibm.java.doc.igaa/_1vg00011e17d8ea-1163a087e6c-7ffe_1001.html

如何debug OOM问题

(6) https://www.securecoding.cert.org/confluence/display/java/The+CERT+Oracle+Secure+Coding+Standard+for+Java

如何写出高质量代码

(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的垃圾收集器代码框架,还不错~

(9) http://www.bookonlinepdf.com/troubleshooting-and-diagnostic-guide-for-java-2-platform-standard-edition-5-0.pdf

最近在看,不错的官方资料

(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.StackOverflowError 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

2.

[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

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 genreference processing,进而能触发基于PhantomReference的清理对象Cleaner对已死的DirectByteBuffer对象做清理工作。


最近在研究JIT运行期性能优化,发现了JITWatch这个不错的工具,记录一下(关于JITWatch的更详细的功能,可以参看这里的视频)。本来呢,通过hsdis插件获得HotSpot执行时产生的汇编代码也是一种不错的选择(如早期,我就喜欢这样玩,java -server -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -XX:+DebugNonSafepoints DemoVolotile > demo.assembly),无奈如果希望全盘看懂那些汇编代码还是有些够呛,毕竟自己那些汇编知识毕业后都还回去了,也没有系统的拾起来过。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值