JVM GC -调优总结

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

JVM  GC    1GC  Descrip.on  • What’s  GC?  – GC– • • GC  Descrip.on(2)• GC?  – • GCGC– • GCGCGC“Out  of  memory”  GC  Descrip.on(3)  • GC  – JVM  (heap)• GC• GCHeap  Descrip.on  • (heap)– java• • • – • (young  genera.on)    • (tenured  genera.on)  • (permanent  genera.on)  Heap  Descrip.on(2)  • (young  genera.on)    – :  EdenSurvivor  spaces  • Eden,infant  mortality”()• Survivor  spaces,GCEden()• Eden(minor  collec.on)Edeninfant  mortalityinfant  mortalityHeap  Descrip.on(3)  • (tenured  genera.on)  – Edenminor  collec.on– (major  collec.on)  Heap  Descrip.on(4)• Heap  Descrip.on(5)  • (permanent  genera.on)  – JavaHeap  Descrip.on(6)• heap  Performance  Tuning  • GCPerformance  Tuning(2)• :  – GC1%32(Throughput)20%  – GC10%32(Throughput)75%    Note:throughputGCPerformance  Tuning(3)• Performance  measurement  – Pause:  the  .mes  when  an  applica.on  appears  unresponsive  because  garbage  collec.on  is  occurring.    – Footprint:  the  working  set  of  a  process,  measured  in  pages  and  cache  lines  .  – Promptness  :the  .me  between  when  an  object  becomes  dead  and  when  the  memory  becomes  available.    Performance  Tuning(4)• How  to  leverage  these  measurement  – a  very  large  young  genera.on  may  maximize  throughput,  but  does  so  at  the  expense  of  footprint,  promptness,  and  pause  .mes.  – a  small  young  genera.on  can  minimize  pause  .mes  at  the  expense  of  throughput    Performance  Tuning(5)• Example  output  of  GC  Performance  Tuning(6)• To  get  detailed  info  of    GC  – -­‐XX:+PrintGCDetails    Example:    [GC  [DefNew:  64575K-­‐959K(64576K),  0.0457646  secs]  196016K-­‐133633K(261184K),  0.0459067  secs]]  – -­‐XX:+PrintGCTimestamps  Example:    111.042:  [GC  111.042:  [DefNew:  8128K-­‐8128K(8128K),  0.0000505  secs]111.042:  [Tenured:  18154K-­‐2311K(24576K),  0.1290354  secs]  26282K-­‐2311K(32704K),  0.1293306  secs]    Note:  the  output  format  of  above  flag  is  different  from  each  version  of  JVM.    Performance  Tuning(7)• Genera.on  size  diagram  Performance  Tuning(8)• Commiged  VS  Virtual    – commigedvirtualJVMheapreserve-­‐Xms-­‐Xmxreservedcommitcommitvirtual– commitedheap-­‐Xmx      Performance  Tuning(9)• Parameters  which  affect  total  heap  size  – -­‐XX:MinHeapFreeRa.o=  – -­‐XX:MaxHeapFreeRa.o=  – -­‐Xms  – -­‐Xmx  Note:  JVMGCheapfree-­‐XX:MinHeapFreeRa.o-­‐XX:MaxHeapFreeRa.o-­‐Xms-­‐XmxPerformance  Tuning(10)• Parameters  which  affect  young  genera.on  size  – -­‐XX:NewRa.o=  – -­‐XX:NewSize=  – -­‐XX:MaxNewSize=  – -­‐XX:SurvivorRa.o=  Note:  young  genera.onyoung  genera.onyoung  genera.onNewRa.oNewRa.o=4young  genera.onheap1/5NewSizeMaxNewSizeyoung  genera.onSurvivorRa.onsurvivoredenSurvivorRa.on=5survivoryoung  genera.on1/7(young  genera.onsurvivor)    Types  of  Collectors  • Collectors  in  J2SE  plalorm,  version  1.4.2  – Default  collector  – Throughput  collector  – Concurrent  low  pause  collector  – Incremental  low  pause  collector    Note:  default  collectorcollectordefault  collectorheap  sizecollector  Throughput  collector• What’s  Throughput  collector  – Throughput  collectoryoung  genera.ontenured  genera.ondefault  collector• When  to  use  Throughput  collector  – Throughput  collectorCPUDefault  collectorminorThroughput  collector• How  to  use  Throughput  collector  – Add  flag  -­‐XX:+UseParallelGC  to  command  lineThroughput  collector(2)• Performance  improvement  – CPU()throughput  collectordefault  collector– CPUthroughput  collectordefault  collector– 3CPUthroughput  collectorThroughput  collector(3)• GC  threads  in  Throughput  collector    – throughput  collectorGCCPUGCflag          -­‐XX:ParallelGCThreads=  • GC  sta.s.cs– Through  collectorheapyoung  genera.ontenured  genera.onflagon        -­‐XX:+UseAdap.veSizePolicy              Throughput  collector(4)• Self  tuning  by  Throughput  collector  – -­‐XX:+AggressiveHeap  CPUflagCPU– AggressiveHeap256Mheap(i.e.,  it  agempt  to  use  heaps  nearly  as  large  as  the  total  physical  memory  )Throughput  collector(5)• Possible  shortcomings    – minortenured  genera.onyoung  genera.ontenured  genera.onheap– GCtenured  genera.onConcurrent  Low  Pause  Collector  • What’s  Concurrent  Low  Pause  Collector  – Concurrent  collectortenured  genera.onmajor  collec.onGCthreadsGCCPU• When  to  use  Concurrent  Low  Pause  Collector  – Concurrent  collectorlong-­‐livedtenured  genera.onGCCPUCPU  Concurrent  Low  Pause  Collector(2)• How  to  use  Concurrent  Low  Pause  Collector  – To  use  concurrent  collectoryou  can  add  follow  flag  to  command  line  -­‐XX:+UseConcMarkSweepGC  • Two  pauses  during  the  collec.on  – Concurrent  collectorthreadscollec.oncollec.on(mark)remarkConcurrent  Low  Pause  Collector(3)• Full  collec.ons  – Concurrent  collectortenured  genera.ontenured  genera.ontenured  genera.onfull  collec.ongc.logfull  collec.ontenured  genera.on• Floa.ng  collec.ons  – GCheapGCGCGCfloa.ng  garbageFloa.ng  gar

1 / 37
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功