-XX:GCTimeRatio

The Parallel Collector

The parallel collector (also referred to here as the throughput collector) is a generational collector similar to the serial collector. 

parallel 收集器(这里也叫做吞吐量收集器),是一个类似serial收集器。

The primary difference between the serial and parallel collectors is that the parallel collector has multiple threads that are used to speed up garbage collection.

首先两者不同是parallel 收集器是 多线程,以更快的速度用于垃圾收集。

https://docs.oracle.com/en/java/javase/13/gctuning/parallel-collector1.html#GUID-DCDD6E46-0406-41D1-AB49-FB96A50EB9CE

 

其中有个参数是-XX:GCTimeRatio

Throughput: The throughput goal is measured in terms of the time spent doing garbage collection versus the time spent outside of garbage collection, referred to as application time.

吞吐量收集器的目标是垃圾收集花费的时间与垃圾收集之外花费的时间(即应用程序时间)来衡量的。

The goal is specified by the command-line option -XX:GCTimeRatio=<N>, which sets the ratio of garbage collection time to application time to 1 / (1 + <N>).

For example, -XX:GCTimeRatio=19 sets a goal of 1/20 or 5% of the total time in garbage collection. The default value is 99, resulting in a goal of 1% of the time in garbage collection.

假设-XX:GCTimeRatio=19 ,则垃圾收集时间为1/(1+19),默认值为99,即1%时间用于垃圾收集。

 

题外话:

在《深入理解java虚拟机》一书中也有提到这个参数,但文中 之前有一个概念,吞吐量=应用程序时间/(应用程序时间+垃圾收集时间);这个公式应该有点问题,不然在后面的描述中无法解释。后文中说到{GCTimeRatio参数的值是一个大于0且小于100的整数,也就是垃圾收集时间占总时间的比率,相当于是吞吐量的倒数。},如果这句话是对的,前面那个概念公式就有问题。

 

这里也有一篇有着同样的想法

https://blog.csdn.net/zmzmz_m/article/details/80536773

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章