Skip to content

other param

ceragon edited this page Dec 16, 2021 · 1 revision

Jvm相关参数

G1 专用参数

MaxGCPauseMillis 和 GCPauseIntervalMillis

MaxGCPauseMillis 是每次STW的最大暂停时间,默认值是 200。GCPauseIntervalMillis是暂停的间隔时间,默认值是 201。

  • 这是两个值的原始定义
product(uintx, MaxGCPauseMillis, max_uintx - 1,                           \
          "Adaptive size policy maximum GC pause time goal in millisecond, "\
          "or (G1 Only) the maximum GC time per MMU time slice")            \
          range(1, max_uintx - 1)                                           \
          constraint(MaxGCPauseMillisConstraintFunc,AfterErgo)

 product(uintx, GCPauseIntervalMillis, 0,                                  \
          "Time slice for MMU specification")                               \
          constraint(GCPauseIntervalMillisConstraintFunc,AfterErgo)          
  • 部分G1的参数会在初始化时被修正
void G1Arguments::initialize() {
    if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
        FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
    }
    if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
        FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
    }
}

G1ConfidencePercent

预测的可信度,默认是50。举例来说,预计本次暂停时间100ms,由于可信度只有50%,所以会认定本次花费100 * 0.5 + 100 = 150ms。

定义

product(uintx, G1ConfidencePercent, 50,                                   \
          "Confidence level for MMU/pause predictions")                     \
          range(0, 100)  

用于计算预估的暂停时间

  1. 相关使用代码
G1Policy::G1Policy(STWGCTimer* gc_timer)(_predictor(G1ConfidencePercent / 100.0)
    // 在G1Policy构造的时候赋值给了 G1Predictions 类的对象 _predictor
}
class G1Predictions {
    G1Predictions(double sigma) : _sigma(sigma) {
        // 在构造函数中赋值给力 sigma 变量
    }
    
    // 修正预测结果
    double get_new_prediction(TruncatedSeq const* seq) const {
        // davg 是衰减平均值,_sigma 在此时是 0.5,stddev_estimate(seq) 可以理解为评估出来的一个值
        return seq->davg() + _sigma * stddev_estimate(seq);
    }
    // 此函数用于估计样本集的stddev。
    // 对于小样本集有一些特殊的考虑:它们的实际stddev不是很有用,因此我们根据样本平均值计算一些值。
    // 五个或更多的样本产生零(此时我们使用stddev);将样本集平均值从平均值的两倍线性扩展到0.5倍。
    double stddev_estimate(TruncatedSeq const* seq) const {
        double estimate = seq->dsd();
        int const samples = seq->num();
        if (samples < 5) {
            estimate = MAX2(seq->davg() * (5 - samples) / 2.0, estimate);
        }
        return estimate;
    }
};

Clone this wiki locally