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

changeset 2243
a7214d79fcf1
parent 2192
c99c53f07c14
child 2314
f95d63e2154a
     1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Thu Oct 21 17:29:24 2010 -0700
     1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Sat Oct 23 23:03:49 2010 -0700
     1.3 @@ -354,12 +354,8 @@
     1.4  double CMSStats::time_until_cms_gen_full() const {
     1.5    size_t cms_free = _cms_gen->cmsSpace()->free();
     1.6    GenCollectedHeap* gch = GenCollectedHeap::heap();
     1.7 -  size_t expected_promotion = gch->get_gen(0)->capacity();
     1.8 -  if (HandlePromotionFailure) {
     1.9 -    expected_promotion = MIN2(
    1.10 -        (size_t) _cms_gen->gc_stats()->avg_promoted()->padded_average(),
    1.11 -        expected_promotion);
    1.12 -  }
    1.13 +  size_t expected_promotion = MIN2(gch->get_gen(0)->capacity(),
    1.14 +                                   (size_t) _cms_gen->gc_stats()->avg_promoted()->padded_average());
    1.15    if (cms_free > expected_promotion) {
    1.16      // Start a cms collection if there isn't enough space to promote
    1.17      // for the next minor collection.  Use the padded average as
    1.18 @@ -865,57 +861,18 @@
    1.19    return free() + _virtual_space.uncommitted_size();
    1.20  }
    1.21  
    1.22 -bool ConcurrentMarkSweepGeneration::promotion_attempt_is_safe(
    1.23 -    size_t max_promotion_in_bytes,
    1.24 -    bool younger_handles_promotion_failure) const {
    1.25 -
    1.26 -  // This is the most conservative test.  Full promotion is
    1.27 -  // guaranteed if this is used. The multiplicative factor is to
    1.28 -  // account for the worst case "dilatation".
    1.29 -  double adjusted_max_promo_bytes = _dilatation_factor * max_promotion_in_bytes;
    1.30 -  if (adjusted_max_promo_bytes > (double)max_uintx) { // larger than size_t
    1.31 -    adjusted_max_promo_bytes = (double)max_uintx;
    1.32 -  }
    1.33 -  bool result = (max_contiguous_available() >= (size_t)adjusted_max_promo_bytes);
    1.34 -
    1.35 -  if (younger_handles_promotion_failure && !result) {
    1.36 -    // Full promotion is not guaranteed because fragmentation
    1.37 -    // of the cms generation can prevent the full promotion.
    1.38 -    result = (max_available() >= (size_t)adjusted_max_promo_bytes);
    1.39 -
    1.40 -    if (!result) {
    1.41 -      // With promotion failure handling the test for the ability
    1.42 -      // to support the promotion does not have to be guaranteed.
    1.43 -      // Use an average of the amount promoted.
    1.44 -      result = max_available() >= (size_t)
    1.45 -        gc_stats()->avg_promoted()->padded_average();
    1.46 -      if (PrintGC && Verbose && result) {
    1.47 -        gclog_or_tty->print_cr(
    1.48 -          "\nConcurrentMarkSweepGeneration::promotion_attempt_is_safe"
    1.49 -          " max_available: " SIZE_FORMAT
    1.50 -          " avg_promoted: " SIZE_FORMAT,
    1.51 -          max_available(), (size_t)
    1.52 -          gc_stats()->avg_promoted()->padded_average());
    1.53 -      }
    1.54 -    } else {
    1.55 -      if (PrintGC && Verbose) {
    1.56 -        gclog_or_tty->print_cr(
    1.57 -          "\nConcurrentMarkSweepGeneration::promotion_attempt_is_safe"
    1.58 -          " max_available: " SIZE_FORMAT
    1.59 -          " adj_max_promo_bytes: " SIZE_FORMAT,
    1.60 -          max_available(), (size_t)adjusted_max_promo_bytes);
    1.61 -      }
    1.62 -    }
    1.63 -  } else {
    1.64 -    if (PrintGC && Verbose) {
    1.65 -      gclog_or_tty->print_cr(
    1.66 -        "\nConcurrentMarkSweepGeneration::promotion_attempt_is_safe"
    1.67 -        " contiguous_available: " SIZE_FORMAT
    1.68 -        " adj_max_promo_bytes: " SIZE_FORMAT,
    1.69 -        max_contiguous_available(), (size_t)adjusted_max_promo_bytes);
    1.70 -    }
    1.71 -  }
    1.72 -  return result;
    1.73 +bool ConcurrentMarkSweepGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
    1.74 +  size_t available = max_available();
    1.75 +  size_t av_promo  = (size_t)gc_stats()->avg_promoted()->padded_average();
    1.76 +  bool   res = (available >= av_promo) || (available >= max_promotion_in_bytes);
    1.77 +  if (PrintGC && Verbose) {
    1.78 +    gclog_or_tty->print_cr(
    1.79 +      "CMS: promo attempt is%s safe: available("SIZE_FORMAT") %s av_promo("SIZE_FORMAT"),"
    1.80 +      "max_promo("SIZE_FORMAT")",
    1.81 +      res? "":" not", available, res? ">=":"<",
    1.82 +      av_promo, max_promotion_in_bytes);
    1.83 +  }
    1.84 +  return res;
    1.85  }
    1.86  
    1.87  // At a promotion failure dump information on block layout in heap
    1.88 @@ -6091,23 +6048,14 @@
    1.89    assert(_collectorState == Resizing, "Change of collector state to"
    1.90      " Resizing must be done under the freelistLocks (plural)");
    1.91  
    1.92 -  // Now that sweeping has been completed, if the GCH's
    1.93 -  // incremental_collection_will_fail flag is set, clear it,
    1.94 +  // Now that sweeping has been completed, we clear
    1.95 +  // the incremental_collection_failed flag,
    1.96    // thus inviting a younger gen collection to promote into
    1.97    // this generation. If such a promotion may still fail,
    1.98    // the flag will be set again when a young collection is
    1.99    // attempted.
   1.100 -  // I think the incremental_collection_will_fail flag's use
   1.101 -  // is specific to a 2 generation collection policy, so i'll
   1.102 -  // assert that that's the configuration we are operating within.
   1.103 -  // The use of the flag can and should be generalized appropriately
   1.104 -  // in the future to deal with a general n-generation system.
   1.105 -
   1.106    GenCollectedHeap* gch = GenCollectedHeap::heap();
   1.107 -  assert(gch->collector_policy()->is_two_generation_policy(),
   1.108 -         "Resetting of incremental_collection_will_fail flag"
   1.109 -         " may be incorrect otherwise");
   1.110 -  gch->clear_incremental_collection_will_fail();
   1.111 +  gch->clear_incremental_collection_failed();  // Worth retrying as fresh space may have been freed up
   1.112    gch->update_full_collections_completed(_collection_count_start);
   1.113  }
   1.114  

mercurial