--- old/src/share/vm/gc_implementation/g1/heapRegion.cpp 2012-07-24 11:52:17.362811133 -0700 +++ new/src/share/vm/gc_implementation/g1/heapRegion.cpp 2012-07-24 11:52:17.151968457 -0700 @@ -384,10 +384,24 @@ } void HeapRegion::calc_gc_efficiency() { + // GC efficiency is the ratio of how much space would be + // reclaimed over how long we predict it would take to reclaim it. G1CollectedHeap* g1h = G1CollectedHeap::heap(); G1CollectorPolicy* g1p = g1h->g1_policy(); - _gc_efficiency = (double) reclaimable_bytes() / - g1p->predict_region_elapsed_time_ms(this, false); + + // The calculation of how long it would take to collect this region + // is based upon G1CollectorPolicy::predict_region_elapsed_time_ms(). + // If that routine changes, this code should be changed appropriately. + size_t rs_length = rem_set()->occupied(); + size_t card_num = g1p->predict_non_young_card_num(rs_length); + size_t bytes_to_copy = live_bytes(); + + double region_elapsed_time_ms = + g1p->predict_rs_scan_time_ms(card_num) + + g1p->predict_object_copy_time_ms(bytes_to_copy) + + g1p->predict_non_young_other_time_ms(1); + + _gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms; } void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) {