Throughput GC (Garbage collector) or Parallel collector in java


Contents of page >
  • Throughput GC (Garbage collector) or Parallel collector in java
  • 1. Features of Throughput GC (Garbage collector) in java  >
  • 2. Performance of Throughput GC (garbage Collector) host with different number of CPU’s in java >
  • 3. When to Use the Throughput GC (Garbage collector) in java >
  • 4.0. Vm (JVM) option for enabling throughput GC (Garbage collector) in java >
-XX:+UseParallelGC

  • 4.1. Vm (JVM) option for enabling throughput collector with n number of threads in java >
-XX:ParallelGCThreads=<numberOfThreads>
  • 4.2. Another Vm (JVM) option for enabling throughput collector in java >
-XX:+UseParallelOldGC
  • 5. Controlling maximum pause time and throughput for the application in java >
    • Vm (JVM) option for maximum pause time in java >
    • Vm (JVM) option for throughput in java >
  • 6. Goals for Throughput GC (Garbage collector) in java >
  • 7. Adjusting Generation Sizes in throughput GC (Garbage collector) >


Also read : xxx


Throughput GC (Garbage collector) or Parallel collector in java

1. Features of Throughput GC (Garbage collector) in java  >
  • Throughput collector is also called
    • Throughput GC (garbage collector)
    • ParallelGC (garbage collector)
    • Throughput collector
    • ParallelGC collector
  • Throughput garbage collector is the default garbage collector for JVM in java.
  • Throughput garbage collector uses multiple threads to execute a minor collection and so reduces the serial execution time of the application in java.
  • The throughput garbage collector is similar to the serial garbage collector but uses multiple threads to do the minor collection in java.
  • This garbage collector uses a parallel version of the young generation garbage collector in java.
  • The tenured generation collector is the same as the serial garbage collector in java.


2. Performance of Throughput GC (garbage Collector) host with different number of CPU’s in java >

By default on a host with N CPUs, the throughput collector uses N garbage collector threads in the minor collection. Note : We can control  number of garbage collector threads with a command line option in java.
On a host with 1 CPU the throughput collector will not perform as well as the serial collector because of the additional overhead for the parallel execution (Example - Synchronization costs) in java.
On a host with 2 CPUs the throughput collector generally performs as well as the serial garbage collector and a reduction in the minor garbage collector pause times can be expected on hosts with more than 2 CPUs in java.

3. When to Use the Throughput GC (Garbage collector) in java >
The Throughput collector should be used when application can afford low pauses in java.
And application is running on host with multiple CPU’s (to derive advantage of using multiple threads for garbage collection) in java.

4.0. Vm (JVM) option for enabling throughput GC (Garbage collector) in java >
-XX:+UseParallelGC

Example of using throughput collector in Command Line for starting jar>
java -Xms256m -Xms512m  -XX:+UseParallelGC -jar d:\MyJar.jar

4.1. Vm (JVM) option for enabling throughput collector with n number of threads in java >
-XX:ParallelGCThreads=<numberOfThreads>

With this Vm (JVM) option you get a
  • Multi-threaded young generation garbage collector in java,
  • single-threaded old generation garbage collector in java and
  • single-threaded compaction of old generation in java.

Example of using throughput collector with n number of threads in Command Line for starting jar>
java -Xms256m -Xms512m  -XX:+UseParallelGC -XX:ParallelGCThreads=5 -jar d:\MyJar.jar
Here, 5 will be the number of threads which will be used for garbage collection by Throughput Collector.

4.2. Another Vm (JVM) option for enabling throughput collector in java >
-XX:+UseParallelOldGC

Note : Young generation collector is a copy collector so there is no need for compaction there in java.

Example of using throughput collector in Command Line for starting jar>
java -Xms256m -Xms512m  -XX:+UseParallelOldGC -jar d:\MyJar.jar



5. Controlling maximum pause time and throughput for the application in java >

In the J2SE 5 the throughput collector is the garbage collector on server class machines.
For the throughput collector a new method of tuning has been added which is based on a desired behavior of the application with respect to garbage collection.

