< prev index next >

src/share/vm/gc/g1/g1IHOPControl.hpp

Print this page
rev 9310 : dihop-changes
rev 9311 : imported patch sihop-thomas-review
rev 9312 : imported patch 8136678-implement-adaptive-sizing-algorithm-for-IHOP
rev 9314 : imported patch 8136679-jfr-event-for-dynamic-ihop
rev 9315 : imported patch sangheon-review


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1IHOPCONTROL_HPP
  26 #define SHARE_VM_GC_G1_G1IHOPCONTROL_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "utilities/numberSeq.hpp"
  30 
  31 class G1Predictions;

  32 
  33 // Manages the decision about the threshold when concurrent marking should start.
  34 class G1IHOPControl : public CHeapObj<mtGC> {
  35  protected:
  36   double _ihop_percent;
  37   size_t _target_occupancy;
  38 
  39   // Initialize an instance with the initial IHOP value in percent and the target
  40   // occupancy. The target occupancy is the number of bytes when marking should
  41   // be finished and reclaim started.
  42   G1IHOPControl(double initial_ihop_percent, size_t target_occupancy);
  43  public:
  44   virtual ~G1IHOPControl() { }
  45 
  46   // Get the current marking threshold in bytes.
  47   virtual size_t get_conc_mark_start_threshold() = 0;
  48 
  49   // Update information about recent time during which allocations happened,
  50   // how many allocations happened and an additional safety buffer.
  51   virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) = 0;
  52   // Update the time from the end of initial mark to the first mixed gc.
  53   virtual void update_time_to_mixed(double marking_length_s) = 0;
  54 
  55   virtual void print() = 0;

  56 };
  57 
  58 class G1StaticIHOPControl : public G1IHOPControl {
  59   double _last_allocation_time_s;
  60   size_t _last_allocated_bytes;
  61   double _last_marking_length_s;
  62  public:
  63   G1StaticIHOPControl(double ihop_percent, size_t target_occupancy);
  64 
  65   size_t get_conc_mark_start_threshold() { return (size_t) (_ihop_percent * _target_occupancy / 100.0); }
  66 
  67   virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
  68     assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s);
  69     _last_allocation_time_s = allocation_time_s;
  70     _last_allocated_bytes = allocated_bytes;
  71   }
  72 
  73   virtual void update_time_to_mixed(double marking_length_s) {
  74    assert(marking_length_s > 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
  75     _last_marking_length_s = marking_length_s;
  76   }
  77 
  78   virtual void print();

  79 #ifndef PRODUCT
  80   static void test();
  81 #endif
  82 };
  83 
  84 class G1AdaptiveIHOPControl : public G1IHOPControl {
  85   G1Predictions const * _predictor;
  86 
  87   TruncatedSeq _marking_times_s;
  88   TruncatedSeq _allocation_rate_s;
  89 
  90   size_t _last_allocation_bytes; // Most recent mutator allocation since last GC.
  91   size_t _prev_unrestrained_young_size;
  92 
  93   size_t _current_threshold;
  94 
  95   // Updates _current_threshold according to internal state.
  96   void recalculate();
  97 
  98   bool have_enough_data_for_prediction() const;
  99  public:
 100   G1AdaptiveIHOPControl(double ihop_percent, size_t initial_target_occupancy, G1Predictions const* predictor);
 101 
 102   virtual void set_target_occupancy(size_t target_occupancy);
 103 
 104   virtual size_t get_conc_mark_start_threshold();
 105 
 106   virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size);
 107   virtual void update_time_to_mixed(double marking_length_s);
 108 
 109   virtual void print();

 110 #ifndef PRODUCT
 111   static void test();
 112 #endif
 113 };
 114 
 115 #endif // SHARE_VM_GC_G1_G1IHOPCONTROL_HPP


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1IHOPCONTROL_HPP
  26 #define SHARE_VM_GC_G1_G1IHOPCONTROL_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "utilities/numberSeq.hpp"
  30 
  31 class G1Predictions;
  32 class G1NewTracer;
  33 
  34 // Manages the decision about the threshold when concurrent marking should start.
  35 class G1IHOPControl : public CHeapObj<mtGC> {
  36  protected:
  37   double _ihop_percent;
  38   size_t _target_occupancy;
  39 
  40   // Initialize an instance with the initial IHOP value in percent and the target
  41   // occupancy. The target occupancy is the number of bytes when marking should
  42   // be finished and reclaim started.
  43   G1IHOPControl(double initial_ihop_percent, size_t target_occupancy);
  44  public:
  45   virtual ~G1IHOPControl() { }
  46 
  47   // Get the current marking threshold in bytes.
  48   virtual size_t get_conc_mark_start_threshold() = 0;
  49 
  50   // Update information about recent time during which allocations happened,
  51   // how many allocations happened and an additional safety buffer.
  52   virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) = 0;
  53   // Update the time from the end of initial mark to the first mixed gc.
  54   virtual void update_time_to_mixed(double marking_length_s) = 0;
  55 
  56   virtual void print() = 0;
  57   virtual void send_event(G1NewTracer* tracer) = 0;
  58 };
  59 
  60 class G1StaticIHOPControl : public G1IHOPControl {
  61   double _last_allocation_time_s;
  62   size_t _last_allocated_bytes;
  63   double _last_marking_length_s;
  64  public:
  65   G1StaticIHOPControl(double ihop_percent, size_t target_occupancy);
  66 
  67   size_t get_conc_mark_start_threshold() { return (size_t) (_ihop_percent * _target_occupancy / 100.0); }
  68 
  69   virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
  70     assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s);
  71     _last_allocation_time_s = allocation_time_s;
  72     _last_allocated_bytes = allocated_bytes;
  73   }
  74 
  75   virtual void update_time_to_mixed(double marking_length_s) {
  76    assert(marking_length_s > 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
  77     _last_marking_length_s = marking_length_s;
  78   }
  79 
  80   virtual void print();
  81   virtual void send_event(G1NewTracer* tracer);
  82 #ifndef PRODUCT
  83   static void test();
  84 #endif
  85 };
  86 
  87 class G1AdaptiveIHOPControl : public G1IHOPControl {
  88   G1Predictions const * _predictor;
  89 
  90   TruncatedSeq _marking_times_s;
  91   TruncatedSeq _allocation_rate_s;
  92 
  93   size_t _last_allocation_bytes; // Most recent mutator allocation since last GC.
  94   size_t _prev_unrestrained_young_size;
  95 
  96   size_t _current_threshold;
  97 
  98   // Updates _current_threshold according to internal state.
  99   void recalculate();
 100 
 101   bool have_enough_data_for_prediction() const;
 102  public:
 103   G1AdaptiveIHOPControl(double ihop_percent, size_t initial_target_occupancy, G1Predictions const* predictor);
 104 
 105   virtual void set_target_occupancy(size_t target_occupancy);
 106 
 107   virtual size_t get_conc_mark_start_threshold();
 108 
 109   virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size);
 110   virtual void update_time_to_mixed(double marking_length_s);
 111 
 112   virtual void print();
 113   virtual void send_event(G1NewTracer* tracer);
 114 #ifndef PRODUCT
 115   static void test();
 116 #endif
 117 };
 118 
 119 #endif // SHARE_VM_GC_G1_G1IHOPCONTROL_HPP
< prev index next >