hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
changeset 5033 55f476a32544
parent 4902 991aaddb5165
child 5034 a1cec6310394
equal deleted inserted replaced
4903:1837a9533d89 5033:55f476a32544
   268   _concurrent_mark_init_times_ms->add(0.05);
   268   _concurrent_mark_init_times_ms->add(0.05);
   269   _concurrent_mark_remark_times_ms->add(0.05);
   269   _concurrent_mark_remark_times_ms->add(0.05);
   270   _concurrent_mark_cleanup_times_ms->add(0.20);
   270   _concurrent_mark_cleanup_times_ms->add(0.20);
   271   _tenuring_threshold = MaxTenuringThreshold;
   271   _tenuring_threshold = MaxTenuringThreshold;
   272 
   272 
   273   if (G1UseSurvivorSpaces) {
   273   // if G1FixedSurvivorSpaceSize is 0 which means the size is not
   274     // if G1FixedSurvivorSpaceSize is 0 which means the size is not
   274   // fixed, then _max_survivor_regions will be calculated at
   275     // fixed, then _max_survivor_regions will be calculated at
   275   // calculate_young_list_target_config during initialization
   276     // calculate_young_list_target_config during initialization
   276   _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes;
   277     _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes;
       
   278   } else {
       
   279     _max_survivor_regions = 0;
       
   280   }
       
   281 
   277 
   282   initialize_all();
   278   initialize_all();
   283 }
   279 }
   284 
   280 
   285 // Increment "i", mod "len"
   281 // Increment "i", mod "len"
   453 
   449 
   454 void G1CollectorPolicy::calculate_young_list_target_config(size_t rs_lengths) {
   450 void G1CollectorPolicy::calculate_young_list_target_config(size_t rs_lengths) {
   455   guarantee( adaptive_young_list_length(), "pre-condition" );
   451   guarantee( adaptive_young_list_length(), "pre-condition" );
   456 
   452 
   457   double start_time_sec = os::elapsedTime();
   453   double start_time_sec = os::elapsedTime();
   458   size_t min_reserve_perc = MAX2((size_t)2, (size_t)G1MinReservePercent);
   454   size_t min_reserve_perc = MAX2((size_t)2, (size_t)G1ReservePercent);
   459   min_reserve_perc = MIN2((size_t) 50, min_reserve_perc);
   455   min_reserve_perc = MIN2((size_t) 50, min_reserve_perc);
   460   size_t reserve_regions =
   456   size_t reserve_regions =
   461     (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0);
   457     (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0);
   462 
   458 
   463   if (full_young_gcs() && _free_regions_at_end_of_collection > 0) {
   459   if (full_young_gcs() && _free_regions_at_end_of_collection > 0) {
  1108   // do that for any other surv rate groups
  1104   // do that for any other surv rate groups
  1109   _short_lived_surv_rate_group->stop_adding_regions();
  1105   _short_lived_surv_rate_group->stop_adding_regions();
  1110   size_t short_lived_so_length = _young_list_so_prefix_length;
  1106   size_t short_lived_so_length = _young_list_so_prefix_length;
  1111   _short_lived_surv_rate_group->record_scan_only_prefix(short_lived_so_length);
  1107   _short_lived_surv_rate_group->record_scan_only_prefix(short_lived_so_length);
  1112   tag_scan_only(short_lived_so_length);
  1108   tag_scan_only(short_lived_so_length);
  1113 
  1109   _survivors_age_table.clear();
  1114   if (G1UseSurvivorSpaces) {
       
  1115     _survivors_age_table.clear();
       
  1116   }
       
  1117 
  1110 
  1118   assert( verify_young_ages(), "region age verification" );
  1111   assert( verify_young_ages(), "region age verification" );
  1119 }
  1112 }
  1120 
  1113 
  1121 void G1CollectorPolicy::tag_scan_only(size_t short_lived_scan_only_length) {
  1114 void G1CollectorPolicy::tag_scan_only(size_t short_lived_scan_only_length) {
  1914   _scan_only_regions_at_end_of_collection = _g1->young_list_length();
  1907   _scan_only_regions_at_end_of_collection = _g1->young_list_length();
  1915   calculate_young_list_min_length();
  1908   calculate_young_list_min_length();
  1916   calculate_young_list_target_config();
  1909   calculate_young_list_target_config();
  1917 
  1910 
  1918   // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
  1911   // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
  1919   double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSUpdatePauseFractionPercent / 100.0;
  1912   double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
  1920   adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms);
  1913   adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms);
  1921 
  1914 
  1922   // </NEW PREDICTION>
  1915   // </NEW PREDICTION>
  1923 
  1916 
  1924   _target_pause_time_ms = -1.0;
  1917   _target_pause_time_ms = -1.0;
  1930                                                      double update_rs_processed_buffers,
  1923                                                      double update_rs_processed_buffers,
  1931                                                      double goal_ms) {
  1924                                                      double goal_ms) {
  1932   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  1925   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  1933   ConcurrentG1Refine *cg1r = G1CollectedHeap::heap()->concurrent_g1_refine();
  1926   ConcurrentG1Refine *cg1r = G1CollectedHeap::heap()->concurrent_g1_refine();
  1934 
  1927 
  1935   if (G1AdaptiveConcRefine) {
  1928   if (G1UseAdaptiveConcRefinement) {
  1936     const int k_gy = 3, k_gr = 6;
  1929     const int k_gy = 3, k_gr = 6;
  1937     const double inc_k = 1.1, dec_k = 0.9;
  1930     const double inc_k = 1.1, dec_k = 0.9;
  1938 
  1931 
  1939     int g = cg1r->green_zone();
  1932     int g = cg1r->green_zone();
  1940     if (update_rs_time > goal_ms) {
  1933     if (update_rs_time > goal_ms) {
  2605 }
  2598 }
  2606 
  2599 
  2607 // Calculates survivor space parameters.
  2600 // Calculates survivor space parameters.
  2608 void G1CollectorPolicy::calculate_survivors_policy()
  2601 void G1CollectorPolicy::calculate_survivors_policy()
  2609 {
  2602 {
  2610   if (!G1UseSurvivorSpaces) {
       
  2611     return;
       
  2612   }
       
  2613   if (G1FixedSurvivorSpaceSize == 0) {
  2603   if (G1FixedSurvivorSpaceSize == 0) {
  2614     _max_survivor_regions = _young_list_target_length / SurvivorRatio;
  2604     _max_survivor_regions = _young_list_target_length / SurvivorRatio;
  2615   } else {
  2605   } else {
  2616     _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes;
  2606     _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes;
  2617   }
  2607   }
  2865 
  2855 
  2866 // Add the heap region to the collection set and return the conservative
  2856 // Add the heap region to the collection set and return the conservative
  2867 // estimate of the number of live bytes.
  2857 // estimate of the number of live bytes.
  2868 void G1CollectorPolicy::
  2858 void G1CollectorPolicy::
  2869 add_to_collection_set(HeapRegion* hr) {
  2859 add_to_collection_set(HeapRegion* hr) {
  2870   if (G1PrintRegions) {
  2860   if (G1PrintHeapRegions) {
  2871     gclog_or_tty->print_cr("added region to cset %d:["PTR_FORMAT", "PTR_FORMAT"], "
  2861     gclog_or_tty->print_cr("added region to cset %d:["PTR_FORMAT", "PTR_FORMAT"], "
  2872                   "top "PTR_FORMAT", young %s",
  2862                   "top "PTR_FORMAT", young %s",
  2873                   hr->hrs_index(), hr->bottom(), hr->end(),
  2863                   hr->hrs_index(), hr->bottom(), hr->end(),
  2874                   hr->top(), (hr->is_young()) ? "YES" : "NO");
  2864                   hr->top(), (hr->is_young()) ? "YES" : "NO");
  2875   }
  2865   }