The following command line flags can be used to specify the behavior of garbage collection in terms of -
  • maximum pause time and
  • throughput for the application.

Vm (JVM) option for maximum pause time in java >
-XX:MaxGCPauseMillis=<miliSec>
We gives hint to throughput collector that pause time should be <miliSec> milliseconds or less.

Example of using -XX:MaxGCPauseMillis=<miliSec> in java :
-XX:MaxGCPauseMillis=100
We gives hint to throughput collector that pause time should be 100 milliseconds or less.

The throughput collector will adjust the Java heap size and other garbage collection related parameters in an attempt to keep garbage collection pauses shorter than <miliSec> milliseconds.

By default there is no maximum pause time goal.
Vm (JVM) option for throughput in java >
-XX:GCTimeRatio=<miliSec>
The throughput is measured time spent doing garbage collection and time spent outside of garbage collection .

Example of using -XX:GCTimeRatio=<miliSec> in java :
XX:GCTimeRatio=19 sets a goal of 5% of the total time for garbage collection.
By default the goal for total time for garbage collection is 1%.

The ratio of garbage collection time to application time is 1 / (1 + <miliSec>)


6. Goals for Throughput GC (Garbage collector) in java >
  • Maximum pause time goal (Highest priority)
  • Throughput goal
  • Minimum footprint goal (Lowest priority)

7. Adjusting Generation Sizes in throughput GC (Garbage collector) >

By default a generation
  • grows in increments of 20% and
  • shrinks in increments of 5%.
Controlling growth of generation (in percent) >
  • -XX:YoungGenerationSizeIncrement=<growthPercent > for the young generation and
  • -XX:TenuredGenerationSizeIncrement=<growthPercent> for the tenured generation.
shrink of generation (in percent) >
  • -XX: AdaptiveSizeDecrementScaleFactor=<shrinkPercent >

If the size of an increment for growing is growthPercent, the size of the decrement for shrinking will be growthPercent/ shrinkPercent.






Summary -

I am highlighting all the summary portion to keep it separate from whole tutorial. Please refer above for complete detail.

1. Features of Throughput GC (Garbage collector) in java  >
  • Throughput garbage collector is the default garbage collector for JVM in java.
  • Throughput garbage collector uses multiple threads to execute a minor collection.

2. Performance of Throughput GC (garbage Collector) host with different number of CPU’s in java >

By default on a host with N CPUs, the throughput collector uses N garbage collector threads in the minor collection. Note : We can control  number of garbage collector threads with a command line option in core java.

3. When to Use the Throughput GC (Garbage collector) in java >
The Throughput collector should be used when application can afford low pauses in java.

4.0. Vm (JVM) option for enabling throughput GC (Garbage collector) in java >
-XX:+UseParallelGC

Example of using throughput collector in Command Line for starting jar>
java -Xms256m -Xms512m  -XX:+UseParallelGC -jar d:\MyJar.jar


5. Controlling maximum pause time and throughput for the application in java >
Vm (JVM) option for maximum pause time in java >
-XX:MaxGCPauseMillis=<miliSec>
We gives hint to throughput collector that pause time should be <miliSec> milliseconds or less.
Vm (JVM) option for throughput in java >
-XX:GCTimeRatio=<miliSec>
The throughput is measured time spent doing garbage collection and time spent outside of garbage collection .

6. Goals for Throughput GC (Garbage collector) in java >
  • Maximum pause time goal (Highest priority)
  • Throughput goal
  • Minimum footprint goal (Lowest priority)

7. Adjusting Generation Sizes in throughput GC (Garbage collector) >

Controlling growth of generation (in percent) >
  • -XX:YoungGenerationSizeIncrement=<growthPercent > for the young generation and
  • -XX:TenuredGenerationSizeIncrement=<growthPercent> for the tenured generation.
shrink of generation (in percent) >
  • -XX: AdaptiveSizeDecrementScaleFactor=<shrinkPercent >




Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.


RELATED LINKS>


No comments:

Post a Comment