JavaStudy Network Daehyub Cho JVM  [Java Virtual Machine] Performance Tuning
AGENDA Basic concept of JVM Tuning 1 Hotspot compiler 2 Threading Model 3 Memory Model 4
Basic Concept of JVM Tuning Basic concept of  JVM Tuning
Basic of performance tuning <ul><li>Decide what performance level is “good enough” </li></ul><ul><li>Test & measurement  <...
JVM Tuning <ul><li>Improve performance about 10~20% </li></ul><ul><li>Find appropriate parameter for your application </li...
Hotspot Compiler Hotspot compiler
JVM Layout <ul><li>Hotspot from JDK 1.3 </li></ul>VM Client Compiler Server Compiler <ul><li>Runtime </li></ul><ul><li>GC ...
Hotspot compiler <ul><li>JIT (Just-In-Time Compiler) </li></ul><ul><ul><li>Compile byte code to native code </li></ul></ul...
Hotspot Detection <ul><li>Hotspot detection </li></ul><ul><li>Method Inlining </li></ul><ul><li>Dynamic Deoptimization </l...
Hotspot Detection and Method Inlining <ul><li>Literal constants are folded </li></ul><ul><li>String concatenation is somet...
Hotspot detection / Method Inlining <ul><li>Dead code branches are eliminated </li></ul>public class A{ static final boole...
Hotspot Client compiler <ul><li>Java Option : -client </li></ul><ul><li>Focused on Simple & Fast start up </li></ul><ul><l...
Hotspot Server compiler <ul><li>Java Option : -server </li></ul><ul><li>Focused on optimization </li></ul><ul><li>SSA (Sta...
Hotspot compiler Option <ul><li>Hotspot compile option </li></ul><ul><ul><li>-XX:MaxInlineSize=<size> </li></ul></ul><ul><...
Threading Threading model
Threading Model <ul><li>Thread Model </li></ul><ul><ul><li>Java is multi threaded programming language </li></ul></ul><ul>...
Solaris M:N Thread Model Java Application Java Thread JVM Solaris OS OS Kernel Solaris Thread LWP Kernel Thread
Solaris M:N Thread Model <ul><li>Solaris M:N Thread Model </li></ul><ul><ul><li>Thread based synchronization </li></ul></u...
Solaris 1:1 Thread Model Java Application Java Thread JVM Solaris OS OS Kernel Solaris Thread LWP Kernel Thread
Solaris 1:1 Thread Model <ul><li>Solaris 1:1 Thread Model </li></ul><ul><ul><li>Bound thread </li></ul></ul><ul><ul><li>Al...
JVM Performance Test on Solaris < Solaris 8 with JVM 1.3 > See next page graph!! Architecture Cpus Threads Model %diff in ...
JVM Performance Test on Solaris <ul><li>Performance Test Result Graph </li></ul>
Memory Tuning Memory Model
Memory Tuning <ul><li>Garbage Collection </li></ul><ul><li>JVM Memory Layout </li></ul><ul><li>Garbage Collection Model </...
Generational Garbage Collection
JVM Memory Layout <ul><li>New/Young – Recently created object </li></ul><ul><li>Old – Long lived object </li></ul><ul><li>...
Garbage Collection <ul><li>Garbage Collection </li></ul><ul><ul><li>Collecting unused java object </li></ul></ul><ul><ul><...
Minor GC <ul><li>Minor Collection </li></ul><ul><ul><li>New/Young Generation </li></ul></ul><ul><ul><li>Copy and Scavenge ...
Minor GC Eden SS1 SS1 Copy live objects to  Survivor area New Object Garbage Lived Object 1 st  Minor GC Old Old Old
Minor GC 2 nd  Minor GC Old Old Old New Object Garbage Lived Object
Minor GC OLD 3 rd  Minor GC Objects moved old space when they become tenured New Object Garbage Lived Object
Major GC <ul><li>Major Collection </li></ul><ul><ul><li>Old Generation </li></ul></ul><ul><ul><li>Mark and compact </li></...
Major GC Eden SS1 SS2 Eden SS1 SS2 Mark the objects to be removed Eden SS1 SS2 Compact the objects to be removed
Server option versus Client option <ul><li>-X:NewRatio=2 (1.3) , -Xmn128m(1.4), -XX:NewSize=<size> -XX:MaxNewSize=<size> <...
GC Tuning Parameter <ul><li>Memory Tuning Parameter </li></ul><ul><ul><li>Perm Size : -XX:MaxPermSize=64m </li></ul></ul><...
Support for –XX Option <ul><li>Options that begin with  -X  are nonstandard (not guaranteed to be supported on all VM impl...
Garbage Collection Model <ul><li>New type of GC </li></ul><ul><ul><li>Default Collector </li></ul></ul><ul><ul><li>Paralle...
Parallel GC <ul><li>Parallel GC </li></ul><ul><ul><li>Improve performance of GC </li></ul></ul><ul><ul><li>For young gener...
Parallel GC <ul><li>Two Parallel Collectors </li></ul><ul><ul><li>Low-pause : -XX:+UseParNewGC </li></ul></ul><ul><ul><ul>...
Parallel GC <ul><li>Throughput Collector </li></ul><ul><ul><li>– XX:+UseParallelGC </li></ul></ul><ul><ul><li>-XX:Parallel...
Parallel GC <ul><li>Throughput Collector </li></ul><ul><ul><li>AggressiveHeap </li></ul></ul><ul><ul><ul><li>Enabled By-XX...
Concurrent GC <ul><li>Concurrent GC </li></ul><ul><ul><li>Reduce pause time to collect   Old Generation </li></ul></ul><ul...
Incremental GC <ul><li>Incremental GC </li></ul><ul><ul><li>Enabled by –XIncgc (from JDK 1.3) </li></ul></ul><ul><ul><li>C...
Incremental GC <ul><li>Incremental GC </li></ul>Minor GC After many time of Minor GC Full GC Minor GC Minor GC Old Generat...
Incremental GC <ul><li>Incremental GC </li></ul><ul><ul><li>-client –XX:+PrintGCDetails  -Xincgc  –ms32m –mx32m  </li></ul...
Best Pause Concurrent GC Best Throughput Parallel GC Better Pause Incremental GC(Train) Better throughput Mark-compact
Garbage Collection Measurement  <ul><li>-verbosegc (All Platform) </li></ul><ul><li>-XX:+PrintGCDetails ( JDK 1.4) </li></...
Garbage Collection Measurement <ul><li>-verbosegc </li></ul>[GC 40549K->20909K(64768K), 0.0484179 secs] [GC 41197K->21405K...
GC Log analysis using AWK script <ul><li>Awk script </li></ul>BEGIN{ printf(&quot;Minor	Major	Alive	Free
&quot;); } { if( ...
GC Log analysis using AWK script < GC Time >
GC Log analysis using HPJtune ※  http://www.hp.com/products1/unix/java/java2/hpjtune/index.html
GC Log analysis using AWK script < GC Amount >
Garbage Collection Tuning <ul><li>GC Tuning </li></ul><ul><ul><li>Find Most Important factor </li></ul></ul><ul><ul><ul><l...
Garbage Collection Tuning <ul><li>GC Tuning </li></ul><ul><ul><li>Full GC    Most important factor in GC tuning  </li></u...
Jmeter / Threads Histogram
Jmeter /Threads Group Histogram
Example
Example 2004-01-08  오후  7:14 2004-01-09  오전  8 시 전후 2004-01-09  오후  7 시 전후 금요일 업무시간 2004-01-10 오전  10 시 전후 2004-01-10 오후  ...
Example Peak Time  시에  Old GC  시간이  4~8 sec 로  이로 인한  Hang 현상 유발이 가능함 Before Tuned GC Time
Example 12 일 03:38A 12 일 05:58P 13 일 07:18A 13 일 09:38P 14 일 11:58A 15 일 01:18A 15 일 03:38P 16 일 05:58A 16 일 07:18P 17 일 0...
Example 12 일 03:38A 12 일 05:58P 13 일 07:18A 13 일 09:38P 14 일 11:58A 15 일 01:18A 15 일 03:38P 16 일 05:58A 16 일 07:18P 17 일 0...
Summary
JVM Tuning Summary <ul><li>Determine JVM performance goal </li></ul><ul><li>Gather statistics on your application </li></u...
More Tips More Tips
Thread dump <ul><li>Thread dump </li></ul><ul><ul><li>Enabled by </li></ul></ul><ul><ul><ul><li>Unix “kill –3 [JAVA PID]” ...
Thread dump example <ul><li>&quot;&quot; </li></ul><ul><li>Thread dump when slowdown in WAS </li></ul>ExecuteThread: '232'...
<ul><li>Profiling CPU usage/HP UX </li></ul><ul><ul><li>HP UX : Glance + Thread Dump </li></ul></ul>HP Glance Press “G” Th...
<ul><li>Profiling CPU usage/HP UX </li></ul>&quot;Application Manager Thread&quot; prio=8 tid=0x002a6c00 nid=62 lwp_id=159...
<ul><li>Other tools </li></ul><ul><ul><li>Profile with Java option </li></ul></ul><ul><ul><li>Analyze using HP Jmeter </li...
<ul><li>Related URL </li></ul><ul><ul><li>Java Thread http://java.sun.com/docs/hotspot/threads/threads.htm </li></ul></ul>...
Thank you
Upcoming SlideShare
Loading in...5
×

Jvm Performance Tunning

4,772

Published on

JVM performance tuning guide.
describes JVM memory structure and explains gc mechanism.
and guide for tuning jvm.

Published in: Technology
0 Comments
21 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,772
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
565
Comments
0
Likes
21
Embeds 0
No embeds

No notes for slide
  • Jvm Performance Tunning

    1. 1. JavaStudy Network Daehyub Cho JVM [Java Virtual Machine] Performance Tuning
    2. 2. AGENDA Basic concept of JVM Tuning 1 Hotspot compiler 2 Threading Model 3 Memory Model 4
    3. 3. Basic Concept of JVM Tuning Basic concept of JVM Tuning
    4. 4. Basic of performance tuning <ul><li>Decide what performance level is “good enough” </li></ul><ul><li>Test & measurement </li></ul><ul><ul><li>Scenario based </li></ul></ul><ul><ul><li>Stress Tool (Load Runner) </li></ul></ul><ul><ul><li>Profiling Tool (J probe, etc) </li></ul></ul><ul><li>Profile application to find bottlenecks </li></ul><ul><li>Tuning </li></ul><ul><ul><li>Application * </li></ul></ul><ul><ul><li>Middleware [WAS] </li></ul></ul><ul><ul><li>OS </li></ul></ul><ul><ul><li>JVM </li></ul></ul><ul><li>Return to Step 2 [feedback] </li></ul>
    5. 5. JVM Tuning <ul><li>Improve performance about 10~20% </li></ul><ul><li>Find appropriate parameter for your application </li></ul><ul><ul><li>Hotspot compile option </li></ul></ul><ul><ul><li>Thread model option * </li></ul></ul><ul><ul><li>GC and memory related option ** </li></ul></ul><ul><li>Changing parameter is very dangerous action </li></ul><ul><ul><li>Need more test and feed back </li></ul></ul><ul><ul><li>Ref spec.org </li></ul></ul>
    6. 6. Hotspot Compiler Hotspot compiler
    7. 7. JVM Layout <ul><li>Hotspot from JDK 1.3 </li></ul>VM Client Compiler Server Compiler <ul><li>Runtime </li></ul><ul><li>GC </li></ul><ul><li>Interpreter </li></ul><ul><li>Threading & Locking </li></ul><ul><li>… . </li></ul>JVM Hotspot Compiler
    8. 8. Hotspot compiler <ul><li>JIT (Just-In-Time Compiler) </li></ul><ul><ul><li>Compile byte code to native code </li></ul></ul><ul><ul><li>Compile as rules of optimization (Not thinking) </li></ul></ul><ul><ul><li>At execution/installation </li></ul></ul><ul><ul><li>Compile byte code to native code </li></ul></ul><ul><li>Hotspot </li></ul><ul><ul><li>Compile byte code to native code </li></ul></ul><ul><ul><li>‘ Thinking’ to trying find where optimization can take place </li></ul></ul><ul><ul><li>Adaptive Optimizing in runtime </li></ul></ul>
    9. 9. Hotspot Detection <ul><li>Hotspot detection </li></ul><ul><li>Method Inlining </li></ul><ul><li>Dynamic Deoptimization </li></ul>
    10. 10. Hotspot Detection and Method Inlining <ul><li>Literal constants are folded </li></ul><ul><li>String concatenation is sometimes folded </li></ul><ul><li>Constant fields are inlined </li></ul>int foo = 9* 10;  int foo = 90; String foo = “Hello “ + (9*10);  String foo = “Hello 90”; public class A{ public static final VALUE=99; } public class B{ static int VALUE2=A.VALUE; } public class B{ static int VALUE2=99; }  When after compiling class B
    11. 11. Hotspot detection / Method Inlining <ul><li>Dead code branches are eliminated </li></ul>public class A{ static final boolean DEBUG = false; public void methodA() if(DEBUG) System.out.println(“DEBUG MODE); System.out.println(“Say Hello”); }// method A }// class A ↓ public class A{ static final boolean DEBUG = false; public void methodA() System.out.println(“Say Hello”); }// method A }// class A
    12. 12. Hotspot Client compiler <ul><li>Java Option : -client </li></ul><ul><li>Focused on Simple & Fast start up </li></ul><ul><li>3 Phase compiler </li></ul><ul><ul><li>HIR (High Level Intermediate Representation) </li></ul></ul><ul><ul><li>LIR (Low Level Intermediate Representation) </li></ul></ul><ul><ul><li>Machine code </li></ul></ul><ul><li>It focuses on local code quality and does very few global optimizations since those are often the most expensive in terms of compile time </li></ul><ul><li>It has for inlining any function that has no exception handlers or synchronization and also supports deoptimization for debugging and inlining </li></ul>
    13. 13. Hotspot Server compiler <ul><li>Java Option : -server </li></ul><ul><li>Focused on optimization </li></ul><ul><li>SSA (Static Single Assignment)-based IR </li></ul>
    14. 14. Hotspot compiler Option <ul><li>Hotspot compile option </li></ul><ul><ul><li>-XX:MaxInlineSize=<size> </li></ul></ul><ul><ul><ul><li>Integer specifying maximum number of bytecode instructions in a method which gets inlined. </li></ul></ul></ul><ul><ul><li>-XX:FreqInlineSize=<size> </li></ul></ul><ul><ul><ul><li>Integer specifying maximum number of bytecode instructions in a frequently executed method which gets inlined. </li></ul></ul></ul><ul><ul><li>-Xint </li></ul></ul><ul><ul><ul><li>Interpreter only (no JIT compilation) </li></ul></ul></ul><ul><ul><li>-XX:+PrintCompilation </li></ul></ul>
    15. 15. Threading Threading model
    16. 16. Threading Model <ul><li>Thread Model </li></ul><ul><ul><li>Java is multi threaded programming language </li></ul></ul><ul><ul><li>Native thread model from JDK 1.2 </li></ul></ul><ul><ul><ul><li>Thread mapping (M:N and 1:1) </li></ul></ul></ul><ul><ul><ul><li>Thread synchronization </li></ul></ul></ul>Java Application Java Thread Operating System Thread Handling Thread Scheduling Lock Mgmt (synchronization) JVM
    17. 17. Solaris M:N Thread Model Java Application Java Thread JVM Solaris OS OS Kernel Solaris Thread LWP Kernel Thread
    18. 18. Solaris M:N Thread Model <ul><li>Solaris M:N Thread Model </li></ul><ul><ul><li>Thread based synchronization </li></ul></ul><ul><ul><li>LWP based synchronization </li></ul></ul>Default -XX:-UseLWPSynchronization JDK1.4 -XX:+UseLWPSynchronization Default JDK1.3 Default N/A JDK1.2 LWP based sync Thread based sync
    19. 19. Solaris 1:1 Thread Model Java Application Java Thread JVM Solaris OS OS Kernel Solaris Thread LWP Kernel Thread
    20. 20. Solaris 1:1 Thread Model <ul><li>Solaris 1:1 Thread Model </li></ul><ul><ul><li>Bound thread </li></ul></ul><ul><ul><li>Alternate Libthread </li></ul></ul>※ In Solaris 9, alternate lib thread is default, do not add /usr/lib/lwp to LD_LIBRARY_PATH export LD_LIBRARY_PATH=/usr/lib/lwp -XX:+UseBoundThreads JDK1.4 export LD_LIBRARY_PATH=/usr/lib/lwp -XX:+UseBoundThreads JDK1.3 export LD_LIBRARY_PATH=/usr/lib/lwp N/A JDK1.2 Alternate Libthread* Bound Thread
    21. 21. JVM Performance Test on Solaris < Solaris 8 with JVM 1.3 > See next page graph!! Architecture Cpus Threads Model %diff in throughput (against Standard Model) Sparc 30 400/2000 Standard --- Sparc 30 400/2000 LWP Synchronization 215%/800% Sparc 30 400/2000 Bound Threads -10%/-80% Sparc 30 400/2000 Alternate One-to-one 275%/900% Sparc 4 400/2000 Standard --- Sparc 4 400/2000 LWP Synchronization 30%/60% Sparc 4 400/2000 Bound Threads -5%/-45% Sparc 4 400/2000 Alternate One-to-one 30%/50% Sparc 2 400/2000 Standard --- Sparc 2 400/2000 LWP Synchronization 0%/25% Sparc 2 400/2000 Bound Threads -30%/-40% Sparc 2 400/2000 Alternate One-to-one -10%/0% Intel 4 400/2000 Standard --- Intel 4 400/2000 LWP Synchronization 25%/60% Intel 4 400/2000 Bound Threads 0%/-10% Intel 4 400/2000 Alternate One-to-one 20%/60% Intel 2 400/2000 Standard --- Intel 2 400/2000 LWP Synchronization 15%/45% Intel 2 400/2000 Bound Threads -10%/-15% Intel 2 400/2000 Alternate One-to-one 15%/35%
    22. 22. JVM Performance Test on Solaris <ul><li>Performance Test Result Graph </li></ul>
    23. 23. Memory Tuning Memory Model
    24. 24. Memory Tuning <ul><li>Garbage Collection </li></ul><ul><li>JVM Memory Layout </li></ul><ul><li>Garbage Collection Model </li></ul><ul><li>Server VM and Client VM </li></ul><ul><li>Garbage Collection Measurement & Analysis </li></ul><ul><li>Tuning Garbage Collection </li></ul>
    25. 25. Generational Garbage Collection
    26. 26. JVM Memory Layout <ul><li>New/Young – Recently created object </li></ul><ul><li>Old – Long lived object </li></ul><ul><li>Perm – JVM classes and methods </li></ul>Eden Old Perm New/Young Old Used in Application JVM Total Heap Size SS1 SS2
    27. 27. Garbage Collection <ul><li>Garbage Collection </li></ul><ul><ul><li>Collecting unused java object </li></ul></ul><ul><ul><li>Cleaning memory </li></ul></ul><ul><ul><li>Minor GC </li></ul></ul><ul><ul><ul><li>Collection memory in New/Young generation </li></ul></ul></ul><ul><ul><li>Major GC (Full GC) </li></ul></ul><ul><ul><ul><li>Collection memory in Old generation </li></ul></ul></ul>
    28. 28. Minor GC <ul><li>Minor Collection </li></ul><ul><ul><li>New/Young Generation </li></ul></ul><ul><ul><li>Copy and Scavenge </li></ul></ul><ul><ul><li>Very Fast </li></ul></ul>
    29. 29. Minor GC Eden SS1 SS1 Copy live objects to Survivor area New Object Garbage Lived Object 1 st Minor GC Old Old Old
    30. 30. Minor GC 2 nd Minor GC Old Old Old New Object Garbage Lived Object
    31. 31. Minor GC OLD 3 rd Minor GC Objects moved old space when they become tenured New Object Garbage Lived Object
    32. 32. Major GC <ul><li>Major Collection </li></ul><ul><ul><li>Old Generation </li></ul></ul><ul><ul><li>Mark and compact </li></ul></ul><ul><ul><li>Slow </li></ul></ul><ul><ul><ul><li>1 st – goes through the entire heap , marking unreachable objects </li></ul></ul></ul><ul><ul><ul><li>2 nd – unreachable objects are compacted </li></ul></ul></ul>
    33. 33. Major GC Eden SS1 SS2 Eden SS1 SS2 Mark the objects to be removed Eden SS1 SS2 Compact the objects to be removed
    34. 34. Server option versus Client option <ul><li>-X:NewRatio=2 (1.3) , -Xmn128m(1.4), -XX:NewSize=<size> -XX:MaxNewSize=<size> </li></ul>
    35. 35. GC Tuning Parameter <ul><li>Memory Tuning Parameter </li></ul><ul><ul><li>Perm Size : -XX:MaxPermSize=64m </li></ul></ul><ul><ul><li>Total Heap Size : -ms512m –mx 512m </li></ul></ul><ul><ul><li>New Size </li></ul></ul><ul><ul><ul><li>-XX:NewRatio=2  Old/New Size </li></ul></ul></ul><ul><ul><ul><li>-XX:NewSize=128m </li></ul></ul></ul><ul><ul><ul><li>-Xmn128m (JDK 1.4) </li></ul></ul></ul><ul><ul><li>Survivor Size : -XX:SurvivorRatio=64 (eden/survivor) </li></ul></ul><ul><ul><li>Heap Ratio </li></ul></ul><ul><ul><ul><li>-XX:MaxHeapFreeRatio=70 </li></ul></ul></ul><ul><ul><ul><li>-XX:MinHeapFreeRatio=40 </li></ul></ul></ul><ul><ul><li>Suvivor Ratio </li></ul></ul><ul><ul><ul><li>-XX:TargetSurvivorRatio=50 </li></ul></ul></ul>
    36. 36. Support for –XX Option <ul><li>Options that begin with -X are nonstandard (not guaranteed to be supported on all VM implementations), and are subject to change without notice in subsequent releases of the Java 2 SDK. </li></ul><ul><li>Because the -XX options have specific system requirements for correct operation and may require privileged access to system configuration parameters, they are not recommended for casual use. These options are also subject to change without notice . </li></ul>
    37. 37. Garbage Collection Model <ul><li>New type of GC </li></ul><ul><ul><li>Default Collector </li></ul></ul><ul><ul><li>Parallel GC for young generation - JDK 1.4 </li></ul></ul><ul><ul><li>Concurrent GC for old generation - JDK 1.4 </li></ul></ul><ul><ul><li>Incremental Low Pause Collector (Train GC) </li></ul></ul>
    38. 38. Parallel GC <ul><li>Parallel GC </li></ul><ul><ul><li>Improve performance of GC </li></ul></ul><ul><ul><li>For young generation (Minor GC) </li></ul></ul><ul><ul><li>More than 4CPU and 256MB Physical memory required </li></ul></ul>threads time gc threads Default GC Parallel GC Young Generation
    39. 39. Parallel GC <ul><li>Two Parallel Collectors </li></ul><ul><ul><li>Low-pause : -XX:+UseParNewGC </li></ul></ul><ul><ul><ul><li>Near real-time or pause dependent application </li></ul></ul></ul><ul><ul><ul><li>Works with </li></ul></ul></ul><ul><ul><ul><ul><li>Mark and compact collector </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Concurrent old area collector </li></ul></ul></ul></ul><ul><ul><li>Throughput : -XX:+UseParallelGC </li></ul></ul><ul><ul><ul><li>Enterprise or throughput oriented application </li></ul></ul></ul><ul><ul><ul><li>Works only with the mark and compact collector </li></ul></ul></ul>
    40. 40. Parallel GC <ul><li>Throughput Collector </li></ul><ul><ul><li>– XX:+UseParallelGC </li></ul></ul><ul><ul><li>-XX:ParallelGCThreads=<desired number> </li></ul></ul><ul><ul><li>-XX:+UseAdaptiveSizePolicy </li></ul></ul><ul><ul><ul><li>Adaptive resizing of the young generation </li></ul></ul></ul>
    41. 41. Parallel GC <ul><li>Throughput Collector </li></ul><ul><ul><li>AggressiveHeap </li></ul></ul><ul><ul><ul><li>Enabled By-XX:+AggresiveHeap </li></ul></ul></ul><ul><ul><ul><li>Inspect machine resources and attempts to set various parameters to be optimal for long-running,memory-intensive jobs </li></ul></ul></ul><ul><ul><ul><ul><li>Useful in more than 4 CPU machine, more than 256M </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Useful in Server Application </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Do not use with –ms and –mx </li></ul></ul></ul></ul><ul><ul><ul><li>Example) HP Itanium 1.4.2 java -XX:+ServerApp -XX:+AggresiveHeap -Xmn3400m -spec.jbb.JBBmain -propfile Test1 </li></ul></ul></ul>
    42. 42. Concurrent GC <ul><li>Concurrent GC </li></ul><ul><ul><li>Reduce pause time to collect Old Generation </li></ul></ul><ul><ul><li>For old generation (Full GC) </li></ul></ul><ul><ul><li>Enabled by - XX:+UseConcMarkSweepGC </li></ul></ul>threads time gc threads Default GC Concurrent GC Old Generation
    43. 43. Incremental GC <ul><li>Incremental GC </li></ul><ul><ul><li>Enabled by –XIncgc (from JDK 1.3) </li></ul></ul><ul><ul><li>Collect Old generation whenever collect young generation </li></ul></ul><ul><ul><li>Reduce pause time for collect old generation </li></ul></ul><ul><ul><li>Disadvantage </li></ul></ul><ul><ul><ul><li>More frequently young generation GC has occurred. </li></ul></ul></ul><ul><ul><ul><li>More resource is needed </li></ul></ul></ul><ul><ul><ul><li>Do not use with –XX:+UseParallelGC and –XX:+UseParNewGC </li></ul></ul></ul>
    44. 44. Incremental GC <ul><li>Incremental GC </li></ul>Minor GC After many time of Minor GC Full GC Minor GC Minor GC Old Generation is collected in Minor GC Default GC Incremental GC Young Generation Old Generation
    45. 45. Incremental GC <ul><li>Incremental GC </li></ul><ul><ul><li>-client –XX:+PrintGCDetails -Xincgc –ms32m –mx32m </li></ul></ul>[GC [DefNew: 540K->35K(576K), 0.0053557 secs][Train: 3495K->3493K(32128K), 0.0043531 secs] 4036K->3529K(32704K), 0.0099856 secs] [GC [DefNew: 547K->64K(576K), 0.0048216 secs][Train: 3529K->3540K(32128K), 0.0058683 secs] 4041K->3604K(32704K), 0.0109779 secs] [GC [DefNew: 575K->64K(576K), 0.0164904 secs] 4116K->3670K(32704K), 0.0169019 secs] [GC [DefNew: 576K->64K(576K), 0.0057541 secs][Train: 3671K->3651K(32128K), 0.0051286 secs] 4182K->3715K(32704K), 0.0113042 secs] [GC [DefNew: 575K->56K(576K), 0.0114559 secs] 4227K->3745K(32704K), 0.0191390 secs] [ Full GC [Train MSC: 3689K->3280K(32128K), 0.0909523 secs] 4038K->3378K(32704K), 0.0910213 secs ] [GC [ DefNew: 502K->64K(576K), 0.0173220 secs ][Train: 3329K->3329K(32128K), 0.0066279 secs] 3782K->3393K(32704K), 0.0325125 secs Young Generation GC Old Generation GC in Minor GC Time Minor GC Full GC Sun JVM 1.4.1 in Windows OS
    46. 46. Best Pause Concurrent GC Best Throughput Parallel GC Better Pause Incremental GC(Train) Better throughput Mark-compact
    47. 47. Garbage Collection Measurement <ul><li>-verbosegc (All Platform) </li></ul><ul><li>-XX:+PrintGCDetails ( JDK 1.4) </li></ul><ul><li>-Xverbosegc (HP) </li></ul>
    48. 48. Garbage Collection Measurement <ul><li>-verbosegc </li></ul>[GC 40549K->20909K(64768K), 0.0484179 secs] [GC 41197K->21405K(64768K), 0.0411095 secs] [GC 41693K->22995K(64768K), 0.0846190 secs] [GC 43283K->23672K(64768K), 0.0492838 secs] [Full GC 43960K->1749K(64768K), 0.1452965 secs] [GC 22037K->2810K(64768K), 0.0310949 secs] [GC 23098K->3657K(64768K), 0.0469624 secs] [GC 23945K->4847K(64768K), 0.0580108 secs] Full GC Total Heap Size GC Time Heap size after GC Heap size before GC
    49. 49. GC Log analysis using AWK script <ul><li>Awk script </li></ul>BEGIN{ printf(&quot;Minor Major Alive Free &quot;); } { if( substr($0,1,4) == &quot;[GC &quot;){ split($0,array,&quot; &quot;); printf(&quot;%s 0.0 &quot;,array[3]) split(array[2],barray,&quot;K&quot;) before=barray[1] after=substr(barray[2],3) reclaim=before-after printf(&quot;%s %s &quot;,after,reclaim) } if( substr($0,1,9) == &quot;[Full GC &quot;){ split($0,array,&quot; &quot;); printf(&quot;0.0 %s &quot;,array[4]) split(array[3],barray,&quot;K&quot;) before = barray[1] after = substr(barray[2],3) reclaim = before - after printf(&quot;%s %s &quot;,after,reclaim) } next; } % awk –f gc.awk gc.log ※ Usage gc.awk Minor       Major       Alive       Freed 0.0484179   0.0         20909       19640 0.0411095   0.0         21405       19792 0.0846190   0.0         22995       18698 0.0492838   0.0         23672       19611 0.0         0.1452965   1749        42211 0.0310949   0.0         2810        19227 0.0469624   0.0         3657        19441 0.0580108   0.0         4847        19098 gc.log
    50. 50. GC Log analysis using AWK script < GC Time >
    51. 51. GC Log analysis using HPJtune ※ http://www.hp.com/products1/unix/java/java2/hpjtune/index.html
    52. 52. GC Log analysis using AWK script < GC Amount >
    53. 53. Garbage Collection Tuning <ul><li>GC Tuning </li></ul><ul><ul><li>Find Most Important factor </li></ul></ul><ul><ul><ul><li>Low pause? Or High performance? </li></ul></ul></ul><ul><ul><ul><li>Select appropriate GC model (New Model has risk!!) </li></ul></ul></ul><ul><ul><li>Select “server” or “client” </li></ul></ul><ul><ul><li>Find appropriate Heap size by reviewing GC log </li></ul></ul><ul><ul><li>Find ratio of young and old generation </li></ul></ul>
    54. 54. Garbage Collection Tuning <ul><li>GC Tuning </li></ul><ul><ul><li>Full GC  Most important factor in GC tuning </li></ul></ul><ul><ul><ul><li>How frequently ? How long ? </li></ul></ul></ul><ul><ul><ul><li>Short and Frequently  decrease old space </li></ul></ul></ul><ul><ul><ul><li>Long and Sometimes  increase old space </li></ul></ul></ul><ul><ul><ul><li>Short and Sometimes  decrease throughput  by Load balancing </li></ul></ul></ul><ul><ul><li>Fix Heap size </li></ul></ul><ul><ul><ul><li>Set “ms” and “mx” as same </li></ul></ul></ul><ul><ul><ul><li>Remove shrinking and growing overhead </li></ul></ul></ul><ul><ul><li>Don’t </li></ul></ul><ul><ul><ul><li>Don’t make heap size bigger than physical memory (SWAP) </li></ul></ul></ul><ul><ul><ul><li>Don’t make new generation bigger than half the heap </li></ul></ul></ul>
    55. 55. Jmeter / Threads Histogram
    56. 56. Jmeter /Threads Group Histogram
    57. 57. Example
    58. 58. Example 2004-01-08 오후 7:14 2004-01-09 오전 8 시 전후 2004-01-09 오후 7 시 전후 금요일 업무시간 2004-01-10 오전 10 시 전후 2004-01-10 오후 6 시 전후 PEAK TIME 52000~56000 sec 9 시 ~ 1 시간 가량 Before Tuned Old Area
    59. 59. Example Peak Time 시에 Old GC 시간이 4~8 sec 로 이로 인한 Hang 현상 유발이 가능함 Before Tuned GC Time
    60. 60. Example 12 일 03:38A 12 일 05:58P 13 일 07:18A 13 일 09:38P 14 일 11:58A 15 일 01:18A 15 일 03:38P 16 일 05:58A 16 일 07:18P 17 일 08:38A 17 일 10:58P Weekend Mon Office Our Tue Office Our Thur Office Our Fri Office Our After AP Tuned GC Time
    61. 61. Example 12 일 03:38A 12 일 05:58P 13 일 07:18A 13 일 09:38P 14 일 11:58A 15 일 01:18A 15 일 03:38P 16 일 05:58A 16 일 07:18P 17 일 08:38A 17 일 10:58P Weekend Mon Office Our Tue Office Our Thur Office Our Fri Office Our
    62. 62. Summary
    63. 63. JVM Tuning Summary <ul><li>Determine JVM performance goal </li></ul><ul><li>Gather statistics on your application </li></ul><ul><li>Select hotspot compiler </li></ul><ul><li>Tuning heap </li></ul><ul><li>Check threading model </li></ul><ul><li>Feedback </li></ul>
    64. 64. More Tips More Tips
    65. 65. Thread dump <ul><li>Thread dump </li></ul><ul><ul><li>Enabled by </li></ul></ul><ul><ul><ul><li>Unix “kill –3 [JAVA PID]” </li></ul></ul></ul><ul><ul><ul><li>Windows “Ctrl+Break” </li></ul></ul></ul><ul><ul><li>Snapshot of java application </li></ul></ul><ul><ul><li>Can profiling “hang-up”, and “slow-down” </li></ul></ul>
    66. 66. Thread dump example <ul><li>&quot;&quot; </li></ul><ul><li>Thread dump when slowdown in WAS </li></ul>ExecuteThread: '232' for queue: 'default'&quot; daemon prio=5 tid=0x573ca630 nid=0xd2c waiting for monitor entry [0x5cebf000..0x5cebfdb8] at java.util.Hashtable.get(Hashtable.java:314) at java.util.ListResourceBundle.handleGetObject(ListResourceBundle.java:122) at java.util.ResourceBundle.getObject(ResourceBundle.java:371) at java.util.ResourceBundle.getObject(ResourceBundle.java:374) at java.text.DateFormatSymbols.initializeData(DateFormatSymbols.java:483) at java.text.DateFormatSymbols.<init>(DateFormatSymbols.java:99) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:275) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:264) at XXX.uv.com.cm.CmDateTimeUtil.getCurrentTime(CmDateTimeUtil.java:88) at XXX.uv.com.util.CmLog.setFileLog(CmLog.java:171) at XXX.uv.com.jsp.EjbJspBase.service(EjbJspBase.java:371) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2546) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2260) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) &quot;ExecuteThread: '231' for queue: 'default'&quot; daemon prio=5 tid=0x573f9a60 nid=0x13a8 waiting for monitor entry [0x5ce7f000..0x5ce7fdb8] at java.util.Hashtable.get(Hashtable.java:314) at java.text.DecimalFormatSymbols.initialize(DecimalFormatSymbols.java:333) at java.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:55) at java.text.NumberFormat.getInstance(NumberFormat.java:565) at java.text.NumberFormat.getInstance(NumberFormat.java:324) at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:327) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:276) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:264) at XXX.uv.com.cm.CmDateTimeUtil.getCurrentTime(CmDateTimeUtil.java:88) at XXX.uv.com.cm.CmDateTimeUtil.getCurrentTime(CmDateTimeUtil.java:67) at XXX.uv.com.datastu.DateTime.setCurrentTime(DateTime.java:190) at XXX.uv.com.jsp.EjbJspBase.service(EjbJspBase.java:239) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2546) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2260) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    67. 67. <ul><li>Profiling CPU usage/HP UX </li></ul><ul><ul><li>HP UX : Glance + Thread Dump </li></ul></ul>HP Glance Press “G” Thread monitoring
    68. 68. <ul><li>Profiling CPU usage/HP UX </li></ul>&quot;Application Manager Thread&quot; prio=8 tid=0x002a6c00 nid=62 lwp_id=15999 waiting o n monitor [0x64bce000..0x64bce4b8] at java.lang.Thread.sleep(Native Method) at weblogic.management.mbeans.custom.ApplicationManager$ApplicationPolle r.run(ApplicationManager.java:1137) CPU Load of Thread 15999 is 17.7% Thread 15999 is working on weblogic.management.mbeans.custom.ApplicationManager (ApplicationManger.java 1137) Glance Thread Monitoring Java Thread Dump
    69. 69. <ul><li>Other tools </li></ul><ul><ul><li>Profile with Java option </li></ul></ul><ul><ul><li>Analyze using HP Jmeter </li></ul></ul><ul><ul><li>Jprobe </li></ul></ul><ul><ul><li>Stress Test </li></ul></ul><ul><ul><ul><li>Load Runner </li></ul></ul></ul><ul><ul><ul><li>MS Stress (Free) </li></ul></ul></ul>
    70. 70. <ul><li>Related URL </li></ul><ul><ul><li>Java Thread http://java.sun.com/docs/hotspot/threads/threads.htm </li></ul></ul><ul><ul><li>Java Performance http://java.sun.com/docs/hotspot/PerformanceFAQ.html </li></ul></ul><ul><ul><li>Java Thread http://www.javaworld.com/javaworld/jw-09-1998/jw-09-threads.html </li></ul></ul><ul><ul><li>Pick up performance with generational gc http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html </li></ul></ul><ul><ul><li>JVM1.4 GC Tunning http://java.sun.com/docs/hotspot/gc1.4.2/index.html </li></ul></ul><ul><ul><li>HP Jmeter,Jtune,Jconfig http://www.hp.com/products1/unix/java/developers/index.html </li></ul></ul><ul><ul><li>SPECjvm98 </li></ul></ul><ul><ul><li>SPECjAppServer2001/2002 </li></ul></ul>
    71. 71. Thank you
    1. Gostou de algum slide específico?

      Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

    ×