< prev index next >

src/hotspot/share/gc/g1/g1MonitoringSupport.hpp

Print this page

        

@@ -44,24 +44,27 @@
 //
 // * eden      : regions that have been allocated since the last GC
 // * survivors : regions with objects that survived the last few GCs
 // * old       : long-lived non-humongous regions
 // * humongous : humongous regions
+// * archive   : archive regions
 // * free      : free regions
 //
 // The combination of eden and survivor regions form the equivalent of
-// the young generation in the other GCs. The combination of old and
-// humongous regions form the equivalent of the old generation in the
-// other GCs. Free regions do not have a good equivalent in the other
-// GCs given that they can be allocated as any of the other region types.
-//
-// The monitoring tools expect the heap to contain a number of
-// generations (young, old, perm) and each generation to contain a
-// number of spaces (young: eden, survivors, old). Given that G1 does
-// not maintain those spaces physically (e.g., the set of
-// non-contiguous eden regions can be considered as a "logical"
-// space), we'll provide the illusion that those generations and
+// the young generation in the other GCs. The combination of old,
+// humongous, and archive regions form the equivalent of the old
+// generation in the other GCs. Archive regions are permanently
+// allocated during heap initialization, e.g., for CDS. Free regions
+// do not have a good equivalent in the other GCs, given that they can
+// be allocated as any of the other region types.
+//
+// The monitoring tools expect the heap to contain one or more
+// generations (young, old) and each generation to contain one or
+// more spaces (young has eden and survivor, old has old, humongous and
+// archive). Given that G1 does not maintain those spaces physically
+// (e.g., the set of non-contiguous eden regions can be considered as
+// a "logical" space), we provide the illusion that those generations and
 // spaces exist. In reality, each generation and space refers to a set
 // of heap regions that are potentially non-contiguous.
 //
 // This class provides interfaces to access the min, current, and max
 // capacity and current occupancy for each of G1's logical spaces and

@@ -76,25 +79,33 @@
 //    - heap_capacity = current heap capacity (e.g., current committed size)
 //    - young_gen_capacity = current max young gen target capacity
 //          (i.e., young gen target capacity + max allowed expansion capacity)
 //    - survivor_capacity = current survivor region capacity
 //    - eden_capacity = young_gen_capacity - survivor_capacity
+//  In legacy mode:
 //    - old_capacity = heap_capacity - young_gen_capacity
+//  Otherwise:
+//    - humongous_capacity = sum of humongous regions allocated
+//    - archive_capacity = sum of archive regions allocated
+//    - old_capacity = heap_capacity - young_gen_capacity -
+//                     humongous_capacity - archive_capacity
 //
 //    What we do in the above is to distribute the free regions among
 //    eden_capacity and old_capacity.
 //
 // * Occupancy
 //
-//    - young_gen_used = current young region capacity
+//    - young_gen_committed = current young region capacity
 //    - survivor_used = survivor_capacity
 //    - eden_used = young_gen_used - survivor_used
+//  In legacy mode:
 //    - old_used = overall_used - young_gen_used
-//
-//    Unfortunately, we currently only keep track of the number of
-//    currently allocated young and survivor regions + the overall used
-//    bytes in the heap, so the above can be a little inaccurate.
+//  Otherwise:
+//    - humongous_used = sum of humongous regions allocated
+//    - archive_used = sum of archive regions allocated
+//    - old_used = overall_used - young_gen_used -
+//                 humongous_used - archive_used
 //
 // * Min Capacity
 //
 //    We set this to 0 for all spaces.
 //

@@ -102,38 +113,46 @@
 //
 //    For jstat, we set the max capacity of all spaces to heap_capacity,
 //    given that we don't always have a reasonable upper bound on how big
 //    each space can grow. For the memory pools, we make the max
 //    capacity undefined with the exception of the old memory pool for
-//    which we make the max capacity same as the max heap capacity.
-//
-// If we had more accurate occupancy / capacity information per
-// region set the above calculations would be greatly simplified and
-// be made more accurate.
+//    which we make the max capacity same as the max heap capacity. This
+//    allows users to sum memory pool max capacities to get something
+//    reasonable.
 //
 // We update all the above synchronously and we store the results in
-// fields so that we just read said fields when needed. A subtle point
-// is that all the above sizes need to be recalculated when the old
+// this singleton class so we can just read them out when needed. A subtle
+// point is that all the above sizes must be recalculated when the old
 // gen changes capacity (after a GC or after a humongous allocation)
 // but only the eden occupancy changes when a new eden region is
 // allocated. So, in the latter case we have minimal recalculation to
