105 // 106 // We update all the above synchronously and we store the results in 107 // fields so that we just read said fields when needed. A subtle point 108 // is that all the above sizes need to be recalculated when the old 109 // gen changes capacity (after a GC or after a humongous allocation) 110 // but only the eden occupancy changes when a new eden region is 111 // allocated. So, in the latter case we have minimal recalculation to 112 // do which is important as we want to keep the eden region allocation 113 // path as low-overhead as possible. 114 115 class G1MonitoringSupport : public CHeapObj<mtGC> { 116 friend class VMStructs; 117 118 G1CollectedHeap* _g1h; 119 120 // jstat performance counters 121 // incremental collections both young and mixed 122 CollectorCounters* _incremental_collection_counters; 123 // full stop-the-world collections 124 CollectorCounters* _full_collection_counters; 125 // stop-the-world phases in G1 126 CollectorCounters* _conc_collection_counters; 127 // young collection set counters. The _eden_counters, 128 // _from_counters, and _to_counters are associated with 129 // this "generational" counter. 130 GenerationCounters* _young_collection_counters; 131 // old collection set counters. The _old_space_counters 132 // below are associated with this "generational" counter. 133 GenerationCounters* _old_collection_counters; 134 // Counters for the capacity and used for 135 // the whole heap 136 HSpaceCounters* _old_space_counters; 137 // the young collection 138 HSpaceCounters* _eden_counters; 139 // the survivor collection (only one, _to_counters, is actively used) 140 HSpaceCounters* _from_counters; 141 HSpaceCounters* _to_counters; 142 143 // When it's appropriate to recalculate the various sizes (at the 144 // end of a GC, when a new eden region is allocated, etc.) we store 145 // them here so that we can easily report them when needed and not 146 // have to recalculate them every time. 195 // (e.g., young gen includes one eden, two survivor spaces), the 196 // mult parameter is provided in order to adding the appropriate 197 // padding multiple times so that the capacities add up correctly. 198 static size_t pad_capacity(size_t size_bytes, size_t mult = 1) { 199 return size_bytes + MinObjAlignmentInBytes * mult; 200 } 201 202 // Recalculate all the sizes from scratch and update all the jstat 203 // counters accordingly. 204 void update_sizes(); 205 // Recalculate only what's necessary when a new eden region is 206 // allocated and update any jstat counters that need to be updated. 207 void update_eden_size(); 208 209 CollectorCounters* incremental_collection_counters() { 210 return _incremental_collection_counters; 211 } 212 CollectorCounters* full_collection_counters() { 213 return _full_collection_counters; 214 } 215 CollectorCounters* conc_collection_counters() { 216 return _conc_collection_counters; 217 } 218 GenerationCounters* young_collection_counters() { 219 return _young_collection_counters; 220 } 221 GenerationCounters* old_collection_counters() { 222 return _old_collection_counters; 223 } 224 HSpaceCounters* old_space_counters() { return _old_space_counters; } 225 HSpaceCounters* eden_counters() { return _eden_counters; } 226 HSpaceCounters* from_counters() { return _from_counters; } 227 HSpaceCounters* to_counters() { return _to_counters; } 228 229 // Monitoring support used by 230 // MemoryService 231 // jstat counters 232 // Tracing 233 234 size_t overall_reserved() { return _overall_reserved; } 235 size_t overall_committed() { return _overall_committed; } 236 size_t overall_used() { return _overall_used; } 237 | 105 // 106 // We update all the above synchronously and we store the results in 107 // fields so that we just read said fields when needed. A subtle point 108 // is that all the above sizes need to be recalculated when the old 109 // gen changes capacity (after a GC or after a humongous allocation) 110 // but only the eden occupancy changes when a new eden region is 111 // allocated. So, in the latter case we have minimal recalculation to 112 // do which is important as we want to keep the eden region allocation 113 // path as low-overhead as possible. 114 115 class G1MonitoringSupport : public CHeapObj<mtGC> { 116 friend class VMStructs; 117 118 G1CollectedHeap* _g1h; 119 120 // jstat performance counters 121 // incremental collections both young and mixed 122 CollectorCounters* _incremental_collection_counters; 123 // full stop-the-world collections 124 CollectorCounters* _full_collection_counters; 125 // young collection set counters. The _eden_counters, 126 // _from_counters, and _to_counters are associated with 127 // this "generational" counter. 128 GenerationCounters* _young_collection_counters; 129 // old collection set counters. The _old_space_counters 130 // below are associated with this "generational" counter. 131 GenerationCounters* _old_collection_counters; 132 // Counters for the capacity and used for 133 // the whole heap 134 HSpaceCounters* _old_space_counters; 135 // the young collection 136 HSpaceCounters* _eden_counters; 137 // the survivor collection (only one, _to_counters, is actively used) 138 HSpaceCounters* _from_counters; 139 HSpaceCounters* _to_counters; 140 141 // When it's appropriate to recalculate the various sizes (at the 142 // end of a GC, when a new eden region is allocated, etc.) we store 143 // them here so that we can easily report them when needed and not 144 // have to recalculate them every time. 193 // (e.g., young gen includes one eden, two survivor spaces), the 194 // mult parameter is provided in order to adding the appropriate 195 // padding multiple times so that the capacities add up correctly. 196 static size_t pad_capacity(size_t size_bytes, size_t mult = 1) { 197 return size_bytes + MinObjAlignmentInBytes * mult; 198 } 199 200 // Recalculate all the sizes from scratch and update all the jstat 201 // counters accordingly. 202 void update_sizes(); 203 // Recalculate only what's necessary when a new eden region is 204 // allocated and update any jstat counters that need to be updated. 205 void update_eden_size(); 206 207 CollectorCounters* incremental_collection_counters() { 208 return _incremental_collection_counters; 209 } 210 CollectorCounters* full_collection_counters() { 211 return _full_collection_counters; 212 } 213 GenerationCounters* young_collection_counters() { 214 return _young_collection_counters; 215 } 216 GenerationCounters* old_collection_counters() { 217 return _old_collection_counters; 218 } 219 HSpaceCounters* old_space_counters() { return _old_space_counters; } 220 HSpaceCounters* eden_counters() { return _eden_counters; } 221 HSpaceCounters* from_counters() { return _from_counters; } 222 HSpaceCounters* to_counters() { return _to_counters; } 223 224 // Monitoring support used by 225 // MemoryService 226 // jstat counters 227 // Tracing 228 229 size_t overall_reserved() { return _overall_reserved; } 230 size_t overall_committed() { return _overall_committed; } 231 size_t overall_used() { return _overall_used; } 232 |