< prev index next >

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

Print this page
rev 49525 : [mq]: 8200426-sangheon-review


 161     "s0", 1 /* ordinal */,
 162     pad_capacity(0) /* max_capacity */,
 163     pad_capacity(0) /* init_capacity */);
 164 
 165   //  name "generation.0.space.2"
 166   // See _old_space_counters for additional counters
 167   _to_counters = new HSpaceCounters(young_collection_name_space,
 168     "s1", 2 /* ordinal */,
 169     pad_capacity(overall_reserved()) /* max_capacity */,
 170     pad_capacity(survivor_space_committed()) /* init_capacity */);
 171 
 172   if (UsePerfData) {
 173     // Given that this survivor space is not used, we update it here
 174     // once to reflect that its used space is 0 so that we don't have to
 175     // worry about updating it again later.
 176     _from_counters->update_used(0);
 177   }
 178 }
 179 
 180 void G1MonitoringSupport::recalculate_sizes() {
 181   G1CollectedHeap* g1 = g1h();
 182 
 183   // Recalculate all the sizes from scratch. We assume that this is
 184   // called at a point where no concurrent updates to the various
 185   // values we read here are possible (i.e., at a STW phase at the end
 186   // of a GC).
 187 
 188   uint young_list_length = g1->young_regions_count();
 189   uint survivor_list_length = g1->survivor_regions_count();
 190   assert(young_list_length >= survivor_list_length, "invariant");
 191   uint eden_list_length = young_list_length - survivor_list_length;
 192   // Max length includes any potential extensions to the young gen
 193   // we'll do when the GC locker is active.
 194   uint young_list_max_length = g1->g1_policy()->young_list_max_length();
 195   assert(young_list_max_length >= survivor_list_length, "invariant");
 196   uint eden_list_max_length = young_list_max_length - survivor_list_length;
 197 
 198   _overall_used = g1->used_unlocked();
 199   _eden_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
 200   _survivor_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
 201   _young_region_num = young_list_length;
 202   _old_used = subtract_up_to_zero(_overall_used, _eden_used + _survivor_used);
 203 
 204   // First calculate the committed sizes that can be calculated independently.
 205   _survivor_committed = _survivor_used;
 206   _old_committed = HeapRegion::align_up_to_region_byte_size(_old_used);
 207 
 208   // Next, start with the overall committed size.
 209   _overall_committed = g1->capacity();
 210   size_t committed = _overall_committed;
 211 
 212   // Remove the committed size we have calculated so far (for the
 213   // survivor and old space).
 214   assert(committed >= (_survivor_committed + _old_committed), "sanity");
 215   committed -= _survivor_committed + _old_committed;
 216 
 217   // Next, calculate and remove the committed size for the eden.
 218   _eden_committed = (size_t) eden_list_max_length * HeapRegion::GrainBytes;
 219   // Somewhat defensive: be robust in case there are inaccuracies in
 220   // the calculations
 221   _eden_committed = MIN2(_eden_committed, committed);
 222   committed -= _eden_committed;
 223 
 224   // Finally, give the rest to the old space...
 225   _old_committed += committed;
 226   // ..and calculate the young gen committed.
 227   _young_gen_committed = _eden_committed + _survivor_committed;
 228 
 229   assert(_overall_committed ==
 230          (_eden_committed + _survivor_committed + _old_committed),
 231          "the committed sizes should add up");
 232   // Somewhat defensive: cap the eden used size to make sure it
 233   // never exceeds the committed size.
 234   _eden_used = MIN2(_eden_used, _eden_committed);
 235   // _survivor_committed and _old_committed are calculated in terms of
 236   // the corresponding _*_used value, so the next two conditions
 237   // should hold.
 238   assert(_survivor_used <= _survivor_committed, "post-condition");
 239   assert(_old_used <= _old_committed, "post-condition");
 240 }
 241 
 242 void G1MonitoringSupport::recalculate_eden_size() {
 243   G1CollectedHeap* g1 = g1h();
 244 
 245   // When a new eden region is allocated, only the eden_used size is
 246   // affected (since we have recalculated everything else at the last GC).
 247 
 248   uint young_region_num = g1h()->young_regions_count();
 249   if (young_region_num > _young_region_num) {
 250     uint diff = young_region_num - _young_region_num;
 251     _eden_used += (size_t) diff * HeapRegion::GrainBytes;
 252     // Somewhat defensive: cap the eden used size to make sure it
 253     // never exceeds the committed size.
 254     _eden_used = MIN2(_eden_used, _eden_committed);
 255     _young_region_num = young_region_num;
 256   }
 257 }
 258 
 259 void G1MonitoringSupport::update_sizes() {
 260   recalculate_sizes();
 261   if (UsePerfData) {
 262     eden_counters()->update_capacity(pad_capacity(eden_space_committed()));
 263     eden_counters()->update_used(eden_space_used());
 264     // only the to survivor space (s1) is active, so we don't need to
 265     // update the counters for the from survivor space (s0)
 266     to_counters()->update_capacity(pad_capacity(survivor_space_committed()));
 267     to_counters()->update_used(survivor_space_used());
 268     old_space_counters()->update_capacity(pad_capacity(old_space_committed()));


 161     "s0", 1 /* ordinal */,
 162     pad_capacity(0) /* max_capacity */,
 163     pad_capacity(0) /* init_capacity */);
 164 
 165   //  name "generation.0.space.2"
 166   // See _old_space_counters for additional counters
 167   _to_counters = new HSpaceCounters(young_collection_name_space,
 168     "s1", 2 /* ordinal */,
 169     pad_capacity(overall_reserved()) /* max_capacity */,
 170     pad_capacity(survivor_space_committed()) /* init_capacity */);
 171 
 172   if (UsePerfData) {
 173     // Given that this survivor space is not used, we update it here
 174     // once to reflect that its used space is 0 so that we don't have to
 175     // worry about updating it again later.
 176     _from_counters->update_used(0);
 177   }
 178 }
 179 
 180 void G1MonitoringSupport::recalculate_sizes() {


 181   // Recalculate all the sizes from scratch. We assume that this is
 182   // called at a point where no concurrent updates to the various
 183   // values we read here are possible (i.e., at a STW phase at the end
 184   // of a GC).
 185 
 186   uint young_list_length = _g1h->young_regions_count();
 187   uint survivor_list_length = _g1h->survivor_regions_count();
 188   assert(young_list_length >= survivor_list_length, "invariant");
 189   uint eden_list_length = young_list_length - survivor_list_length;
 190   // Max length includes any potential extensions to the young gen
 191   // we'll do when the GC locker is active.
 192   uint young_list_max_length = _g1h->g1_policy()->young_list_max_length();
 193   assert(young_list_max_length >= survivor_list_length, "invariant");
 194   uint eden_list_max_length = young_list_max_length - survivor_list_length;
 195 
 196   _overall_used = _g1h->used_unlocked();
 197   _eden_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
 198   _survivor_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
 199   _young_region_num = young_list_length;
 200   _old_used = subtract_up_to_zero(_overall_used, _eden_used + _survivor_used);
 201 
 202   // First calculate the committed sizes that can be calculated independently.
 203   _survivor_committed = _survivor_used;
 204   _old_committed = HeapRegion::align_up_to_region_byte_size(_old_used);
 205 
 206   // Next, start with the overall committed size.
 207   _overall_committed = _g1h->capacity();
 208   size_t committed = _overall_committed;
 209 
 210   // Remove the committed size we have calculated so far (for the
 211   // survivor and old space).
 212   assert(committed >= (_survivor_committed + _old_committed), "sanity");
 213   committed -= _survivor_committed + _old_committed;
 214 
 215   // Next, calculate and remove the committed size for the eden.
 216   _eden_committed = (size_t) eden_list_max_length * HeapRegion::GrainBytes;
 217   // Somewhat defensive: be robust in case there are inaccuracies in
 218   // the calculations
 219   _eden_committed = MIN2(_eden_committed, committed);
 220   committed -= _eden_committed;
 221 
 222   // Finally, give the rest to the old space...
 223   _old_committed += committed;
 224   // ..and calculate the young gen committed.
 225   _young_gen_committed = _eden_committed + _survivor_committed;
 226 
 227   assert(_overall_committed ==
 228          (_eden_committed + _survivor_committed + _old_committed),
 229          "the committed sizes should add up");
 230   // Somewhat defensive: cap the eden used size to make sure it
 231   // never exceeds the committed size.
 232   _eden_used = MIN2(_eden_used, _eden_committed);
 233   // _survivor_committed and _old_committed are calculated in terms of
 234   // the corresponding _*_used value, so the next two conditions
 235   // should hold.
 236   assert(_survivor_used <= _survivor_committed, "post-condition");
 237   assert(_old_used <= _old_committed, "post-condition");
 238 }
 239 
 240 void G1MonitoringSupport::recalculate_eden_size() {


 241   // When a new eden region is allocated, only the eden_used size is
 242   // affected (since we have recalculated everything else at the last GC).
 243 
 244   uint young_region_num = _g1h->young_regions_count();
 245   if (young_region_num > _young_region_num) {
 246     uint diff = young_region_num - _young_region_num;
 247     _eden_used += (size_t) diff * HeapRegion::GrainBytes;
 248     // Somewhat defensive: cap the eden used size to make sure it
 249     // never exceeds the committed size.
 250     _eden_used = MIN2(_eden_used, _eden_committed);
 251     _young_region_num = young_region_num;
 252   }
 253 }
 254 
 255 void G1MonitoringSupport::update_sizes() {
 256   recalculate_sizes();
 257   if (UsePerfData) {
 258     eden_counters()->update_capacity(pad_capacity(eden_space_committed()));
 259     eden_counters()->update_used(eden_space_used());
 260     // only the to survivor space (s1) is active, so we don't need to
 261     // update the counters for the from survivor space (s0)
 262     to_counters()->update_capacity(pad_capacity(survivor_space_committed()));
 263     to_counters()->update_used(survivor_space_used());
 264     old_space_counters()->update_capacity(pad_capacity(old_space_committed()));
< prev index next >