====== Java Performance ====== * [[java:performance:threaddump|Java ThreadDump]] * [[java:gc|Java Garbage Collection]] * [[java:memory|Java Memory Analysis]] * [[https://github.com/foursquare/heapaudit|HeapAudit]] * [[http://code.google.com/p/javamelody/|javamelody - monitoring of JavaEE applications]] * [[http://www.appdynamics.com/|AppDynamics]] * [[http://weblogs.java.net/blog/kcpeppe/archive/2011/12/19/setting-xmx-xms-still-considered-harmful|Is setting -Xmx==-Xms still considered harmful?]] - G1 GC에서는 Xmx==Xms로 두는게 좋다? * [[http://visualvm.java.net/|VisualVM]] jconsole을 대체할 만한 JVM 분석툴. * [[http://helloworld.naver.com/helloworld/6043|Garbage Collection 모니터링 방법]] * [[http://helloworld.naver.com/helloworld/10963|스레드 덤프 분석하기]] * [[http://www.javacodegeeks.com/2012/03/jvm-how-to-analyze-thread-dump.html|JVM: How to analyze Thread Dump]] * [[http://www.dzone.com/links/r/useful_jvm_flags_part_1_jvm_types_and_compiler_mo.html|Useful JVM Flags – Part 1 (JVM Types and Compiler Modes)]] * [[http://architects.dzone.com/articles/how-analyze-java-thread-dumps|How to Analyze Java Thread Dumps]] * [[http://architects.dzone.com/articles/how-monitor-java-garbage|How to Monitor Java Garbage Collection]] * [[http://helloworld.naver.com/helloworld/184615|자바 애플리케이션 성능 튜닝의 도(道)]] * [[http://www.tuning-java.com/485|Java NIO의 DirectByteBuffer는 필요한 갯수만큼만 만들어서 사용하자]] DirectByteBuffer가 사용하는 [[http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/nio/Bits.java#Bits.reserveMemory%28long%29|Bits.reverseMemory()]]가 System.gc()를 호출한다. * [[http://javarevisited.blogspot.in/2012/10/10-garbage-collection-interview-question-answer.html|10 Java GC interview question answer]] * [[http://javaeesupportpatterns.blogspot.kr/2012/09/outofmemoryerror-unable-to-create-new.html|OutOfMemoryError: unable to create new native thread]] * [[http://java.dzone.com/articles/maxclients-apache-and-its|MaxClients in Apache and its effect on Tomcat during Full Java GC]] * [[http://www.javacodegeeks.com/2012/12/busting-permgen-myths.html|Busting PermGen Myths]] * [[http://www.jolokia.org/|Jolokia]] remote JMX with JSON over HTTP * [[https://github.com/jmxtrans/jmxtrans|JMXTrans]] * [[http://www.infoq.com/presentations/JVM-Performance-Tuning-twitter-QCon-London-2012|Everything I Ever Learned about JVM Performance Tuning @twitter]] * [[http://www.infoq.com/presentations/jvm-optimization|JVM Optimization 101]] * [[https://github.com/ScottOaks/JavaPerformanceTuning|Examples for O'Reilly & Associates Java Performance Tuning: The Definitive Guide]] * [[http://www.baeldung.com/java-jvm-warmup|How to Warm Up the JVM]] * [[https://engineering.linkedin.com/garbage-collection/garbage-collection-optimization-high-throughput-and-low-latency-java-applications|Garbage Collection Optimization for High-Throughput and Low-Latency Java Applications]] * [[https://apacheignite.readme.io/docs/jvm-and-system-tuning|Garbage Collection Tuning]] * [[https://docs.gigaspaces.com/latest/production/production-jvm-tuning.html|JVM Tuning]] * [[http://xmlandmore.blogspot.com/2014/09/jdk-8-thread-stack-size-tuning.html|Xml and More: JDK 8: Thread Stack Size Tuning]] ===== Java World Java Performance Series ===== * [[http://www.javaworld.com/javaworld/jw-08-2012/120821-jvm-performance-optimization-overview.html|JVM performance optimization, Part 1: A JVM technology primer]] * [[http://www.javaworld.com/javaworld/jw-09-2012/120905-jvm-performance-optimization-compilers.html|JVM performance optimization, Part 2: Compilers]] * [[http://www.javaworld.com/javaworld/jw-10-2012/121010-jvm-performance-optimization-garbage-collection.html|JVM performance optimization, Part 3: GC]] * [[http://www.javaworld.com/javaworld/jw-11-2012/121107-jvm-performance-optimization-low-latency-garbage-collection.html|JVM performance optimization, Part 4: C4 garbage collection for low-latency Java applications]] * [[http://www.javaworld.com/javaworld/jw-03-2013/130301-jvm-performance-optimization-java-scalability.html|JVM performance optimization, Part 5: Is Java scalability an oxymoron? - JavaWorld]] ===== JVM의 Heap을 무한정 늘리지 말 것 ===== * [[http://plumbr.eu/blog/increasing-heap-size-beware-of-the-cobra-effect|Increasing heap size – beware of the Cobra Effect]] * JVM Heap을 무한정 늘리면 Full GC 시간 증가로 인해 오히려 성능 병목이 될 수 있다. * JVM의 Heap을 증가시키기 보다는 JVM을 여러 대 띄운다. * JVM을 여러개 띄울 수 없다면, * [[http://directmemory.apache.org/|Apache Direct Memory]] 혹은 [[http://terracotta.org/products/bigmemory|Terracotta Big Memory]] 등을 사용해 외부에 메모리를 할당한다. * GC 설정을 튜닝한다. 그러나 현재로서는 확실한 효과를 보장할 수 없을수도. * [[http://www.azulsystems.com/products/zing/virtual-machine|Zing JVM]] Full GC를 하지 않는 JVM ===== JIT Compiler option ===== * [[http://www.javacodegeeks.com/2012/10/warming-up-your-jvm-superfast.html|Warming Up Your JVM - Superfast Production Servers and IDEs]] * 특정 메소드가 일정 횟수 있상 실행되면 JIT Compiler가 native 코드로 컴파일한다. * ''-XX:CompileThreshold'' 가 그 횟수를 지정한다. 기본 1500이며, 너무 작게 주면 서버가 최초로 뜰 때, 컴파일하느라 너무 많은 시간을 소비한다. 따라서 애플리케이션에 따라 적정수를 지정해야 한다. 보통은 **100** 이상 정도가 적합하다 한다. * ''-server -XX:+TieredCompilation'' : Java 7, Multi Core 환경에서 이 옵션을 주면 native 컴파일 속도가 향상 된다. ===== Linux Tuning ===== * [[linux:performance|Linux Performance]] * 기본적으로 ''swappiness=1''로 스왑 가능성을 줄이고 file과 process 제약을 풀어준다. ulimit -n 32768 -u 32768 ===== HashMap.get/getEntry, WeakHashMap.get/getEntry 에 대한 동시 접근은 CPU 사용률 증가(High 100%) 유발 ===== * ''HashMap.get/getEntry'', ''WeakHashMap.get/getEntry''에 대한 다중 쓰레드 동시접근은 CPU 사용률 증가를 유발한다. * **결론은 동시 접근이 필요할 경우에는 ''ConcurrentHashMap''을 사용하라.** * [[http://mailinator.blogspot.kr/2009/06/beautiful-race-condition.html|Beautiful race condition]] : HashMap get infinit loop within a particular bucket. * [[http://stackoverflow.com/questions/4034141/java-high-cpu-usage|Java - High cpu usage]] * [[http://portrix-systems.de/blog/brost/troubleshooting-a-cpu-eating-java-process/|troubleshooting a CPU eating java process ]] * [[http://stackoverflow.com/questions/3429420/why-java-util-hashmap-getentry-can-block-my-program|multithreading - why java.util.HashMap.getEntry can block my program?]] * [[http://javaeesupportpatterns.blogspot.kr/2012/02/hashmapget-high-cpu-case-study.html|HashMap.get High CPU]] * [[http://www.adam-bien.com/roller/abien/entry/endless_loops_in_unsychronized_weakhashmap|Endless Loops In Unsychronized WeakHashMap]] ===== Selector.select() CPU 100% ===== * [[http://knight76.tistory.com/entry/Apache-Mina-%EC%82%AC%EB%A1%80%EC%97%90%EC%84%9C-%EB%B3%B8-Selectorselect-%EC%9D%B4%EC%8A%88-cpu-100-%ED%8A%80%EB%8A%94-%ED%98%84%EC%83%81|Apache Mina 사례에서 본 Selector.select() 이슈- cpu 100% 튀는 현상]] * [[http://stackoverflow.com/questions/20475290/why-does-select-consume-so-much-cpu-time-in-my-program|java - Why does select() consume so much CPU time in my program? - Stack Overflow]] * [[http://bugs.java.com/view_bug.do?bug_id=6693490|Bug ID: JDK-6693490 (se) select throws "File exists" IOException under load (lnx)]]