< prev index next >

src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp

Print this page
@@ -23,11 +23,10 @@
   */
  
  #ifndef SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHHEURISTICS_HPP
  #define SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHHEURISTICS_HPP
  
- #include "gc/shenandoah/shenandoahHeap.hpp"
  #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  #include "gc/shenandoah/shenandoahSharedVariables.hpp"
  #include "memory/allocation.hpp"
  #include "runtime/globals_extension.hpp"
  

@@ -55,10 +54,12 @@
      }                                                                       \
    } while (0)
  
  class ShenandoahCollectionSet;
  class ShenandoahHeapRegion;
+ class ShenandoahGeneration;
+ class ShenandoahOldHeuristics;
  
  class ShenandoahHeuristics : public CHeapObj<mtGC> {
    static const intx Concurrent_Adjust   = -1; // recover from penalties
    static const intx Degenerated_Penalty = 10; // how much to penalize average GC duration history on Degenerated GC
    static const intx Full_Penalty        = 20; // how much to penalize average GC duration history on Full GC

@@ -67,15 +68,32 @@
    typedef struct {
      ShenandoahHeapRegion* _region;
      size_t _garbage;
    } RegionData;
  
+   ShenandoahGeneration* _generation;
+ 
+   // if (_generation->generation_mode() == GLOBAL) _region_data represents
+   //  the results of most recently completed global marking pass
+   // if (_generation->generation_mode() == OLD) _region_data represents
+   //  the results of most recently completed old-gen marking pass
+   // if (_generation->generation_mode() == YOUNG) _region_data represents
+   //  the resulits of most recently completed young-gen marking pass
+   //
+   // Note that there is some redundancy represented in _region_data because
+   // each instance is an array large enough to hold all regions.  However,
+   // any region in young-gen is not in old-gen.  And any time we are
+   // making use of the GLOBAL data, there is no need to maintain the
+   // YOUNG or OLD data.  Consider this redundancy of data structure to
+   // have negligible cost unless proven otherwise.
    RegionData* _region_data;
  
    uint _degenerated_cycles_in_a_row;
    uint _successful_cycles_in_a_row;
  
+   size_t _guaranteed_gc_interval;
+ 
    double _cycle_start;
    double _last_cycle_end;
  
    size_t _gc_times_learned;
    intx _gc_time_penalties;

@@ -84,24 +102,34 @@
    // There may be many threads that contend to set this flag
    ShenandoahSharedFlag _metaspace_oom;
  
    static int compare_by_garbage(RegionData a, RegionData b);
  
+   // TODO: We need to enhance this API to give visibility to accompanying old-gen evacuation effort.
+   // In the case that the old-gen evacuation effort is small or zero, the young-gen heuristics
+   // should feel free to dedicate increased efforts to young-gen evacuation.
+ 
    virtual void choose_collection_set_from_regiondata(ShenandoahCollectionSet* set,
                                                       RegionData* data, size_t data_size,
                                                       size_t free) = 0;
  
    void adjust_penalty(intx step);
  
+   bool in_generation(ShenandoahHeapRegion* region);
+ 
  public:
-   ShenandoahHeuristics();
+   ShenandoahHeuristics(ShenandoahGeneration* generation);
    virtual ~ShenandoahHeuristics();
  
    void record_metaspace_oom()     { _metaspace_oom.set(); }
    void clear_metaspace_oom()      { _metaspace_oom.unset(); }
    bool has_metaspace_oom() const  { return _metaspace_oom.is_set(); }
  
+   void set_guaranteed_gc_interval(size_t guaranteed_gc_interval) {
+     _guaranteed_gc_interval = guaranteed_gc_interval;
+   }
+ 
    virtual void record_cycle_start();
  
    virtual void record_cycle_end();
  
    virtual bool should_start_gc();

@@ -116,11 +144,12 @@
  
    virtual void record_allocation_failure_gc();
  
    virtual void record_requested_gc();
  
-   virtual void choose_collection_set(ShenandoahCollectionSet* collection_set);
+   // Return true iff the chosen collection set includes at least one old-gen region.
+   virtual bool choose_collection_set(ShenandoahCollectionSet* collection_set, ShenandoahOldHeuristics* old_heuristics);
  
    virtual bool can_unload_classes();
    virtual bool can_unload_classes_normal();
    virtual bool should_unload_classes();
  
< prev index next >