your programing

-XX : UseParallelGC와 -XX ​​: + UseParNewGC의 차이점

lovepro 2020. 10. 7. 08:03
반응형

-XX : UseParallelGC와 -XX ​​: + UseParNewGC의 차이점


젊은 세대의 가비지 수집을위한 알고리즘입니다.

두 번째 것 (UseParNewGC)은 동시 보유 세대 가비지 콜렉션 ( Java Concurrent 및 Parallel GC 참조)과 함께 자동으로 활성화 되지만 두 병렬 알고리즘간에 차이점이 있습니까?


많은 검색 끝에 내가 찾은 가장 좋은 설명은 Question of the month : 1.4.1 Garbage collection algorithms, January 29th, 2003에있는 Java Performance Tuning 웹 사이트에서 찾을 수 있습니다 .

젊은 세대 가비지 수집 알고리즘

(원본) 복사 수집기 (기본적으로 활성화). 이 수집기가 시작되면 모든 응용 프로그램 스레드가 중지되고 복사 수집은 하나의 스레드를 사용하여 진행됩니다 (멀티 CPU 시스템에 있더라도 하나의 CPU 만 의미 함). 기본적으로 JVM은 수집이 완료 될 때까지 다른 모든 것을 일시 중지하기 때문에이를 stop-the-world 수집이라고합니다.

평행 복사 수집기 (-XX하여 활성화 : UseParNewGC +). 원본 복사 수집가와 마찬가지로 이것은 세계 중지 수집가입니다. 그러나이 콜렉터는 다중 스레드에서 복사 콜렉션을 병렬화합니다. 이는 다중 CPU 머신에 대한 원래 단일 스레드 복사 콜렉터보다 효율적입니다 (단일 CPU 머신에는 해당되지 않음). 이 알고리즘은 원래의 단일 스레드 복사 수집기와 비교할 때 사용 가능한 CPU 수와 동일한 요소로 잠재적으로 젊은 세대 수집 속도를 높입니다.

평행 소기 컬렉터 (-XX을 사용하여 활성화 : UseParallelGC). 이것은 이전의 병렬 복사 수집기와 비슷하지만 알고리즘은 다중 CPU 시스템에서 기가 바이트 힙 (10GB 이상)에 맞게 조정됩니다. 이 수집 알고리즘은 일시 중지를 최소화하면서 처리량을 최대화하도록 설계되었습니다. 힙 공간의 크기를 자동으로 조정하는 선택적 조정 조정 정책이 있습니다. 이 수집기를 사용하는 경우 이전 세대의 원래 마크 스윕 수집기 만 사용할 수 있습니다 (즉, 최신 이전 세대 동시 수집기는이 젊은 세대 수집기와 함께 작동 할 수 없음).

이 정보에서 (CMS 협력을 제외하고) 주요 차이점은 UseParallelGC가 인체 공학지원 하는 반면 UseParNewGC는 지원 하지 않는다는 것입니다.


병렬 GC

  • XX : + UseParallelGC 청소를 위해 병렬 가비지 수집을 사용합니다. (1.4.1에 도입 됨)
  • XX : + UseParallelOldGC 전체 컬렉션에 대해 병렬 가비지 컬렉션을 사용합니다. 이 옵션을 활성화하면 -XX : + UseParallelGC가 자동으로 설정됩니다. (5.0 업데이트 6에 도입 됨)

UseParNewGC

UseParNewGC 젊은 세대 복사 수집기의 병렬 버전이 동시 수집기와 함께 사용됩니다 (즉, 명령 줄에서 -XX : + UseConcMarkSweepGC가 사용 된 경우 명령 줄에서 명시 적으로 설정되지 않은 경우 UseParNewGC 플래그도 true로 설정 됨) ).

이해하는 가장 쉬운 방법은 Alexey Ragozin이 만든 가비지 수집 알고리즘의 조합이었을 것입니다.

<table border="1" style="width:100%">
  <tr>
    <td align="center">Young collector</td>
    <td align="center">Old collector</td>
    <td align="center">JVM option</td>
  </tr>
  <tr>
    <td>Serial (DefNew)</td>
    <td>Serial Mark-Sweep-Compact</td>
    <td>-XX:+UseSerialGC</td>
  </tr>
  <tr>
    <td>Parallel scavenge (PSYoungGen)</td>
    <td>Serial Mark-Sweep-Compact (PSOldGen)</td>
    <td>-XX:+UseParallelGC</td>
  </tr>
  <tr>
    <td>Parallel scavenge (PSYoungGen)</td>
    <td>Parallel Mark-Sweep-Compact (ParOldGen)</td>
    <td>-XX:+UseParallelOldGC</td>
  </tr>
  <tr>
    <td>Serial (DefNew)</td>
    <td>Concurrent Mark Sweep</td>
    <td>
      <p>-XX:+UseConcMarkSweepGC</p>
      <p>-XX:-UseParNewGC</p>
    </td>
  </tr>
  <tr>
    <td>Parallel (ParNew)</td>
    <td>Concurrent Mark Sweep</td>
    <td>
      <p>-XX:+UseConcMarkSweepGC</p>
      <p>-XX:+UseParNewGC</p>
    </td>
  </tr>
  <tr>
    <td colspan="2">G1</td>
    <td>-XX:+UseG1GC</td>
  </tr>
</table>

결론:

  1. Apply -XX:+UseParallelGC when you require parallel collection method over YOUNG generation ONLY, (but still) use serial-mark-sweep method as OLD generation collection
  2. Apply -XX:+UseParallelOldGC when you require parallel collection method over YOUNG generation (automatically sets -XX:+UseParallelGC) AND OLD generation collection
  3. Apply -XX:+UseParNewGC & -XX:+UseConcMarkSweepGC when you require parallel collection method over YOUNG generation AND require CMS method as your collection over OLD generation memory
  4. You can't apply -XX:+UseParallelGC or -XX:+UseParallelOldGC with -XX:+UseConcMarkSweepGC simultaneously, that's why your require -XX:+UseParNewGC to be paired with CMS otherwise use -XX:+UseSerialGC explicitly OR -XX:-UseParNewGC if you wish to use serial method against young generation

UseParNewGC usually knowns as "parallel young generation collector" is same in all ways as the parallel garbage collector (-XX:+UseParallelGC), except that its more sophiscated and effiecient. Also it can be used with a "concurrent low pause collector".

See Java GC FAQ, question 22 for more information.

Note that there are some known bugs with UseParNewGC


Using -XX:+UseParNewGC along with -XX:+UseConcMarkSweepGC, will cause higher pause time for Minor GCs, when compared to -XX:+UseParallelGC.

This is because, promotion of objects from Young to Old Generation will require running a Best-Fit algorithm (due to old generation fragmentation) to find an address for this object.
Running such an algorithm is not required when using -XX:+UseParallelGC, as +UseParallelGC can be configured only with MarkandCompact Collector, in which case there is no fragmentation.

참고URL : https://stackoverflow.com/questions/2101518/difference-between-xxuseparallelgc-and-xxuseparnewgc

반응형