Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

HotSpot JVM Tuning

10,996 views

Published on

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

Published in: Technology
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

HotSpot JVM Tuning

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

×