src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/gc_implementation/concurrentMarkSweep

src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp

Print this page
rev 7211 : [mq]: remove_ngen
rev 7212 : [mq]: remove_get_gen


 363   _cms_used_at_gc0_end = 0;
 364   _allow_duty_cycle_reduction = false;
 365   _valid_bits = 0;
 366   _icms_duty_cycle = CMSIncrementalDutyCycle;
 367 }
 368 
 369 double CMSStats::cms_free_adjustment_factor(size_t free) const {
 370   // TBD: CR 6909490
 371   return 1.0;
 372 }
 373 
 374 void CMSStats::adjust_cms_free_adjustment_factor(bool fail, size_t free) {
 375 }
 376 
 377 // If promotion failure handling is on use
 378 // the padded average size of the promotion for each
 379 // young generation collection.
 380 double CMSStats::time_until_cms_gen_full() const {
 381   size_t cms_free = _cms_gen->cmsSpace()->free();
 382   GenCollectedHeap* gch = GenCollectedHeap::heap();
 383   size_t expected_promotion = MIN2(gch->get_gen(0)->capacity(),
 384                                    (size_t) _cms_gen->gc_stats()->avg_promoted()->padded_average());
 385   if (cms_free > expected_promotion) {
 386     // Start a cms collection if there isn't enough space to promote
 387     // for the next minor collection.  Use the padded average as
 388     // a safety factor.
 389     cms_free -= expected_promotion;
 390 
 391     // Adjust by the safety factor.
 392     double cms_free_dbl = (double)cms_free;
 393     double cms_adjustment = (100.0 - CMSIncrementalSafetyFactor)/100.0;
 394     // Apply a further correction factor which tries to adjust
 395     // for recent occurance of concurrent mode failures.
 396     cms_adjustment = cms_adjustment * cms_free_adjustment_factor(cms_free);
 397     cms_free_dbl = cms_free_dbl * cms_adjustment;
 398 
 399     if (PrintGCDetails && Verbose) {
 400       gclog_or_tty->print_cr("CMSStats::time_until_cms_gen_full: cms_free "
 401         SIZE_FORMAT " expected_promotion " SIZE_FORMAT,
 402         cms_free, expected_promotion);
 403       gclog_or_tty->print_cr("  cms_free_dbl %f cms_consumption_rate %f",


 691 
 692   _cmsGen ->init_initiating_occupancy(CMSInitiatingOccupancyFraction, CMSTriggerRatio);
 693 
 694   // Clip CMSBootstrapOccupancy between 0 and 100.
 695   _bootstrap_occupancy = ((double)CMSBootstrapOccupancy)/(double)100;
 696 
 697   _full_gcs_since_conc_gc = 0;
 698 
 699   // Now tell CMS generations the identity of their collector
 700   ConcurrentMarkSweepGeneration::set_collector(this);
 701 
 702   // Create & start a CMS thread for this CMS collector
 703   _cmsThread = ConcurrentMarkSweepThread::start(this);
 704   assert(cmsThread() != NULL, "CMS Thread should have been created");
 705   assert(cmsThread()->collector() == this,
 706          "CMS Thread should refer to this gen");
 707   assert(CGC_lock != NULL, "Where's the CGC_lock?");
 708 
 709   // Support for parallelizing young gen rescan
 710   GenCollectedHeap* gch = GenCollectedHeap::heap();
 711   _young_gen = gch->prev_gen(_cmsGen);
 712   if (gch->supports_inline_contig_alloc()) {
 713     _top_addr = gch->top_addr();
 714     _end_addr = gch->end_addr();
 715     assert(_young_gen != NULL, "no _young_gen");
 716     _eden_chunk_index = 0;
 717     _eden_chunk_capacity = (_young_gen->max_capacity()+CMSSamplingGrain)/CMSSamplingGrain;
 718     _eden_chunk_array = NEW_C_HEAP_ARRAY(HeapWord*, _eden_chunk_capacity, mtGC);
 719     if (_eden_chunk_array == NULL) {
 720       _eden_chunk_capacity = 0;
 721       warning("GC/CMS: _eden_chunk_array allocation failure");
 722     }
 723   }
 724   assert(_eden_chunk_array != NULL || _eden_chunk_capacity == 0, "Error");
 725 
 726   // Support for parallelizing survivor space rescan
 727   if ((CMSParallelRemarkEnabled && CMSParallelSurvivorRemarkEnabled) || CMSParallelInitialMarkEnabled) {
 728     const size_t max_plab_samples =
 729       ((DefNewGeneration*)_young_gen)->max_survivor_size()/MinTLABSize;
 730 
 731     _survivor_plab_array  = NEW_C_HEAP_ARRAY(ChunkArray, ParallelGCThreads, mtGC);


 938   // compute expansion delta needed for reaching desired free percentage
 939   if (free_percentage < desired_free_percentage) {
 940     size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
 941     assert(desired_capacity >= capacity(), "invalid expansion size");
 942     size_t expand_bytes = MAX2(desired_capacity - capacity(), MinHeapDeltaBytes);
 943     if (PrintGCDetails && Verbose) {
 944       size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
 945       gclog_or_tty->print_cr("\nFrom compute_new_size: ");
 946       gclog_or_tty->print_cr("  Free fraction %f", free_percentage);
 947       gclog_or_tty->print_cr("  Desired free fraction %f",
 948         desired_free_percentage);
 949       gclog_or_tty->print_cr("  Maximum free fraction %f",
 950         maximum_free_percentage);
 951       gclog_or_tty->print_cr("  Capacity "SIZE_FORMAT, capacity()/1000);
 952       gclog_or_tty->print_cr("  Desired capacity "SIZE_FORMAT,
 953         desired_capacity/1000);
 954       int prev_level = level() - 1;
 955       if (prev_level >= 0) {
 956         size_t prev_size = 0;
 957         GenCollectedHeap* gch = GenCollectedHeap::heap();
 958         Generation* prev_gen = gch->get_gen(prev_level);
 959         prev_size = prev_gen->capacity();
 960           gclog_or_tty->print_cr("  Younger gen size "SIZE_FORMAT,
 961                                  prev_size/1000);
 962       }
 963       gclog_or_tty->print_cr("  unsafe_max_alloc_nogc "SIZE_FORMAT,
 964         unsafe_max_alloc_nogc()/1000);
 965       gclog_or_tty->print_cr("  contiguous available "SIZE_FORMAT,
 966         contiguous_available()/1000);
 967       gclog_or_tty->print_cr("  Expand by "SIZE_FORMAT" (bytes)",
 968         expand_bytes);
 969     }
 970     // safe if expansion fails
 971     expand(expand_bytes, 0, CMSExpansionCause::_satisfy_free_ratio);
 972     if (PrintGCDetails && Verbose) {
 973       gclog_or_tty->print_cr("  Expanded free fraction %f",
 974         ((double) free()) / capacity());
 975     }
 976   } else {
 977     size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
 978     assert(desired_capacity <= capacity(), "invalid expansion size");


1109         }
1110       } else {  // not an obj array; we can just mark the head
1111         if (par) {
1112           _modUnionTable.par_mark(start);
1113         } else {
1114           _modUnionTable.mark(start);
1115         }
1116       }
1117     }
1118   }
1119 }
1120 
1121 static inline size_t percent_of_space(Space* space, HeapWord* addr)
1122 {
1123   size_t delta = pointer_delta(addr, space->bottom());
1124   return (size_t)(delta * 100.0 / (space->capacity() / HeapWordSize));
1125 }
1126 
1127 void CMSCollector::icms_update_allocation_limits()
1128 {
1129   Generation* young = GenCollectedHeap::heap()->get_gen(0);
1130   EdenSpace* eden = young->as_DefNewGeneration()->eden();
1131 
1132   const unsigned int duty_cycle = stats().icms_update_duty_cycle();
1133   if (CMSTraceIncrementalPacing) {
1134     stats().print();
1135   }
1136 
1137   assert(duty_cycle <= 100, "invalid duty cycle");
1138   if (duty_cycle != 0) {
1139     // The duty_cycle is a percentage between 0 and 100; convert to words and
1140     // then compute the offset from the endpoints of the space.
1141     size_t free_words = eden->free() / HeapWordSize;
1142     double free_words_dbl = (double)free_words;
1143     size_t duty_cycle_words = (size_t)(free_words_dbl * duty_cycle / 100.0);
1144     size_t offset_words = (free_words - duty_cycle_words) / 2;
1145 
1146     _icms_start_limit = eden->top() + offset_words;
1147     _icms_stop_limit = eden->end() - offset_words;
1148 
1149     // The limits may be adjusted (shifted to the right) by


1250 }
1251 
1252 oop ConcurrentMarkSweepGeneration::promote(oop obj, size_t obj_size) {
1253   assert(obj_size == (size_t)obj->size(), "bad obj_size passed in");
1254   // allocate, copy and if necessary update promoinfo --
1255   // delegate to underlying space.
1256   assert_lock_strong(freelistLock());
1257 
1258 #ifndef PRODUCT
1259   if (Universe::heap()->promotion_should_fail()) {
1260     return NULL;
1261   }
1262 #endif  // #ifndef PRODUCT
1263 
1264   oop res = _cmsSpace->promote(obj, obj_size);
1265   if (res == NULL) {
1266     // expand and retry
1267     size_t s = _cmsSpace->expansionSpaceRequired(obj_size);  // HeapWords
1268     expand(s*HeapWordSize, MinHeapDeltaBytes,
1269       CMSExpansionCause::_satisfy_promotion);
1270     // Since there's currently no next generation, we don't try to promote
1271     // into a more senior generation.
1272     assert(next_gen() == NULL, "assumption, based upon which no attempt "
1273                                "is made to pass on a possibly failing "
1274                                "promotion to next generation");
1275     res = _cmsSpace->promote(obj, obj_size);
1276   }
1277   if (res != NULL) {
1278     // See comment in allocate() about when objects should
1279     // be allocated live.
1280     assert(obj->is_oop(), "Will dereference klass pointer below");
1281     collector()->promoted(false,           // Not parallel
1282                           (HeapWord*)res, obj->is_objArray(), obj_size);
1283     // promotion counters
1284     NOT_PRODUCT(
1285       _numObjectsPromoted++;
1286       _numWordsPromoted +=
1287         (int)(CompactibleFreeListSpace::adjustObjectSize(obj->size()));
1288     )
1289   }
1290   return res;
1291 }
1292 
1293 
1294 HeapWord*




 363   _cms_used_at_gc0_end = 0;
 364   _allow_duty_cycle_reduction = false;
 365   _valid_bits = 0;
 366   _icms_duty_cycle = CMSIncrementalDutyCycle;
 367 }
 368 
 369 double CMSStats::cms_free_adjustment_factor(size_t free) const {
 370   // TBD: CR 6909490
 371   return 1.0;
 372 }
 373 
 374 void CMSStats::adjust_cms_free_adjustment_factor(bool fail, size_t free) {
 375 }
 376 
 377 // If promotion failure handling is on use
 378 // the padded average size of the promotion for each
 379 // young generation collection.
 380 double CMSStats::time_until_cms_gen_full() const {
 381   size_t cms_free = _cms_gen->cmsSpace()->free();
 382   GenCollectedHeap* gch = GenCollectedHeap::heap();
 383   size_t expected_promotion = MIN2(gch->young_gen()->capacity(),
 384                                    (size_t) _cms_gen->gc_stats()->avg_promoted()->padded_average());
 385   if (cms_free > expected_promotion) {
 386     // Start a cms collection if there isn't enough space to promote
 387     // for the next minor collection.  Use the padded average as
 388     // a safety factor.
 389     cms_free -= expected_promotion;
 390 
 391     // Adjust by the safety factor.
 392     double cms_free_dbl = (double)cms_free;
 393     double cms_adjustment = (100.0 - CMSIncrementalSafetyFactor)/100.0;
 394     // Apply a further correction factor which tries to adjust
 395     // for recent occurance of concurrent mode failures.
 396     cms_adjustment = cms_adjustment * cms_free_adjustment_factor(cms_free);
 397     cms_free_dbl = cms_free_dbl * cms_adjustment;
 398 
 399     if (PrintGCDetails && Verbose) {
 400       gclog_or_tty->print_cr("CMSStats::time_until_cms_gen_full: cms_free "
 401         SIZE_FORMAT " expected_promotion " SIZE_FORMAT,
 402         cms_free, expected_promotion);
 403       gclog_or_tty->print_cr("  cms_free_dbl %f cms_consumption_rate %f",


 691 
 692   _cmsGen ->init_initiating_occupancy(CMSInitiatingOccupancyFraction, CMSTriggerRatio);
 693 
 694   // Clip CMSBootstrapOccupancy between 0 and 100.
 695   _bootstrap_occupancy = ((double)CMSBootstrapOccupancy)/(double)100;
 696 
 697   _full_gcs_since_conc_gc = 0;
 698 
 699   // Now tell CMS generations the identity of their collector
 700   ConcurrentMarkSweepGeneration::set_collector(this);
 701 
 702   // Create & start a CMS thread for this CMS collector
 703   _cmsThread = ConcurrentMarkSweepThread::start(this);
 704   assert(cmsThread() != NULL, "CMS Thread should have been created");
 705   assert(cmsThread()->collector() == this,
 706          "CMS Thread should refer to this gen");
 707   assert(CGC_lock != NULL, "Where's the CGC_lock?");
 708 
 709   // Support for parallelizing young gen rescan
 710   GenCollectedHeap* gch = GenCollectedHeap::heap();
 711   _young_gen = gch->young_gen();
 712   if (gch->supports_inline_contig_alloc()) {
 713     _top_addr = gch->top_addr();
 714     _end_addr = gch->end_addr();
 715     assert(_young_gen != NULL, "no _young_gen");
 716     _eden_chunk_index = 0;
 717     _eden_chunk_capacity = (_young_gen->max_capacity()+CMSSamplingGrain)/CMSSamplingGrain;
 718     _eden_chunk_array = NEW_C_HEAP_ARRAY(HeapWord*, _eden_chunk_capacity, mtGC);
 719     if (_eden_chunk_array == NULL) {
 720       _eden_chunk_capacity = 0;
 721       warning("GC/CMS: _eden_chunk_array allocation failure");
 722     }
 723   }
 724   assert(_eden_chunk_array != NULL || _eden_chunk_capacity == 0, "Error");
 725 
 726   // Support for parallelizing survivor space rescan
 727   if ((CMSParallelRemarkEnabled && CMSParallelSurvivorRemarkEnabled) || CMSParallelInitialMarkEnabled) {
 728     const size_t max_plab_samples =
 729       ((DefNewGeneration*)_young_gen)->max_survivor_size()/MinTLABSize;
 730 
 731     _survivor_plab_array  = NEW_C_HEAP_ARRAY(ChunkArray, ParallelGCThreads, mtGC);


 938   // compute expansion delta needed for reaching desired free percentage
 939   if (free_percentage < desired_free_percentage) {
 940     size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
 941     assert(desired_capacity >= capacity(), "invalid expansion size");
 942     size_t expand_bytes = MAX2(desired_capacity - capacity(), MinHeapDeltaBytes);
 943     if (PrintGCDetails && Verbose) {
 944       size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
 945       gclog_or_tty->print_cr("\nFrom compute_new_size: ");
 946       gclog_or_tty->print_cr("  Free fraction %f", free_percentage);
 947       gclog_or_tty->print_cr("  Desired free fraction %f",
 948         desired_free_percentage);
 949       gclog_or_tty->print_cr("  Maximum free fraction %f",
 950         maximum_free_percentage);
 951       gclog_or_tty->print_cr("  Capacity "SIZE_FORMAT, capacity()/1000);
 952       gclog_or_tty->print_cr("  Desired capacity "SIZE_FORMAT,
 953         desired_capacity/1000);
 954       int prev_level = level() - 1;
 955       if (prev_level >= 0) {
 956         size_t prev_size = 0;
 957         GenCollectedHeap* gch = GenCollectedHeap::heap();
 958         Generation* prev_gen = gch->young_gen();
 959         prev_size = prev_gen->capacity();
 960           gclog_or_tty->print_cr("  Younger gen size "SIZE_FORMAT,
 961                                  prev_size/1000);
 962       }
 963       gclog_or_tty->print_cr("  unsafe_max_alloc_nogc "SIZE_FORMAT,
 964         unsafe_max_alloc_nogc()/1000);
 965       gclog_or_tty->print_cr("  contiguous available "SIZE_FORMAT,
 966         contiguous_available()/1000);
 967       gclog_or_tty->print_cr("  Expand by "SIZE_FORMAT" (bytes)",
 968         expand_bytes);
 969     }
 970     // safe if expansion fails
 971     expand(expand_bytes, 0, CMSExpansionCause::_satisfy_free_ratio);
 972     if (PrintGCDetails && Verbose) {
 973       gclog_or_tty->print_cr("  Expanded free fraction %f",
 974         ((double) free()) / capacity());
 975     }
 976   } else {
 977     size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
 978     assert(desired_capacity <= capacity(), "invalid expansion size");


1109         }
1110       } else {  // not an obj array; we can just mark the head
1111         if (par) {
1112           _modUnionTable.par_mark(start);
1113         } else {
1114           _modUnionTable.mark(start);
1115         }
1116       }
1117     }
1118   }
1119 }
1120 
1121 static inline size_t percent_of_space(Space* space, HeapWord* addr)
1122 {
1123   size_t delta = pointer_delta(addr, space->bottom());
1124   return (size_t)(delta * 100.0 / (space->capacity() / HeapWordSize));
1125 }
1126 
1127 void CMSCollector::icms_update_allocation_limits()
1128 {
1129   Generation* young = GenCollectedHeap::heap()->young_gen();
1130   EdenSpace* eden = young->as_DefNewGeneration()->eden();
1131 
1132   const unsigned int duty_cycle = stats().icms_update_duty_cycle();
1133   if (CMSTraceIncrementalPacing) {
1134     stats().print();
1135   }
1136 
1137   assert(duty_cycle <= 100, "invalid duty cycle");
1138   if (duty_cycle != 0) {
1139     // The duty_cycle is a percentage between 0 and 100; convert to words and
1140     // then compute the offset from the endpoints of the space.
1141     size_t free_words = eden->free() / HeapWordSize;
1142     double free_words_dbl = (double)free_words;
1143     size_t duty_cycle_words = (size_t)(free_words_dbl * duty_cycle / 100.0);
1144     size_t offset_words = (free_words - duty_cycle_words) / 2;
1145 
1146     _icms_start_limit = eden->top() + offset_words;
1147     _icms_stop_limit = eden->end() - offset_words;
1148 
1149     // The limits may be adjusted (shifted to the right) by


1250 }
1251 
1252 oop ConcurrentMarkSweepGeneration::promote(oop obj, size_t obj_size) {
1253   assert(obj_size == (size_t)obj->size(), "bad obj_size passed in");
1254   // allocate, copy and if necessary update promoinfo --
1255   // delegate to underlying space.
1256   assert_lock_strong(freelistLock());
1257 
1258 #ifndef PRODUCT
1259   if (Universe::heap()->promotion_should_fail()) {
1260     return NULL;
1261   }
1262 #endif  // #ifndef PRODUCT
1263 
1264   oop res = _cmsSpace->promote(obj, obj_size);
1265   if (res == NULL) {
1266     // expand and retry
1267     size_t s = _cmsSpace->expansionSpaceRequired(obj_size);  // HeapWords
1268     expand(s*HeapWordSize, MinHeapDeltaBytes,
1269       CMSExpansionCause::_satisfy_promotion);
1270     // Since this is the old generation, we don't try to promote
1271     // into a more senior generation.



1272     res = _cmsSpace->promote(obj, obj_size);
1273   }
1274   if (res != NULL) {
1275     // See comment in allocate() about when objects should
1276     // be allocated live.
1277     assert(obj->is_oop(), "Will dereference klass pointer below");
1278     collector()->promoted(false,           // Not parallel
1279                           (HeapWord*)res, obj->is_objArray(), obj_size);
1280     // promotion counters
1281     NOT_PRODUCT(
1282       _numObjectsPromoted++;
1283       _numWordsPromoted +=
1284         (int)(CompactibleFreeListSpace::adjustObjectSize(obj->size()));
1285     )
1286   }
1287   return res;
1288 }
1289 
1290 
1291 HeapWord*


src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File