inline void CMSStats::record_gc0_end(size_t cms_gen_bytes_used) {
  double last_gc0_duration = _gc0_begin_time.seconds();
  _gc0_duration = exp_avg(_gc0_duration, last_gc0_duration, _gc0_alpha);

  // Amount promoted.
  _cms_used_at_gc0_end = cms_gen_bytes_used;
  size_t promoted_bytes = _cms_used_at_gc0_end - _cms_used_at_gc0_begin;
  _gc0_promoted = exp_avg(_gc0_promoted, promoted_bytes, _gc0_alpha);

  // Amount directly allocated.
  size_t allocated_bytes = _cms_gen->direct_allocated_words() * HeapWordSize;
  _cms_gen->reset_direct_allocated_words();
  _cms_allocated = exp_avg(_cms_allocated, allocated_bytes, _gc0_alpha);
}
inline void CMSStats::record_cms_end() {
  _cms_timer.stop();

  double cur_duration = _cms_timer.seconds();
  _cms_duration = exp_avg(_cms_duration, cur_duration, _cms_alpha);

  // Avoid division by 0.
  const size_t cms_used_mb = MAX2(_cms_used_at_cms_begin / M, (size_t)1);
  _cms_duration_per_mb = exp_avg(_cms_duration_per_mb,
				 cur_duration / cms_used_mb,
				 _cms_alpha);

  _cms_end_time.update();
  _cms_alpha = _saved_alpha;
  _allow_duty_cycle_reduction = true;
  _valid_bits |= _CMS_VALID;

  _cms_timer.start();
}
inline void CMSStats::record_gc0_begin() {
  if (_gc0_begin_time.is_updated()) {
    double last_gc0_period = _gc0_begin_time.seconds();
    _gc0_period = exp_avg(_gc0_period, last_gc0_period, _gc0_alpha);
    _gc0_alpha = _saved_alpha;
    _valid_bits |= _GC0_VALID;
  }
  _cms_used_at_gc0_begin = _cms_gen->cmsSpace()->used();

  _gc0_begin_time.update();
}
inline void CMSStats::record_cms_begin() {
  _cms_timer.stop();

  // This is just an approximate value, but is good enough.
  _cms_used_at_cms_begin = _cms_used_at_gc0_end;

  _cms_period = exp_avg(_cms_period, _cms_timer.seconds(), _cms_alpha);
  _cms_begin_time.update();

  _cms_timer.reset();
  _cms_timer.start();
}
Beispiel #5
0
float AdaptiveWeightedAverage::compute_adaptive_average(float new_sample,
        float average) {
    // We smooth the samples by not using weight() directly until we've
    // had enough data to make it meaningful. We'd like the first weight
    // used to be 1, the second to be 1/2, etc until we have 100/weight
    // samples.
    unsigned count_weight = 100/count();
    unsigned adaptive_weight = (MAX2(weight(), count_weight));

    float new_avg = exp_avg(average, new_sample, adaptive_weight);

    return new_avg;
}
 static inline size_t exp_avg(size_t avg, size_t sample,
                              unsigned int weight) {
   // Convert to float and back to avoid integer overflow.
   return (size_t)exp_avg((float)avg, (float)sample, weight);
 }
inline size_t
CMSStats::exp_avg(size_t old_avg, size_t cur_val, unsigned int alpha) {
  // Convert to double and back to avoid integer overflow.
  return (size_t)exp_avg((double)old_avg, (double)cur_val, alpha);
}