Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2011 Apptio, Inc. All Rights Reserved. 1 Java Performance - War Stories Paul McLachlan Apptio.

Similar presentations


Presentation on theme: "© 2011 Apptio, Inc. All Rights Reserved. 1 Java Performance - War Stories Paul McLachlan Apptio."— Presentation transcript:

1 © 2011 Apptio, Inc. All Rights Reserved. 1 Java Performance - War Stories Paul McLachlan Apptio

2 © 2011 Apptio, Inc. All Rights Reserved. 2 Performance Strategy Performance tuning is a discipline –Measure, Dont (ever) guess –Always attack #1 bottleneck first –Is success possible?

3 © 2011 Apptio, Inc. All Rights Reserved. 3 Performance Strategies –Call it less –Make it more efficient –Do it in parallel –Do it beforehand or… Performance Strategy

4 © 2011 Apptio, Inc. All Rights Reserved. 4

5 5 Perceived Performance

6 © 2011 Apptio, Inc. All Rights Reserved. 6 Example Performance Tuning By Example

7 © 2011 Apptio, Inc. All Rights Reserved. 7 A random bottleneck This is an example – please ignore the SQL stupidity (Actually – all of these snippets are for explanation purposes, YAMMV)

8 © 2011 Apptio, Inc. All Rights Reserved. 8 Add a cache

9 © 2011 Apptio, Inc. All Rights Reserved. 9 Dont synchronize on the DB

10 © 2011 Apptio, Inc. All Rights Reserved. 10 Use ConcurrentHashMap

11 © 2011 Apptio, Inc. All Rights Reserved. 11 Dont thrash with simultaneous hits

12 © 2011 Apptio, Inc. All Rights Reserved. 12 Dont run out of RAM

13 © 2011 Apptio, Inc. All Rights Reserved. 13 Soft References Weak/Soft/Phantom/Final References http://jeremymanson.blogspot.com/2009/07/how-hotspot-decides-to-clear_07.html -XX:SoftRefLRUPolicyMSPerMB=1

14 © 2011 Apptio, Inc. All Rights Reserved. 14 Preload everything beforehand

15 © 2011 Apptio, Inc. All Rights Reserved. 15 Use less RAM with.intern()

16 © 2011 Apptio, Inc. All Rights Reserved. 16 How to make HashMap.get() faster?

17 © 2011 Apptio, Inc. All Rights Reserved. 17 HotCache pattern

18 © 2011 Apptio, Inc. All Rights Reserved. 18 Example Memory Optimizations

19 © 2011 Apptio, Inc. All Rights Reserved. 19 How Much Memory?

20 © 2011 Apptio, Inc. All Rights Reserved. 20 How Much Memory?

21 © 2011 Apptio, Inc. All Rights Reserved. 21 How Much Memory? org.apache.commons.collections.map.Flat3Map

22 © 2011 Apptio, Inc. All Rights Reserved. 22 *How* Much Memory? -XX:+UseCompressedOops

23 © 2011 Apptio, Inc. All Rights Reserved. 23 Off Heap Off Heap & Native Integration Tricks

24 © 2011 Apptio, Inc. All Rights Reserved. 24 Unsafe http://javasourcecode.org/html/open-source/jdk/jdk-6u23/sun/misc/Unsafe.java.html

25 © 2011 Apptio, Inc. All Rights Reserved. 25 Off Heap / Mapped Wrapping Classes

26 © 2011 Apptio, Inc. All Rights Reserved. 26 Example Build In Instrumentation

27 © 2011 Apptio, Inc. All Rights Reserved. 27 Visibility

28 © 2011 Apptio, Inc. All Rights Reserved. 28 Memory Report

29 © 2011 Apptio, Inc. All Rights Reserved. 29 Visibility

30 © 2011 Apptio, Inc. All Rights Reserved. 30 Visibility

31 © 2011 Apptio, Inc. All Rights Reserved. 31 /OutputThreads Servlet

32 © 2011 Apptio, Inc. All Rights Reserved. 32 Example Or … Tools

33 © 2011 Apptio, Inc. All Rights Reserved. 33 Tools / YourKit yourkit.com: Sampling Instrumenting Heap & GC $500 / unlimited

34 © 2011 Apptio, Inc. All Rights Reserved. 34 How Profilers Work

35 © 2011 Apptio, Inc. All Rights Reserved. 35 Or … Embed the Profiler

36 © 2011 Apptio, Inc. All Rights Reserved. 36 Tools / NMon http://nmon.sourceforge.net

37 © 2011 Apptio, Inc. All Rights Reserved. 37 Example Reference Material

38 © 2011 Apptio, Inc. All Rights Reserved. 38 Numbers Everyone Should Know http://www.cs.cornell.edu/projects/ladis2009/talks/dean-keynote-ladis2009.pdf

39 © 2011 Apptio, Inc. All Rights Reserved. 39 Statistics Relative Standard Deviation = STDEV(…)/AVERAGE(…) Confidence = 1-TTEST(orig,control,1,2) Throughput Average latency Max latency 90 th Percentile latency

40 © 2011 Apptio, Inc. All Rights Reserved. 40 Tools jHiccup http://www.azulsystems.com/jHiccup http://www.azulsystems.com/jHiccup YourKit http://yourkit.com/ http://yourkit.com/ Nmon for Linux http://nmon.sourceforge.net http://nmon.sourceforge.net

41 © 2011 Apptio, Inc. All Rights Reserved. 41 Libraries CLHM http://code.google.com/p/concurrentlinkedhashmap/http://code.google.com/p/concurrentlinkedhashmap/ Guava http://code.google.com/p/guava-libraries/ http://code.google.com/p/guava-libraries/ Colt http://acs.lbl.gov/software/colt/ http://acs.lbl.gov/software/colt/ Trove4J http://trove.starlight-systems.com/ http://trove.starlight-systems.com/ JDK 8 Concurrency Code http://gee.cs.oswego.edu/dl/concurrency-interest/index.html http://gee.cs.oswego.edu/dl/concurrency-interest/index.html

42 © 2011 Apptio, Inc. All Rights Reserved. 42 Good Books / References Java Memory Model http://www.cs.umd.edu/~pugh/java/memoryModel/ http://www.cs.umd.edu/~pugh/java/memoryModel/ Java Platform Performance http://java.sun.com/docs/books/performance/ http://java.sun.com/docs/books/performance/ Debugging by Thinking http://www.debuggingbythinking.com/ http://www.debuggingbythinking.com/ Concurrent Programming in Java http://www.amazon.com/Concurrent-Programming-Java- Principles-Pattern/dp/0201310090/ http://www.amazon.com/Concurrent-Programming-Java- Principles-Pattern/dp/0201310090/

43 © 2011 Apptio, Inc. All Rights Reserved. 43 JVM Intrinsics http://hg.openjdk.java.net/jdk6/jdk6/hotspot/file/6d13fcb3663f/ src/share/vm/classfile/vmSymbols.hpp


Download ppt "© 2011 Apptio, Inc. All Rights Reserved. 1 Java Performance - War Stories Paul McLachlan Apptio."

Similar presentations


Ads by Google