src/hotspot/share/gc/g1/g1CollectionSet.cpp
changeset 49643 a3453bbd5418
parent 49333 489f1dd40582
child 49806 2d62570a615c
equal deleted inserted replaced
49642:7bad9c9efdf3 49643:a3453bbd5418
    45 CollectionSetChooser* G1CollectionSet::cset_chooser() {
    45 CollectionSetChooser* G1CollectionSet::cset_chooser() {
    46   return _cset_chooser;
    46   return _cset_chooser;
    47 }
    47 }
    48 
    48 
    49 double G1CollectionSet::predict_region_elapsed_time_ms(HeapRegion* hr) {
    49 double G1CollectionSet::predict_region_elapsed_time_ms(HeapRegion* hr) {
    50   return _policy->predict_region_elapsed_time_ms(hr, collector_state()->gcs_are_young());
    50   return _policy->predict_region_elapsed_time_ms(hr, collector_state()->in_young_only_phase());
    51 }
    51 }
    52 
    52 
    53 G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) :
    53 G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) :
    54   _g1(g1h),
    54   _g1(g1h),
    55   _policy(policy),
    55   _policy(policy),
   253   // information in the heap region here (before the region gets added
   253   // information in the heap region here (before the region gets added
   254   // to the collection set). An individual heap region's cached values
   254   // to the collection set). An individual heap region's cached values
   255   // are calculated, aggregated with the policy collection set info,
   255   // are calculated, aggregated with the policy collection set info,
   256   // and cached in the heap region here (initially) and (subsequently)
   256   // and cached in the heap region here (initially) and (subsequently)
   257   // by the Young List sampling code.
   257   // by the Young List sampling code.
   258 
   258   // Ignore calls to this due to retirement during full gc.
   259   size_t rs_length = hr->rem_set()->occupied();
   259 
   260   double region_elapsed_time_ms = predict_region_elapsed_time_ms(hr);
   260   if (!G1CollectedHeap::heap()->collector_state()->in_full_gc()) {
   261 
   261     size_t rs_length = hr->rem_set()->occupied();
   262   // Cache the values we have added to the aggregated information
   262     double region_elapsed_time_ms = predict_region_elapsed_time_ms(hr);
   263   // in the heap region in case we have to remove this region from
   263 
   264   // the incremental collection set, or it is updated by the
   264     // Cache the values we have added to the aggregated information
   265   // rset sampling code
   265     // in the heap region in case we have to remove this region from
   266   hr->set_recorded_rs_length(rs_length);
   266     // the incremental collection set, or it is updated by the
   267   hr->set_predicted_elapsed_time_ms(region_elapsed_time_ms);
   267     // rset sampling code
   268 
   268     hr->set_recorded_rs_length(rs_length);
   269   size_t used_bytes = hr->used();
   269     hr->set_predicted_elapsed_time_ms(region_elapsed_time_ms);
   270   _inc_recorded_rs_lengths += rs_length;
   270 
   271   _inc_predicted_elapsed_time_ms += region_elapsed_time_ms;
   271     _inc_recorded_rs_lengths += rs_length;
   272   _inc_bytes_used_before += used_bytes;
   272     _inc_predicted_elapsed_time_ms += region_elapsed_time_ms;
       
   273     _inc_bytes_used_before += hr->used();
       
   274   }
   273 
   275 
   274   assert(!hr->in_collection_set(), "invariant");
   276   assert(!hr->in_collection_set(), "invariant");
   275   _g1->register_young_region_with_cset(hr);
   277   _g1->register_young_region_with_cset(hr);
   276 }
   278 }
   277 
   279 
   364   double time_remaining_ms = MAX2(target_pause_time_ms - base_time_ms, 0.0);
   366   double time_remaining_ms = MAX2(target_pause_time_ms - base_time_ms, 0.0);
   365 
   367 
   366   log_trace(gc, ergo, cset)("Start choosing CSet. pending cards: " SIZE_FORMAT " predicted base time: %1.2fms remaining time: %1.2fms target pause time: %1.2fms",
   368   log_trace(gc, ergo, cset)("Start choosing CSet. pending cards: " SIZE_FORMAT " predicted base time: %1.2fms remaining time: %1.2fms target pause time: %1.2fms",
   367                             pending_cards, base_time_ms, time_remaining_ms, target_pause_time_ms);
   369                             pending_cards, base_time_ms, time_remaining_ms, target_pause_time_ms);
   368 
   370 
   369   collector_state()->set_last_gc_was_young(collector_state()->gcs_are_young());
       
   370 
       
   371   // The young list is laid with the survivor regions from the previous
   371   // The young list is laid with the survivor regions from the previous
   372   // pause are appended to the RHS of the young list, i.e.
   372   // pause are appended to the RHS of the young list, i.e.
   373   //   [Newly Young Regions ++ Survivors from last pause].
   373   //   [Newly Young Regions ++ Survivors from last pause].
   374 
   374 
   375   uint survivor_region_length = survivors->length();
   375   uint survivor_region_length = survivors->length();
   409 
   409 
   410 void G1CollectionSet::finalize_old_part(double time_remaining_ms) {
   410 void G1CollectionSet::finalize_old_part(double time_remaining_ms) {
   411   double non_young_start_time_sec = os::elapsedTime();
   411   double non_young_start_time_sec = os::elapsedTime();
   412   double predicted_old_time_ms = 0.0;
   412   double predicted_old_time_ms = 0.0;
   413 
   413 
   414   if (!collector_state()->gcs_are_young()) {
   414   if (collector_state()->in_mixed_phase()) {
   415     cset_chooser()->verify();
   415     cset_chooser()->verify();
   416     const uint min_old_cset_length = _policy->calc_min_old_cset_length();
   416     const uint min_old_cset_length = _policy->calc_min_old_cset_length();
   417     const uint max_old_cset_length = _policy->calc_max_old_cset_length();
   417     const uint max_old_cset_length = _policy->calc_max_old_cset_length();
   418 
   418 
   419     uint expensive_region_num = 0;
   419     uint expensive_region_num = 0;