1 / 43

Java Performance - War Stories

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

starbuck
Télécharger la présentation

Java Performance - War Stories

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Performance -War Stories Paul McLachlan Apptio

  2. Performance Strategy • Performance tuning is a discipline • Measure, Don’t (ever) guess • Always attack #1 bottleneck first • Is success possible?

  3. Performance Strategy • Performance Strategies • Call it less • Make it more efficient • Do it in parallel • Do it beforehand • or…

  4. “Perceived Performance”

  5. Example Performance Tuning By Example

  6. A random bottleneck This is an example – please ignore the SQL stupidity (Actually – all of these snippets are for explanation purposes, YAMMV)

  7. Add a cache

  8. Don’t synchronize on the DB

  9. Use ConcurrentHashMap

  10. Don’t thrash with simultaneous hits

  11. Don’t run out of RAM

  12. Soft References • Weak/Soft/Phantom/Final References http://jeremymanson.blogspot.com/2009/07/how-hotspot-decides-to-clear_07.html -XX:SoftRefLRUPolicyMSPerMB=1

  13. Preload everything beforehand

  14. Use less RAM with .intern()

  15. How to make HashMap.get() faster?

  16. HotCache pattern

  17. Example Memory Optimizations

  18. How Much Memory?

  19. How Much Memory?

  20. How Much Memory? org.apache.commons.collections.map.Flat3Map

  21. *How* Much Memory? -XX:+UseCompressedOops

  22. Off Heap Off Heap & Native Integration Tricks

  23. “Unsafe” http://javasourcecode.org/html/open-source/jdk/jdk-6u23/sun/misc/Unsafe.java.html

  24. Off Heap / Mapped Wrapping Classes

  25. Example Build In Instrumentation

  26. Visibility

  27. Memory Report

  28. Visibility

  29. Visibility

  30. /OutputThreads Servlet

  31. Example Or … Tools

  32. Tools / YourKit yourkit.com: • Sampling • Instrumenting • Heap & GC • $500 / unlimited

  33. How Profilers Work

  34. Or … Embed the Profiler

  35. Tools / NMon • http://nmon.sourceforge.net

  36. Example Reference Material

  37. Numbers Everyone Should Know http://www.cs.cornell.edu/projects/ladis2009/talks/dean-keynote-ladis2009.pdf

  38. Statistics • Relative Standard Deviation = STDEV(…)/AVERAGE(…) • Confidence = 1-TTEST(orig,control,1,2) • Throughput • Average latency • Max latency • 90th Percentile latency

  39. Tools • jHiccuphttp://www.azulsystems.com/jHiccup • YourKithttp://yourkit.com/ • Nmon for Linuxhttp://nmon.sourceforge.net

  40. 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

  41. 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/

  42. JVM Intrinsics http://hg.openjdk.java.net/jdk6/jdk6/hotspot/file/6d13fcb3663f/src/share/vm/classfile/vmSymbols.hpp

More Related