-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

 

 

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