Skip to content

other param G1ConfidencePercent

ceragon edited this page Dec 16, 2021 · 1 revision

G1ConfidencePercent

预测的可信度,默认是50。

定义

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

用途

  1. 修正G1 GC的各种预测值
    1. 并发标记的启动阈值
  2. 参与评估年轻代是否应该伸缩

修正G1 GC的各种预测值

相关使用代码

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;
    }
};

修正并发标记的预估总时长

  1. 引用代码如下
size_t G1AdaptiveIHOPControl::get_conc_mark_start_threshold() {
   if (have_enough_data_for_prediction()) {
      double pred_marking_time = _predictor->get_new_prediction(&_marking_times_s);
      double pred_promotion_rate = _predictor->get_new_prediction(&_allocation_rate_s);
      size_t pred_promotion_size = (size_t)(pred_marking_time * pred_promotion_rate);

      size_t predicted_needed_bytes_during_marking =
      pred_promotion_size +
      // In reality we would need the maximum size of the young gen during
      // marking. This is a conservative estimate.
      _last_unrestrained_young_size;

      size_t internal_threshold = actual_target_threshold();
      size_t predicted_initiating_threshold = predicted_needed_bytes_during_marking < internal_threshold ?
                                            internal_threshold - predicted_needed_bytes_during_marking :
                                            0;
      return predicted_initiating_threshold;
   } else {
      // Use the initial value.
      return (size_t)(_initial_ihop_percent * _target_occupancy / 100.0);
   }
}

Clone this wiki locally