430 likes | 676 Views
Java Performance - War Stories. Paul McLachlan Apptio. Performance Strategy. Performance tuning is a discipline Measure, Don’t (ever) guess Always attack #1 bottleneck first Is success possible?. Performance Strategy. Performance Strategies Call it less Make it more efficient
E N D
Java Performance -War Stories Paul McLachlan Apptio
Performance Strategy • Performance tuning is a discipline • Measure, Don’t (ever) guess • Always attack #1 bottleneck first • Is success possible?
Performance Strategy • Performance Strategies • Call it less • Make it more efficient • Do it in parallel • Do it beforehand • or…
Example Performance Tuning By Example
A random bottleneck This is an example – please ignore the SQL stupidity (Actually – all of these snippets are for explanation purposes, YAMMV)
Soft References • Weak/Soft/Phantom/Final References http://jeremymanson.blogspot.com/2009/07/how-hotspot-decides-to-clear_07.html -XX:SoftRefLRUPolicyMSPerMB=1
Example Memory Optimizations
How Much Memory? org.apache.commons.collections.map.Flat3Map
*How* Much Memory? -XX:+UseCompressedOops
Off Heap Off Heap & Native Integration Tricks
“Unsafe” http://javasourcecode.org/html/open-source/jdk/jdk-6u23/sun/misc/Unsafe.java.html
Example Build In Instrumentation
Example Or … Tools
Tools / YourKit yourkit.com: • Sampling • Instrumenting • Heap & GC • $500 / unlimited
Tools / NMon • http://nmon.sourceforge.net
Example Reference Material
Numbers Everyone Should Know http://www.cs.cornell.edu/projects/ladis2009/talks/dean-keynote-ladis2009.pdf
Statistics • Relative Standard Deviation = STDEV(…)/AVERAGE(…) • Confidence = 1-TTEST(orig,control,1,2) • Throughput • Average latency • Max latency • 90th Percentile latency
Tools • jHiccuphttp://www.azulsystems.com/jHiccup • YourKithttp://yourkit.com/ • Nmon for Linuxhttp://nmon.sourceforge.net
Libraries • CLHM http://code.google.com/p/concurrentlinkedhashmap/ • Guavahttp://code.google.com/p/guava-libraries/ • Colthttp://acs.lbl.gov/software/colt/ • Trove4Jhttp://trove.starlight-systems.com/ • JDK 8 Concurrency Codehttp://gee.cs.oswego.edu/dl/concurrency-interest/index.html
Good Books / References • Java Memory Modelhttp://www.cs.umd.edu/~pugh/java/memoryModel/ • Java Platform Performancehttp://java.sun.com/docs/books/performance/ • Debugging by Thinkinghttp://www.debuggingbythinking.com/ • Concurrent Programming in Javahttp://www.amazon.com/Concurrent-Programming-Java-Principles-Pattern/dp/0201310090/
JVM Intrinsics http://hg.openjdk.java.net/jdk6/jdk6/hotspot/file/6d13fcb3663f/src/share/vm/classfile/vmSymbols.hpp