-// do which is important as we want to keep the eden region allocation
-// path as low-overhead as possible.
+// do, but we don't both special-casing it because doing the full
+// recalculation is quite fast.
 
 class G1MonitoringSupport : public CHeapObj<mtGC> {
   friend class VMStructs;
   friend class G1MonitoringScope;
 
   G1CollectedHeap* _g1h;
 
   // java.lang.management MemoryManager and MemoryPool support
+
+  bool _use_legacy_monitoring; // For vmStructs and hsdb
+
+  GCMemoryManager _full_memory_manager;
+  // Legacy monitoring
   GCMemoryManager _incremental_memory_manager;
-  GCMemoryManager _full_gc_memory_manager;
+  // Default monitoring
+  GCMemoryManager _young_memory_manager;
+  GCMemoryManager _mixed_memory_manager;
+  GCMemoryManager _conc_memory_manager;
 
   MemoryPool* _eden_space_pool;
   MemoryPool* _survivor_space_pool;
-  MemoryPool* _old_gen_pool;
+  MemoryPool* _old_space_pool;
+  MemoryPool* _archive_space_pool;
+  MemoryPool* _humongous_space_pool;
 
   // jstat performance counters
   //  incremental collections both young and mixed
   CollectorCounters*   _incremental_collection_counters;
   //  full stop-the-world collections

@@ -163,18 +182,23 @@
 
   size_t _overall_committed;
   size_t _overall_used;
 
   size_t _young_gen_committed;
-  size_t _old_gen_committed;
 
   size_t _eden_space_committed;
   size_t _eden_space_used;
   size_t _survivor_space_committed;
   size_t _survivor_space_used;
 
-  size_t _old_gen_used;
+  size_t _old_space_committed;
+  size_t _old_space_used;
+  size_t _archive_space_committed;
+  size_t _archive_space_used;
+
+  size_t _humongous_space_committed;
+  size_t _humongous_space_used;
 
   // It returns x - y if x > y, 0 otherwise.
   // As described in the comment above, some of the inputs to the
   // calculations we have to do are obtained concurrently and hence
   // may be inconsistent with each other. So, this provides a

@@ -187,25 +211,25 @@
     } else {
       return 0;
     }
   }
 
-  // Recalculate all the sizes.
+  // Recalculate all the space sizes.
   void recalculate_sizes();
 
-  void recalculate_eden_size();
-
 public:
   G1MonitoringSupport(G1CollectedHeap* g1h);
   ~G1MonitoringSupport();
 
   void initialize_serviceability();
 
-  MemoryUsage memory_usage();
   GrowableArray<GCMemoryManager*> memory_managers();
   GrowableArray<MemoryPool*> memory_pools();
 
+  bool use_legacy_monitoring() { return _use_legacy_monitoring; }
+  GCMemoryManager* conc_memory_manager() { return &_conc_memory_manager; }
+
   // Unfortunately, the jstat tool assumes that no space has 0
   // capacity. In our case, given that each space is logical, it's
   // possible that no regions will be allocated to it, hence to have 0
   // capacity (e.g., if there are no survivor regions, the survivor
   // space has 0 capacity). The way we deal with this is to always pad

@@ -217,14 +241,15 @@
   // padding multiple times so that the capacities add up correctly.
   static size_t pad_capacity(size_t size_bytes, size_t mult = 1) {
     return size_bytes + MinObjAlignmentInBytes * mult;
   }
 
-  // Recalculate all the sizes from scratch and update all the jstat
-  // counters accordingly.
+  // Recalculate all the space sizes from scratch and update
+  // all jstat counters accordingly.
   void update_sizes();
-
+  // Recalculate all the space sizes from scratch, but update
+  // just the eden size and jstat counters.
   void update_eden_size();
 
   CollectorCounters* conc_collection_counters() {
     return _conc_collection_counters;
   }

@@ -238,25 +263,45 @@
   size_t young_gen_committed()        { return _young_gen_committed; }
 
   size_t eden_space_used()            { return _eden_space_used; }
   size_t survivor_space_used()        { return _survivor_space_used; }
 
-  size_t old_gen_committed()          { return _old_gen_committed; }
-  size_t old_gen_used()               { return _old_gen_used; }
+  size_t old_gen_committed();
+  size_t old_gen_used();
+
+  size_t old_space_committed()  { return _old_space_committed; }
+  size_t old_space_used()       { return _old_space_used; }
+  size_t archive_space_used()   { return _archive_space_used; }
+
+  size_t humongous_space_used() { return _humongous_space_used; }
 
   // Monitoring support for MemoryPools. Values in the returned MemoryUsage are
   // guaranteed to be consistent with each other.
+  MemoryUsage memory_usage();
   MemoryUsage eden_space_memory_usage(size_t initial_size, size_t max_size);
   MemoryUsage survivor_space_memory_usage(size_t initial_size, size_t max_size);
+  MemoryUsage old_space_memory_usage(size_t initial_size, size_t max_size);
+  MemoryUsage archive_space_memory_usage(size_t initial_size, size_t max_size);
+  MemoryUsage humongous_space_memory_usage(size_t initial_size, size_t max_size);
+};
 
-  MemoryUsage old_gen_memory_usage(size_t initial_size, size_t max_size);
+// TraceMemoryManagerStats for concurrent cycle.
+class TraceConcMemoryManagerStats : public TraceMemoryManagerStats {
+ public:
+  enum Stage {
+    CycleStart,
+    Remark,
+    Cleanup,
+    CycleEnd
+  };
+  TraceConcMemoryManagerStats(Stage stage, GCCause::Cause cause);
 };
 
 // Scope object for java.lang.management support.
 class G1MonitoringScope : public StackObj {
   TraceCollectorStats _tcs;
   TraceMemoryManagerStats _tms;
 public:
-  G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool all_memory_pools_affected);
+  G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool mixed_gc);
 };
 
 #endif // SHARE_VM_GC_G1_G1MONITORINGSUPPORT_HPP
< prev index next >