Print this page
JDK-8236073 G1: Use SoftMaxHeapSize to guide GC heuristics

Split Close
Expand all
Collapse all
          --- old/src/hotspot/share/gc/g1/g1CollectedHeap.hpp
          +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.hpp
↓ open down ↓ 68 lines elided ↑ open up ↑
  69   69  class G1ParScanThreadStateSet;
  70   70  class G1ParScanThreadState;
  71   71  class MemoryPool;
  72   72  class MemoryManager;
  73   73  class ObjectClosure;
  74   74  class SpaceClosure;
  75   75  class CompactibleSpaceClosure;
  76   76  class Space;
  77   77  class G1CardTableEntryClosure;
  78   78  class G1CollectionSet;
       79 +class G1HeapSizingPolicy;
  79   80  class G1Policy;
  80   81  class G1HotCardCache;
  81   82  class G1RemSet;
  82   83  class G1YoungRemSetSamplingThread;
  83   84  class G1ConcurrentMark;
  84   85  class G1ConcurrentMarkThread;
  85   86  class G1ConcurrentRefine;
  86   87  class GenerationCounters;
  87   88  class STWGCTimer;
  88   89  class G1NewTracer;
↓ open down ↓ 469 lines elided ↑ open up ↑
 558  559  
 559  560    G1HeapVerifier* verifier() {
 560  561      return _verifier;
 561  562    }
 562  563  
 563  564    G1MonitoringSupport* g1mm() {
 564  565      assert(_g1mm != NULL, "should have been initialized");
 565  566      return _g1mm;
 566  567    }
 567  568  
 568      -  void resize_heap_if_necessary();
      569 +  void resize_heap_after_full_gc();
 569  570  
 570  571    G1NUMA* numa() const { return _numa; }
 571  572  
 572  573    // Expand the garbage-first heap by at least the given size (in bytes!).
 573  574    // Returns true if the heap was expanded by the requested amount;
 574  575    // false otherwise.
 575  576    // (Rounds up to a HeapRegion boundary.)
 576  577    bool expand(size_t expand_bytes, WorkGang* pretouch_workers = NULL, double* expand_time_ms = NULL);
 577  578    bool expand_single_region(uint node_index);
 578  579  
↓ open down ↓ 189 lines elided ↑ open up ↑
 768  769  
 769  770    void calculate_collection_set(G1EvacuationInfo& evacuation_info, double target_pause_time_ms);
 770  771  
 771  772    // Actually do the work of evacuating the parts of the collection set.
 772  773    void evacuate_initial_collection_set(G1ParScanThreadStateSet* per_thread_states);
 773  774    void evacuate_optional_collection_set(G1ParScanThreadStateSet* per_thread_states);
 774  775  private:
 775  776    // Evacuate the next set of optional regions.
 776  777    void evacuate_next_optional_regions(G1ParScanThreadStateSet* per_thread_states);
 777  778  
      779 +  bool expand_heap_after_young_collection();
      780 +  void shrink_heap_after_young_collection();
      781 +
 778  782  public:
 779  783    void pre_evacuate_collection_set(G1EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* pss);
 780  784    void post_evacuate_collection_set(G1EvacuationInfo& evacuation_info,
 781  785                                      G1RedirtyCardsQueueSet* rdcqs,
 782  786                                      G1ParScanThreadStateSet* pss);
 783  787  
 784      -  void expand_heap_after_young_collection();
      788 +  void resize_heap_after_young_collection();
      789 +  void shrink_heap_after_concurrent_mark();
      790 +
 785  791    // Update object copying statistics.
 786  792    void record_obj_copy_mem_stats();
 787  793  
 788  794    // The hot card cache for remembered set insertion optimization.
 789  795    G1HotCardCache* _hot_card_cache;
 790  796  
 791  797    // The g1 remembered set of the heap.
 792  798    G1RemSet* _rem_set;
 793  799  
 794  800    // After a collection pause, convert the regions in the collection set into free
↓ open down ↓ 181 lines elided ↑ open up ↑
 976  982      return CollectedHeap::G1;
 977  983    }
 978  984  
 979  985    virtual const char* name() const {
 980  986      return "G1";
 981  987    }
 982  988  
 983  989    const G1CollectorState* collector_state() const { return &_collector_state; }
 984  990    G1CollectorState* collector_state() { return &_collector_state; }
 985  991  
      992 +  G1HeapSizingPolicy* heap_sizing_policy() const { return _heap_sizing_policy; }
 986  993    // The current policy object for the collector.
 987  994    G1Policy* policy() const { return _policy; }
 988  995    // The remembered set.
 989  996    G1RemSet* rem_set() const { return _rem_set; }
 990  997  
 991  998    inline G1GCPhaseTimes* phase_times() const;
 992  999  
 993 1000    HeapRegionManager* hrm() const { return _hrm; }
 994 1001  
 995 1002    const G1CollectionSet* collection_set() const { return &_collection_set; }
↓ open down ↓ 75 lines elided ↑ open up ↑
1071 1078    bool is_on_master_free_list(HeapRegion* hr) {
1072 1079      return _hrm->is_free(hr);
1073 1080    }
1074 1081  #endif // ASSERT
1075 1082  
1076 1083    inline void old_set_add(HeapRegion* hr);
1077 1084    inline void old_set_remove(HeapRegion* hr);
1078 1085  
1079 1086    inline void archive_set_add(HeapRegion* hr);
1080 1087  
1081      -  size_t non_young_capacity_bytes() {
     1088 +  size_t non_young_capacity_bytes() const {
1082 1089      return (old_regions_count() + _archive_set.length() + humongous_regions_count()) * HeapRegion::GrainBytes;
1083 1090    }
1084 1091  
1085 1092    // Determine whether the given region is one that we are using as an
1086 1093    // old GC alloc region.
1087 1094    bool is_old_gc_alloc_region(HeapRegion* hr);
1088 1095  
1089 1096    // Perform a collection of the heap; intended for use in implementing
1090 1097    // "System.gc".  This probably implies as full a collection as the
1091 1098    // "CollectedHeap" supports.
↓ open down ↓ 180 lines elided ↑ open up ↑
1272 1279  
1273 1280    // Returns the number of regions the humongous object of the given word size
1274 1281    // requires.
1275 1282    static size_t humongous_obj_size_in_regions(size_t word_size);
1276 1283  
1277 1284    // Print the maximum heap capacity.
1278 1285    virtual size_t max_capacity() const;
1279 1286  
1280 1287    // Return the size of reserved memory. Returns different value than max_capacity() when AllocateOldGenAt is used.
1281 1288    virtual size_t max_reserved_capacity() const;
     1289 +
     1290 +  // Print the soft maximum heap capacity.
     1291 +  size_t soft_max_capacity() const;
1282 1292  
1283 1293    virtual jlong millis_since_last_gc();
1284 1294  
1285 1295  
1286 1296    // Convenience function to be used in situations where the heap type can be
1287 1297    // asserted to be this type.
1288 1298    static G1CollectedHeap* heap();
1289 1299  
1290 1300    void set_region_short_lived_locked(HeapRegion* hr);
1291 1301    // add appropriate methods for any other surv rate groups
↓ open down ↓ 213 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX