HotSpot JVM Tuning
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

HotSpot JVM Tuning

on

  • 7,155 views

HotSpot JVM Tuning

HotSpot JVM Tuning
A presentation about HotSpot JVM Tuning,
Garbage collectors and JVM Flags

Statistics

Views

Total Views
7,155
Views on SlideShare
7,152
Embed Views
3

Actions

Likes
20
Downloads
302
Comments
0

1 Embed 3

http://www.linkedin.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

HotSpot JVM Tuning Presentation Transcript

  • 1. HotSpot JVM Tuning
    By: Gilad Garon
    Technical
    Meeting!
  • 2. -Xmx2g
    It’s more than just:
    What is JVM Tuning?
    It’s a combination of:
    • Hardware selection
    • 3. Software architecture
    But most of all, JVM Tuning is about:
    Understanding how your application works!
  • 4. The IDI Test Case
    Choosing the right hardware
    Garbage Collectors
    JVM Tuning
    Agenda
    JVM Tuning
  • 5. Swing desktop client application
    Wicket web application
    Mobile web application (In development)
    Multiple AS:JBoss Clusters, Apache Cluster, Tomcat & Terracotta
    Multiple frameworks: Spring, Guice, Wicket, Hibernate, Terracotta DSO, XStream, EJB 3.0, JMS, CGLib & Proprietary frameworks
    Technical Information
    The IDI Test Case
  • 6. The IDI Test Case
  • 7. 3000 +/- EJB Invocations per minute
    100+ concurrent web sessions
    Internal Print servers clients
    Internal Mail servers clients
    Internal Webservices clients
    JBoss EAR cluster user load information
    The IDI Test Case
  • 8. The IDI Test Case
    Choosing the right hardware
    Garbage Collectors
    JVM Tuning
    Agenda
    JVM Tuning
  • 9. How many software engineers does it take to change a light bulb?
    Hardware choices affects code performance
    Hardware choices affects OS offerings (Do you really want Windows?)
    Hardware isn’t easily replaced, it costs a lot.
    Choosing the right hardware
    None. It's a hardware problem.
  • 10. Which CPU architecture is right for you?
    Higher clock speed? (what about Moore’s law?)
    Higher core count?
    Number of hardware threads?
    Choosing the right hardware
    Remember:
    • Not all CPU’s are created equally
    • 11. Highly computational apps relay on clock speed
    • 12. Highly concurrent / multi user app relay on number of threads
    • 13. Hardware benchmarking helps a lot, but it’s difficult to arrange
  • Intel Xeon / Itanium?
    AMD Operton?
    Sun SPARC?
    IBM Power?
    What should be your opinion?
    Choosing the right hardware
    The winner is….
    No one will ever ask for your opinion (almost)
  • 14. IDI Hardware history
    Choosing the right hardware @ IDI
  • 15. The IDI Test Case
    Choosing the right hardware
    Garbage Collectors
    JVM Tuning
    Agenda
    JVM Tuning
  • 16. Remember this?
    Garbage Collectors
    Garbage Collection means that don’t have to anymore
  • 17. When the JVM starts, the host OS assigns a dedicated memory space to that VM
    The VM allocates memory to the application within that dedicated memory space
    The VM frees memory automatically via garbage collectors
    Garbage Collection is an expensive algorithm
    JVM Memory Handling
    Garbage Collectors
  • 18. The memory space is divided into three separated memory spaces:
    Eden SpaceWhere objects are born
    Survivor SpacesWhere objects mature
    Tenure SpaceWhere objects grow old and die
    Generational Memory Space
    Garbage Collectors
  • 19. HotSpot VM‘s Generational Memory Space
    Garbage Collectors
    Eden Space
    Survivor Space 2
    Survivor Space 1
    Tenure (Old) Generation
    Permanent Generation
  • 20. ConcurrencyConcurrency describes its ability to do work while application threads are still running
    ParallelismParallelismdescribes the collector's ability to perform its work across multiple threads of execution.
    Hence, a collector can be parallel but not concurrent, concurrent but not parallel, or both parallel and concurrent.
    Technical Terms:
    Garbage Collectors
  • 21. Copy CollectorA collector that copies live object from one space to another
    Low Pause CollectorA collector that works along side the application threads
    Throughput CollectorA collector that doesn’t add to the serial execution time of the application
    Technical Terms:
    Garbage Collectors
  • 22. Memory FragmentationThe amount of unusable free memory (small holes that object can’t be fitted in)
    Stop the world:The application threads are stopped during the garbage collection
    Minor CollectionA garbage collection of the young generation
    Major CollectionA garbage collection of the old generation
    Technical Terms, Continued:
    Garbage Collectors
  • 23. Types of GC Strategies (Generational):
    Garbage Collectors
  • 24. Garbage Collectors
    “Parallel New” Strategy
    • Young generation collection is done in parallel (CMS Version)
    • 25. Old generation collection is done in serial
    “Parallel” Strategy
    • Young generation collection is done in parallel
    • 26. Old generation collection is done in serial
    “Parallel Old” Strategy
    Young generation collection is done in parallel
    Old generation collection is done mostly in parallel
  • 27. Low pause collector (short Stop the World pauses)
    Uses Parallel New for new generation GC
    Uses CMS for old generation GC
    Non compacting old generation collector
    Starts before the memory space is full (68%)
    Requires a larger heap
    Concurrent Mark-Sweep Strategy
    Garbage Collectors
  • 28. Serial Collector (New Generation Space)
    Garbage Collectors
  • 29. Serial GC Strategy - Young Generation
    Garbage Collectors
    No more room! Promoting to Tenure space
    Eden memory space
    Garbage Collection!
    Resuming Application
    Survived!Earned it’s place inTenure space
    Survivor space (To)
    Survivor space (From)
    Tenure memory space
  • 30. Serial Collector (Old Generation Space)
    Garbage Collectors
  • 31. Concurrent Mark-Sweep
    Garbage Collectors
  • 32. CMS - Old Generation
    Garbage Collectors
    Tenure memory space
    Garbage Collection!
    Resuming Application
    Stop The World!
    Phase:
    Initial Mark
    Concurrent Mark
    Remark
    Concurrent Sweep
    Concurrent Pre-Clean
  • 33. High probability soft real time collector
    One memory space for the young and tenure generation
    Entire memory space is divided into equally sized cards
    Cards are managed by regions and tracked by “Remembered Sets” for changes
    A global card table track all the cards
    Garbage First (G1) What’s the big deal?
    Garbage Collectors
  • 34. Garbage First (G1) - Heap Structure
    Garbage Collectors
    Card
    (512 Bytes)
    Region A
    Card
    (512 Bytes)
    Region B
    Global Card Table
    Card
    (512 Bytes)
    Region N
    Remembered Set (Per Region)
  • 35. Garbage First - Minor Collection
    Garbage Collectors
    Similar to Parallel New
    Compacts young regions
    Also compacts old regions if there’s time
    Garbage First - Major Collection
    • Reclaims empty regions at once
    • 36. Marks low lived ratio regions for collection in the minor collection phase
  • IDI GC Problem Related History
    Garbage Collectors @ IDI
  • 37. IDI Garbage Collection Strategy:
    Garbage Collectors @ IDI
  • 38. The IDI Test Case
    Choosing the right hardware
    Garbage Collectors
    JVM Tuning
    Agenda
    JVM Tuning
  • 39. This is JVM Tuning:
    JVM Tuning
  • 40. -Xmx<size><units>
    -Xms<size><units>
    -d64
    -server
    -XX:MaxPermSize=<size><units>
    -XX:-HeapDumpOnOutOfMemoryError
    The must know flags
    JVM Tuning
  • 41. -Xloggc:<file_name>
    -XX:+ PrintHeapAtGC
    -XX:+ PrintGCDateStamps
    -XX:+ PrintGCDetails
    -XX:+ PrintGCApplicationStoppedTime
    -XX:+ PrintGCApplicationConcurrentTime
    GC Logs
    JVM Tuning
  • 42. -XX:+ UseSerialGC
    -XX:+ UseParNewGC
    -XX:+UseConcMarkSweepGC 
    -XX:+ UseParallelGC
    -XX:+UseParallelOldGC
    -XX:+UseG1GC (JDK 1.7)
    -XX:+UnlockExperimentalVMOptions(for G1 JDK 1.6_14)
     
     
    Garbage Collector Strategies
    JVM Tuning
  • 43. Tuning GC
    JVM Tuning
  • 44. Tuning GC
    JVM Tuning
  • 45. Tuning GC
    JVM Tuning
  • 46. Tuning GC
    JVM Tuning
    And many many more…
  • 47. Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning
    Memory Management Whitepaper
    Garbage-First Garbage Collection Whitepaper
    Setting Java GC Parameters For Large Heaps
    Java Tuning White Paper
    Java HotSpot VM Options
    The most complete list of -XX options for Java 6 JVM
    G1: Java's Garbage First Garbage Collector`
    References
  • 48. The Garbage-First Garbage Collector (JavaOne 2008)
    JVM Internals - Garbage Collection & Runtime Optimizations
    Garbage Collection in the Java HotSpot Virtual Machine
    References