< prev index next >

src/hotspot/share/gc/z/zDirector.cpp

Print this page




  58   const double time_since_last_gc = ZStatCycle::time_since_last();
  59   const double time_until_gc = ZCollectionInterval - time_since_last_gc;
  60 
  61   log_debug(gc, director)("Rule: Timer, Interval: %us, TimeUntilGC: %.3fs",
  62                           ZCollectionInterval, time_until_gc);
  63 
  64   return time_until_gc <= 0;
  65 }
  66 
  67 bool ZDirector::rule_warmup() const {
  68   if (ZStatCycle::is_warm()) {
  69     // Rule disabled
  70     return false;
  71   }
  72 
  73   // Perform GC if heap usage passes 10/20/30% and no other GC has been
  74   // performed yet. This allows us to get some early samples of the GC
  75   // duration, which is needed by the other rules.
  76   const size_t max_capacity = ZHeap::heap()->soft_max_capacity();
  77   const size_t used = ZHeap::heap()->used();
  78   const double used_threshold_percent = (ZStatCycle::ncycles() + 1) * 0.1;
  79   const size_t used_threshold = max_capacity * used_threshold_percent;
  80 
  81   log_debug(gc, director)("Rule: Warmup %.0f%%, Used: " SIZE_FORMAT "MB, UsedThreshold: " SIZE_FORMAT "MB",
  82                           used_threshold_percent * 100, used / M, used_threshold / M);
  83 
  84   return used >= used_threshold;
  85 }
  86 
  87 bool ZDirector::rule_allocation_rate() const {
  88   if (ZStatCycle::is_first()) {
  89     // Rule disabled
  90     return false;
  91   }
  92 
  93   // Perform GC if the estimated max allocation rate indicates that we
  94   // will run out of memory. The estimated max allocation rate is based
  95   // on the moving average of the sampled allocation rate plus a safety
  96   // margin based on variations in the allocation rate and unforeseen
  97   // allocation spikes.
  98 
  99   // Calculate amount of free memory available to Java threads. Note that
 100   // the heap reserve is not available to Java threads and is therefore not
 101   // considered part of the free memory.
 102   const size_t max_capacity = ZHeap::heap()->soft_max_capacity();
 103   const size_t max_reserve = ZHeap::heap()->max_reserve();
 104   const size_t used = ZHeap::heap()->used();
 105   const size_t free_with_reserve = max_capacity - MIN2(max_capacity, used);
 106   const size_t free = free_with_reserve - MIN2(free_with_reserve, max_reserve);
 107 
 108   // Calculate time until OOM given the max allocation rate and the amount




  58   const double time_since_last_gc = ZStatCycle::time_since_last();
  59   const double time_until_gc = ZCollectionInterval - time_since_last_gc;
  60 
  61   log_debug(gc, director)("Rule: Timer, Interval: %us, TimeUntilGC: %.3fs",
  62                           ZCollectionInterval, time_until_gc);
  63 
  64   return time_until_gc <= 0;
  65 }
  66 
  67 bool ZDirector::rule_warmup() const {
  68   if (ZStatCycle::is_warm()) {
  69     // Rule disabled
  70     return false;
  71   }
  72 
  73   // Perform GC if heap usage passes 10/20/30% and no other GC has been
  74   // performed yet. This allows us to get some early samples of the GC
  75   // duration, which is needed by the other rules.
  76   const size_t max_capacity = ZHeap::heap()->soft_max_capacity();
  77   const size_t used = ZHeap::heap()->used();
  78   const double used_threshold_percent = (ZStatCycle::nwarmup_cycles() + 1) * 0.1;
  79   const size_t used_threshold = max_capacity * used_threshold_percent;
  80 
  81   log_debug(gc, director)("Rule: Warmup %.0f%%, Used: " SIZE_FORMAT "MB, UsedThreshold: " SIZE_FORMAT "MB",
  82                           used_threshold_percent * 100, used / M, used_threshold / M);
  83 
  84   return used >= used_threshold;
  85 }
  86 
  87 bool ZDirector::rule_allocation_rate() const {
  88   if (!ZStatCycle::is_normalized_duration_trustable()) {
  89     // Rule disabled
  90     return false;
  91   }
  92 
  93   // Perform GC if the estimated max allocation rate indicates that we
  94   // will run out of memory. The estimated max allocation rate is based
  95   // on the moving average of the sampled allocation rate plus a safety
  96   // margin based on variations in the allocation rate and unforeseen
  97   // allocation spikes.
  98 
  99   // Calculate amount of free memory available to Java threads. Note that
 100   // the heap reserve is not available to Java threads and is therefore not
 101   // considered part of the free memory.
 102   const size_t max_capacity = ZHeap::heap()->soft_max_capacity();
 103   const size_t max_reserve = ZHeap::heap()->max_reserve();
 104   const size_t used = ZHeap::heap()->used();
 105   const size_t free_with_reserve = max_capacity - MIN2(max_capacity, used);
 106   const size_t free = free_with_reserve - MIN2(free_with_reserve, max_reserve);
 107 
 108   // Calculate time until OOM given the max allocation rate and the amount


< prev index next >