Java - Java Platform, SE HotSpot VM GC Tuning Guide - 5 Available Collectors
2018-01-18 09:44
573 查看
5 Available Collectors
The discussion to this point has been about the serial collector. The Java HotSpot VM includes three different types of collectors, each with different performance characteristics.The serial collector uses a single thread to perform all garbage collection work, which makes it relatively efficient because there is no communication overhead between threads. It is best-suited to single processor
machines, because it cannot take advantage of multiprocessor hardware, although it can be useful on multiprocessors for applications with small data sets (up to approximately 100 MB). The serial collector is selected by default on certain hardware and operating
system configurations, or can be explicitly enabled with the option
-XX:+UseSerialGC.
The parallel collector (also known as the throughput collector) performs minor collections in parallel, which can significantly reduce garbage collection overhead. It is intended for applications with
medium-sized to large-sized data sets that are run on multiprocessor or multithreaded hardware. The parallel collector is selected by default on certain hardware and operating system configurations, or can be explicitly enabled with the option
-XX:+UseParallelGC.
Parallel compaction is a feature that enables the parallel collector to perform major collections in parallel. Without parallel compaction, major collections are performed using a single thread, which can significantly
limit scalability. Parallel compaction is enabled by default if the option
-XX:+UseParallelGChas been specified. The option to turn it off is
-XX:-UseParallelOldGC.
The mostly concurrent collector performs most of its work concurrently (for example, while the application is still running) to keep garbage collection pauses short. It is designed for applications with medium-sized
to large-sized data sets in which response time is more important than overall throughput because the techniques used to minimize pauses can reduce application performance. The Java HotSpot VM offers a choice between two mostly concurrent collectors; see The
Mostly Concurrent Collectors. Use the option
-XX:+UseConcMarkSweepGCto enable the CMS collector or
-XX:+UseG1GCto enable the G1 collector.
Selecting a Collector
Unless your application has rather strict pause time requirements, first run your application and allow the VM to select a collector. If necessary, adjust the heap size to improve performance. If the performancestill does not meet your goals, then use the following guidelines as a starting point for selecting a collector.
If the application has a small data set (up to approximately 100 MB), then
select the serial collector with the option
-XX:+UseSerialGC.
If the application will be run on a single processor and there are no pause time requirements, then let the VM select the collector, or select the serial collector with the option
-XX:+UseSerialGC.
If (a) peak application performance is the first priority and (b) there are no pause time requirements or pauses of 1 second or longer are acceptable, then let the VM select the collector, or select the parallel
collector with
-XX:+UseParallelGC.
If response time is more important than overall throughput and garbage collection pauses must be kept shorter than approximately 1 second, then select the concurrent collector with
-XX:+UseConcMarkSweepGCor
-XX:+UseG1GC.
These guidelines provide only a starting point for selecting a collector because performance is dependent on the size of the heap, the amount of live data maintained by the application, and the number and speed
of available processors. Pause times are particularly sensitive to these factors, so the threshold of 1 second mentioned previously is only approximate: the parallel collector will experience pause times longer than 1 second on many data size and hardware
combinations; conversely, the concurrent collector may not be able to keep pauses shorter than 1 second on some combinations.
If the recommended collector does not achieve the desired performance, first attempt to adjust the heap and generation sizes to meet the desired goals. If performance is still inadequate, then try a different
collector: use the concurrent collector to reduce pause times and use the parallel collector to increase overall throughput on multiprocessor hardware.
相关文章推荐
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - Preface
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 9 Garbage-First Garbage Collector
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 1 Introduction
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 10 Garbage-First Garbage Collector Tuning
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 11 Other Considerations
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 4 Sizing the Generations
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 6 The Parallel Collector
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 2 Ergonomics
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 7 The Mostly Concurrent Collectors
- Java - Java Platform, SE HotSpot VM GC Tuning Guide
- Java - Java Platform, SE HotSpot VM GC Tuning Guide - 8 Concurrent Mark Sweep (CMS) Collector
- Java - Java Platform, SE HotSpot VM Garbage Collection - 3 Generations
- Java 8 VM GC Tuning Guide Charter3-4
- Java HotSpot Client VM 和 Java HotSpot Server VM的配置
- HotSpot VM GC收集器的易混淆的名称问题
- HotSpotVM的Java堆实现浅析#1:初始化
- JVM——Java HotSpot VM Options
- Java HotSpot VM Options
- Java GC, HotSpot's CMS promotion buffers
- Ref : Troubleshooting Guide for HotSpot VM