Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @ 545:58054a18d735
6484959: G1: introduce survivor spaces
6797754: G1: combined bugfix
Summary: Implemented a policy to control G1 survivor space parameters.
Reviewed-by: tonyp, iveresov
author | apetrusenko |
---|---|
date | Fri, 06 Feb 2009 01:38:50 +0300 |
parents | 818efdefcc99 |
children | 1e458753107d |
comparison
equal
deleted
inserted
replaced
544:82a980778b92 | 545:58054a18d735 |
---|---|
194 #endif // _MSC_VER | 194 #endif // _MSC_VER |
195 | 195 |
196 _short_lived_surv_rate_group(new SurvRateGroup(this, "Short Lived", | 196 _short_lived_surv_rate_group(new SurvRateGroup(this, "Short Lived", |
197 G1YoungSurvRateNumRegionsSummary)), | 197 G1YoungSurvRateNumRegionsSummary)), |
198 _survivor_surv_rate_group(new SurvRateGroup(this, "Survivor", | 198 _survivor_surv_rate_group(new SurvRateGroup(this, "Survivor", |
199 G1YoungSurvRateNumRegionsSummary)) | 199 G1YoungSurvRateNumRegionsSummary)), |
200 // add here any more surv rate groups | 200 // add here any more surv rate groups |
201 _recorded_survivor_regions(0), | |
202 _recorded_survivor_head(NULL), | |
203 _recorded_survivor_tail(NULL), | |
204 _survivors_age_table(true) | |
205 | |
201 { | 206 { |
202 _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime()); | 207 _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime()); |
203 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0; | 208 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0; |
204 | 209 |
205 _par_last_ext_root_scan_times_ms = new double[_parallel_gc_threads]; | 210 _par_last_ext_root_scan_times_ms = new double[_parallel_gc_threads]; |
270 _concurrent_mark_init_times_ms->add(0.05); | 275 _concurrent_mark_init_times_ms->add(0.05); |
271 _concurrent_mark_remark_times_ms->add(0.05); | 276 _concurrent_mark_remark_times_ms->add(0.05); |
272 _concurrent_mark_cleanup_times_ms->add(0.20); | 277 _concurrent_mark_cleanup_times_ms->add(0.20); |
273 _tenuring_threshold = MaxTenuringThreshold; | 278 _tenuring_threshold = MaxTenuringThreshold; |
274 | 279 |
280 if (G1UseSurvivorSpace) { | |
281 // if G1FixedSurvivorSpaceSize is 0 which means the size is not | |
282 // fixed, then _max_survivor_regions will be calculated at | |
283 // calculate_young_list_target_config diring initialization | |
284 _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes; | |
285 } else { | |
286 _max_survivor_regions = 0; | |
287 } | |
288 | |
275 initialize_all(); | 289 initialize_all(); |
276 } | 290 } |
277 | 291 |
278 // Increment "i", mod "len" | 292 // Increment "i", mod "len" |
279 static void inc_mod(int& i, int len) { | 293 static void inc_mod(int& i, int len) { |
298 } | 312 } |
299 if (UseConcMarkSweepGC) { | 313 if (UseConcMarkSweepGC) { |
300 vm_exit_during_initialization("-XX:+UseG1GC is incompatible with " | 314 vm_exit_during_initialization("-XX:+UseG1GC is incompatible with " |
301 "-XX:+UseConcMarkSweepGC."); | 315 "-XX:+UseConcMarkSweepGC."); |
302 } | 316 } |
317 | |
318 initialize_gc_policy_counters(); | |
303 | 319 |
304 if (G1Gen) { | 320 if (G1Gen) { |
305 _in_young_gc_mode = true; | 321 _in_young_gc_mode = true; |
306 | 322 |
307 if (G1YoungGenSize == 0) { | 323 if (G1YoungGenSize == 0) { |
318 calculate_young_list_target_config(); | 334 calculate_young_list_target_config(); |
319 } else { | 335 } else { |
320 _young_list_fixed_length = 0; | 336 _young_list_fixed_length = 0; |
321 _in_young_gc_mode = false; | 337 _in_young_gc_mode = false; |
322 } | 338 } |
339 } | |
340 | |
341 // Create the jstat counters for the policy. | |
342 void G1CollectorPolicy::initialize_gc_policy_counters() | |
343 { | |
344 _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 2 + G1Gen); | |
323 } | 345 } |
324 | 346 |
325 void G1CollectorPolicy::calculate_young_list_min_length() { | 347 void G1CollectorPolicy::calculate_young_list_min_length() { |
326 _young_list_min_length = 0; | 348 _young_list_min_length = 0; |
327 | 349 |
350 _young_list_target_length = MAX2(_young_list_target_length, (size_t)1); | 372 _young_list_target_length = MAX2(_young_list_target_length, (size_t)1); |
351 size_t so_length = calculate_optimal_so_length(_young_list_target_length); | 373 size_t so_length = calculate_optimal_so_length(_young_list_target_length); |
352 guarantee( so_length < _young_list_target_length, "invariant" ); | 374 guarantee( so_length < _young_list_target_length, "invariant" ); |
353 _young_list_so_prefix_length = so_length; | 375 _young_list_so_prefix_length = so_length; |
354 } | 376 } |
377 calculate_survivors_policy(); | |
355 } | 378 } |
356 | 379 |
357 // This method calculate the optimal scan-only set for a fixed young | 380 // This method calculate the optimal scan-only set for a fixed young |
358 // gen size. I couldn't work out how to reuse the more elaborate one, | 381 // gen size. I couldn't work out how to reuse the more elaborate one, |
359 // i.e. calculate_young_list_target_config(rs_length), as the loops are | 382 // i.e. calculate_young_list_target_config(rs_length), as the loops are |
445 size_t reserve_regions = | 468 size_t reserve_regions = |
446 (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0); | 469 (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0); |
447 | 470 |
448 if (full_young_gcs() && _free_regions_at_end_of_collection > 0) { | 471 if (full_young_gcs() && _free_regions_at_end_of_collection > 0) { |
449 // we are in fully-young mode and there are free regions in the heap | 472 // we are in fully-young mode and there are free regions in the heap |
473 | |
474 double survivor_regions_evac_time = | |
475 predict_survivor_regions_evac_time(); | |
450 | 476 |
451 size_t min_so_length = 0; | 477 size_t min_so_length = 0; |
452 size_t max_so_length = 0; | 478 size_t max_so_length = 0; |
453 | 479 |
454 if (G1UseScanOnlyPrefix) { | 480 if (G1UseScanOnlyPrefix) { |
495 scanned_cards = predict_young_card_num(adj_rs_lengths); | 521 scanned_cards = predict_young_card_num(adj_rs_lengths); |
496 else | 522 else |
497 scanned_cards = predict_non_young_card_num(adj_rs_lengths); | 523 scanned_cards = predict_non_young_card_num(adj_rs_lengths); |
498 // calculate this once, so that we don't have to recalculate it in | 524 // calculate this once, so that we don't have to recalculate it in |
499 // the innermost loop | 525 // the innermost loop |
500 double base_time_ms = predict_base_elapsed_time_ms(pending_cards, | 526 double base_time_ms = predict_base_elapsed_time_ms(pending_cards, scanned_cards) |
501 scanned_cards); | 527 + survivor_regions_evac_time; |
502 | |
503 // the result | 528 // the result |
504 size_t final_young_length = 0; | 529 size_t final_young_length = 0; |
505 size_t final_so_length = 0; | 530 size_t final_so_length = 0; |
506 double final_gc_eff = 0.0; | 531 double final_gc_eff = 0.0; |
507 // we'll also keep track of how many times we go into the inner loop | 532 // we'll also keep track of how many times we go into the inner loop |
546 } | 571 } |
547 | 572 |
548 bool done = false; | 573 bool done = false; |
549 // this is the outermost loop | 574 // this is the outermost loop |
550 while (!done) { | 575 while (!done) { |
551 #if 0 | 576 #ifdef TRACE_CALC_YOUNG_CONFIG |
552 // leave this in for debugging, just in case | 577 // leave this in for debugging, just in case |
553 gclog_or_tty->print_cr("searching between " SIZE_FORMAT " and " SIZE_FORMAT | 578 gclog_or_tty->print_cr("searching between " SIZE_FORMAT " and " SIZE_FORMAT |
554 ", incr " SIZE_FORMAT ", pass %s", | 579 ", incr " SIZE_FORMAT ", pass %s", |
555 from_so_length, to_so_length, so_length_incr, | 580 from_so_length, to_so_length, so_length_incr, |
556 (pass == pass_type_coarse) ? "coarse" : | 581 (pass == pass_type_coarse) ? "coarse" : |
557 (pass == pass_type_fine) ? "fine" : "final"); | 582 (pass == pass_type_fine) ? "fine" : "final"); |
558 #endif // 0 | 583 #endif // TRACE_CALC_YOUNG_CONFIG |
559 | 584 |
560 size_t so_length = from_so_length; | 585 size_t so_length = from_so_length; |
561 size_t init_free_regions = | 586 size_t init_free_regions = |
562 MAX2((size_t)0, | 587 MAX2((size_t)0, |
563 _free_regions_at_end_of_collection + | 588 _free_regions_at_end_of_collection + |
649 // S-O lengths around that config with a fine increment. | 674 // S-O lengths around that config with a fine increment. |
650 | 675 |
651 guarantee( so_length_incr == so_coarse_increments, "invariant" ); | 676 guarantee( so_length_incr == so_coarse_increments, "invariant" ); |
652 guarantee( final_so_length >= min_so_length, "invariant" ); | 677 guarantee( final_so_length >= min_so_length, "invariant" ); |
653 | 678 |
654 #if 0 | 679 #ifdef TRACE_CALC_YOUNG_CONFIG |
655 // leave this in for debugging, just in case | 680 // leave this in for debugging, just in case |
656 gclog_or_tty->print_cr(" coarse pass: SO length " SIZE_FORMAT, | 681 gclog_or_tty->print_cr(" coarse pass: SO length " SIZE_FORMAT, |
657 final_so_length); | 682 final_so_length); |
658 #endif // 0 | 683 #endif // TRACE_CALC_YOUNG_CONFIG |
659 | 684 |
660 from_so_length = | 685 from_so_length = |
661 (final_so_length - min_so_length > so_coarse_increments) ? | 686 (final_so_length - min_so_length > so_coarse_increments) ? |
662 final_so_length - so_coarse_increments + 1 : min_so_length; | 687 final_so_length - so_coarse_increments + 1 : min_so_length; |
663 to_so_length = | 688 to_so_length = |
685 } else { | 710 } else { |
686 // we'll go around once more, setting the S-O length to 95% | 711 // we'll go around once more, setting the S-O length to 95% |
687 // of the optimal | 712 // of the optimal |
688 size_t new_so_length = 950 * final_so_length / 1000; | 713 size_t new_so_length = 950 * final_so_length / 1000; |
689 | 714 |
690 #if 0 | 715 #ifdef TRACE_CALC_YOUNG_CONFIG |
691 // leave this in for debugging, just in case | 716 // leave this in for debugging, just in case |
692 gclog_or_tty->print_cr(" fine pass: SO length " SIZE_FORMAT | 717 gclog_or_tty->print_cr(" fine pass: SO length " SIZE_FORMAT |
693 ", setting it to " SIZE_FORMAT, | 718 ", setting it to " SIZE_FORMAT, |
694 final_so_length, new_so_length); | 719 final_so_length, new_so_length); |
695 #endif // 0 | 720 #endif // TRACE_CALC_YOUNG_CONFIG |
696 | 721 |
697 from_so_length = new_so_length; | 722 from_so_length = new_so_length; |
698 to_so_length = new_so_length; | 723 to_so_length = new_so_length; |
699 fine_so_length = final_so_length; | 724 fine_so_length = final_so_length; |
700 | 725 |
717 | 742 |
718 // we now go around the outermost loop | 743 // we now go around the outermost loop |
719 } | 744 } |
720 | 745 |
721 // we should have at least one region in the target young length | 746 // we should have at least one region in the target young length |
722 _young_list_target_length = MAX2((size_t) 1, final_young_length); | 747 _young_list_target_length = |
748 MAX2((size_t) 1, final_young_length + _recorded_survivor_regions); | |
723 if (final_so_length >= final_young_length) | 749 if (final_so_length >= final_young_length) |
724 // and we need to ensure that the S-O length is not greater than | 750 // and we need to ensure that the S-O length is not greater than |
725 // the target young length (this is being a bit careful) | 751 // the target young length (this is being a bit careful) |
726 final_so_length = 0; | 752 final_so_length = 0; |
727 _young_list_so_prefix_length = final_so_length; | 753 _young_list_so_prefix_length = final_so_length; |
732 // right now, I assume that we'll print it when we need it; we | 758 // right now, I assume that we'll print it when we need it; we |
733 // should really adde it to the breakdown of a pause | 759 // should really adde it to the breakdown of a pause |
734 double end_time_sec = os::elapsedTime(); | 760 double end_time_sec = os::elapsedTime(); |
735 double elapsed_time_ms = (end_time_sec - start_time_sec) * 1000.0; | 761 double elapsed_time_ms = (end_time_sec - start_time_sec) * 1000.0; |
736 | 762 |
737 #if 0 | 763 #ifdef TRACE_CALC_YOUNG_CONFIG |
738 // leave this in for debugging, just in case | 764 // leave this in for debugging, just in case |
739 gclog_or_tty->print_cr("target = %1.1lf ms, young = " SIZE_FORMAT | 765 gclog_or_tty->print_cr("target = %1.1lf ms, young = " SIZE_FORMAT |
740 ", SO = " SIZE_FORMAT ", " | 766 ", SO = " SIZE_FORMAT ", " |
741 "elapsed %1.2lf ms, calcs: " SIZE_FORMAT " (%s%s) " | 767 "elapsed %1.2lf ms, calcs: " SIZE_FORMAT " (%s%s) " |
742 SIZE_FORMAT SIZE_FORMAT, | 768 SIZE_FORMAT SIZE_FORMAT, |
745 _young_list_so_prefix_length, | 771 _young_list_so_prefix_length, |
746 elapsed_time_ms, | 772 elapsed_time_ms, |
747 calculations, | 773 calculations, |
748 full_young_gcs() ? "full" : "partial", | 774 full_young_gcs() ? "full" : "partial", |
749 should_initiate_conc_mark() ? " i-m" : "", | 775 should_initiate_conc_mark() ? " i-m" : "", |
750 in_marking_window(), | 776 _in_marking_window, |
751 in_marking_window_im()); | 777 _in_marking_window_im); |
752 #endif // 0 | 778 #endif // TRACE_CALC_YOUNG_CONFIG |
753 | 779 |
754 if (_young_list_target_length < _young_list_min_length) { | 780 if (_young_list_target_length < _young_list_min_length) { |
755 // bummer; this means that, if we do a pause when the optimal | 781 // bummer; this means that, if we do a pause when the optimal |
756 // config dictates, we'll violate the pause spacing target (the | 782 // config dictates, we'll violate the pause spacing target (the |
757 // min length was calculate based on the application's current | 783 // min length was calculate based on the application's current |
766 if (!_in_marking_window && !_last_full_young_gc) | 792 if (!_in_marking_window && !_last_full_young_gc) |
767 // but we can still try to see whether we can find an optimal | 793 // but we can still try to see whether we can find an optimal |
768 // S-O length | 794 // S-O length |
769 so_length = calculate_optimal_so_length(_young_list_min_length); | 795 so_length = calculate_optimal_so_length(_young_list_min_length); |
770 | 796 |
771 #if 0 | 797 #ifdef TRACE_CALC_YOUNG_CONFIG |
772 // leave this in for debugging, just in case | 798 // leave this in for debugging, just in case |
773 gclog_or_tty->print_cr("adjusted target length from " | 799 gclog_or_tty->print_cr("adjusted target length from " |
774 SIZE_FORMAT " to " SIZE_FORMAT | 800 SIZE_FORMAT " to " SIZE_FORMAT |
775 ", SO " SIZE_FORMAT, | 801 ", SO " SIZE_FORMAT, |
776 _young_list_target_length, _young_list_min_length, | 802 _young_list_target_length, _young_list_min_length, |
777 so_length); | 803 so_length); |
778 #endif // 0 | 804 #endif // TRACE_CALC_YOUNG_CONFIG |
779 | 805 |
780 _young_list_target_length = | 806 _young_list_target_length = |
781 MAX2(_young_list_min_length, (size_t)1); | 807 MAX2(_young_list_min_length, (size_t)1); |
782 _young_list_so_prefix_length = so_length; | 808 _young_list_so_prefix_length = so_length; |
783 } | 809 } |
784 } else { | 810 } else { |
785 // we are in a partially-young mode or we've run out of regions (due | 811 // we are in a partially-young mode or we've run out of regions (due |
786 // to evacuation failure) | 812 // to evacuation failure) |
787 | 813 |
788 #if 0 | 814 #ifdef TRACE_CALC_YOUNG_CONFIG |
789 // leave this in for debugging, just in case | 815 // leave this in for debugging, just in case |
790 gclog_or_tty->print_cr("(partial) setting target to " SIZE_FORMAT | 816 gclog_or_tty->print_cr("(partial) setting target to " SIZE_FORMAT |
791 ", SO " SIZE_FORMAT, | 817 ", SO " SIZE_FORMAT, |
792 _young_list_min_length, 0); | 818 _young_list_min_length, 0); |
793 #endif // 0 | 819 #endif // TRACE_CALC_YOUNG_CONFIG |
794 | 820 |
795 // we'll do the pause as soon as possible and with no S-O prefix | 821 // we'll do the pause as soon as possible and with no S-O prefix |
796 // (see above for the reasons behind the latter) | 822 // (see above for the reasons behind the latter) |
797 _young_list_target_length = | 823 _young_list_target_length = |
798 MAX2(_young_list_min_length, (size_t) 1); | 824 MAX2(_young_list_min_length, (size_t) 1); |
882 *ret_gc_eff = gc_eff; | 908 *ret_gc_eff = gc_eff; |
883 | 909 |
884 return true; | 910 return true; |
885 } | 911 } |
886 | 912 |
913 double G1CollectorPolicy::predict_survivor_regions_evac_time() { | |
914 double survivor_regions_evac_time = 0.0; | |
915 for (HeapRegion * r = _recorded_survivor_head; | |
916 r != NULL && r != _recorded_survivor_tail->get_next_young_region(); | |
917 r = r->get_next_young_region()) { | |
918 survivor_regions_evac_time += predict_region_elapsed_time_ms(r, true); | |
919 } | |
920 return survivor_regions_evac_time; | |
921 } | |
922 | |
887 void G1CollectorPolicy::check_prediction_validity() { | 923 void G1CollectorPolicy::check_prediction_validity() { |
888 guarantee( adaptive_young_list_length(), "should not call this otherwise" ); | 924 guarantee( adaptive_young_list_length(), "should not call this otherwise" ); |
889 | 925 |
890 size_t rs_lengths = _g1->young_list_sampled_rs_lengths(); | 926 size_t rs_lengths = _g1->young_list_sampled_rs_lengths(); |
891 if (rs_lengths > _rs_lengths_prediction) { | 927 if (rs_lengths > _rs_lengths_prediction) { |
993 | 1029 |
994 _short_lived_surv_rate_group->record_scan_only_prefix(0); | 1030 _short_lived_surv_rate_group->record_scan_only_prefix(0); |
995 _short_lived_surv_rate_group->start_adding_regions(); | 1031 _short_lived_surv_rate_group->start_adding_regions(); |
996 // also call this on any additional surv rate groups | 1032 // also call this on any additional surv rate groups |
997 | 1033 |
1034 record_survivor_regions(0, NULL, NULL); | |
1035 | |
998 _prev_region_num_young = _region_num_young; | 1036 _prev_region_num_young = _region_num_young; |
999 _prev_region_num_tenured = _region_num_tenured; | 1037 _prev_region_num_tenured = _region_num_tenured; |
1000 | 1038 |
1001 _free_regions_at_end_of_collection = _g1->free_regions(); | 1039 _free_regions_at_end_of_collection = _g1->free_regions(); |
1002 _scan_only_regions_at_end_of_collection = 0; | 1040 _scan_only_regions_at_end_of_collection = 0; |
1041 // Reset survivors SurvRateGroup. | |
1042 _survivor_surv_rate_group->reset(); | |
1003 calculate_young_list_min_length(); | 1043 calculate_young_list_min_length(); |
1004 calculate_young_list_target_config(); | 1044 calculate_young_list_target_config(); |
1005 } | 1045 } |
1006 | 1046 |
1007 void G1CollectorPolicy::record_pop_compute_rc_start() { | 1047 void G1CollectorPolicy::record_pop_compute_rc_start() { |
1101 // do that for any other surv rate groups | 1141 // do that for any other surv rate groups |
1102 _short_lived_surv_rate_group->stop_adding_regions(); | 1142 _short_lived_surv_rate_group->stop_adding_regions(); |
1103 size_t short_lived_so_length = _young_list_so_prefix_length; | 1143 size_t short_lived_so_length = _young_list_so_prefix_length; |
1104 _short_lived_surv_rate_group->record_scan_only_prefix(short_lived_so_length); | 1144 _short_lived_surv_rate_group->record_scan_only_prefix(short_lived_so_length); |
1105 tag_scan_only(short_lived_so_length); | 1145 tag_scan_only(short_lived_so_length); |
1146 | |
1147 if (G1UseSurvivorSpace) { | |
1148 _survivors_age_table.clear(); | |
1149 } | |
1106 | 1150 |
1107 assert( verify_young_ages(), "region age verification" ); | 1151 assert( verify_young_ages(), "region age verification" ); |
1108 } | 1152 } |
1109 | 1153 |
1110 void G1CollectorPolicy::tag_scan_only(size_t short_lived_scan_only_length) { | 1154 void G1CollectorPolicy::tag_scan_only(size_t short_lived_scan_only_length) { |
1963 calculate_young_list_target_config(); | 2007 calculate_young_list_target_config(); |
1964 | 2008 |
1965 // </NEW PREDICTION> | 2009 // </NEW PREDICTION> |
1966 | 2010 |
1967 _target_pause_time_ms = -1.0; | 2011 _target_pause_time_ms = -1.0; |
1968 | |
1969 // TODO: calculate tenuring threshold | |
1970 _tenuring_threshold = MaxTenuringThreshold; | |
1971 } | 2012 } |
1972 | 2013 |
1973 // <NEW PREDICTION> | 2014 // <NEW PREDICTION> |
1974 | 2015 |
1975 double | 2016 double |
2056 bytes_to_copy = hr->max_live_bytes(); | 2097 bytes_to_copy = hr->max_live_bytes(); |
2057 else { | 2098 else { |
2058 guarantee( hr->is_young() && hr->age_in_surv_rate_group() != -1, | 2099 guarantee( hr->is_young() && hr->age_in_surv_rate_group() != -1, |
2059 "invariant" ); | 2100 "invariant" ); |
2060 int age = hr->age_in_surv_rate_group(); | 2101 int age = hr->age_in_surv_rate_group(); |
2061 double yg_surv_rate = predict_yg_surv_rate(age); | 2102 double yg_surv_rate = predict_yg_surv_rate(age, hr->surv_rate_group()); |
2062 bytes_to_copy = (size_t) ((double) hr->used() * yg_surv_rate); | 2103 bytes_to_copy = (size_t) ((double) hr->used() * yg_surv_rate); |
2063 } | 2104 } |
2064 | 2105 |
2065 return bytes_to_copy; | 2106 return bytes_to_copy; |
2066 } | 2107 } |
2089 } else { | 2130 } else { |
2090 ++_recorded_non_young_regions; | 2131 ++_recorded_non_young_regions; |
2091 } | 2132 } |
2092 #if PREDICTIONS_VERBOSE | 2133 #if PREDICTIONS_VERBOSE |
2093 if (young) { | 2134 if (young) { |
2094 _recorded_young_bytes += hr->asSpace()->used(); | 2135 _recorded_young_bytes += hr->used(); |
2095 } else { | 2136 } else { |
2096 _recorded_marked_bytes += hr->max_live_bytes(); | 2137 _recorded_marked_bytes += hr->max_live_bytes(); |
2097 } | 2138 } |
2098 _predicted_bytes_to_copy += predict_bytes_to_copy(hr); | 2139 _predicted_bytes_to_copy += predict_bytes_to_copy(hr); |
2099 #endif // PREDICTIONS_VERBOSE | 2140 #endif // PREDICTIONS_VERBOSE |
2116 _predicted_cards_scanned += predict_young_card_num(_predicted_rs_lengths); | 2157 _predicted_cards_scanned += predict_young_card_num(_predicted_rs_lengths); |
2117 else | 2158 else |
2118 _predicted_cards_scanned += | 2159 _predicted_cards_scanned += |
2119 predict_non_young_card_num(_predicted_rs_lengths); | 2160 predict_non_young_card_num(_predicted_rs_lengths); |
2120 _recorded_region_num = _recorded_young_regions + _recorded_non_young_regions; | 2161 _recorded_region_num = _recorded_young_regions + _recorded_non_young_regions; |
2121 | |
2122 _predicted_young_survival_ratio = 0.0; | |
2123 for (int i = 0; i < _recorded_young_regions; ++i) | |
2124 _predicted_young_survival_ratio += predict_yg_surv_rate(i); | |
2125 _predicted_young_survival_ratio /= (double) _recorded_young_regions; | |
2126 | 2162 |
2127 _predicted_scan_only_scan_time_ms = | 2163 _predicted_scan_only_scan_time_ms = |
2128 predict_scan_only_time_ms(_recorded_scan_only_regions); | 2164 predict_scan_only_time_ms(_recorded_scan_only_regions); |
2129 _predicted_rs_update_time_ms = | 2165 _predicted_rs_update_time_ms = |
2130 predict_rs_update_time_ms(_g1->pending_card_num()); | 2166 predict_rs_update_time_ms(_g1->pending_card_num()); |
2671 bool | 2707 bool |
2672 G1CollectorPolicy::should_add_next_region_to_young_list() { | 2708 G1CollectorPolicy::should_add_next_region_to_young_list() { |
2673 assert(in_young_gc_mode(), "should be in young GC mode"); | 2709 assert(in_young_gc_mode(), "should be in young GC mode"); |
2674 bool ret; | 2710 bool ret; |
2675 size_t young_list_length = _g1->young_list_length(); | 2711 size_t young_list_length = _g1->young_list_length(); |
2676 | 2712 size_t young_list_max_length = _young_list_target_length; |
2677 if (young_list_length < _young_list_target_length) { | 2713 if (G1FixedEdenSize) { |
2714 young_list_max_length -= _max_survivor_regions; | |
2715 } | |
2716 if (young_list_length < young_list_max_length) { | |
2678 ret = true; | 2717 ret = true; |
2679 ++_region_num_young; | 2718 ++_region_num_young; |
2680 } else { | 2719 } else { |
2681 ret = false; | 2720 ret = false; |
2682 ++_region_num_tenured; | 2721 ++_region_num_tenured; |
2708 conc_overhead, _mmu_tracker->max_gc_time()); | 2747 conc_overhead, _mmu_tracker->max_gc_time()); |
2709 #endif | 2748 #endif |
2710 } | 2749 } |
2711 | 2750 |
2712 | 2751 |
2713 uint G1CollectorPolicy::max_regions(int purpose) { | 2752 size_t G1CollectorPolicy::max_regions(int purpose) { |
2714 switch (purpose) { | 2753 switch (purpose) { |
2715 case GCAllocForSurvived: | 2754 case GCAllocForSurvived: |
2716 return G1MaxSurvivorRegions; | 2755 return _max_survivor_regions; |
2717 case GCAllocForTenured: | 2756 case GCAllocForTenured: |
2718 return UINT_MAX; | 2757 return REGIONS_UNLIMITED; |
2719 default: | 2758 default: |
2720 return UINT_MAX; | 2759 ShouldNotReachHere(); |
2760 return REGIONS_UNLIMITED; | |
2721 }; | 2761 }; |
2722 } | 2762 } |
2763 | |
2764 // Calculates survivor space parameters. | |
2765 void G1CollectorPolicy::calculate_survivors_policy() | |
2766 { | |
2767 if (!G1UseSurvivorSpace) { | |
2768 return; | |
2769 } | |
2770 if (G1FixedSurvivorSpaceSize == 0) { | |
2771 _max_survivor_regions = _young_list_target_length / SurvivorRatio; | |
2772 } else { | |
2773 _max_survivor_regions = G1FixedSurvivorSpaceSize; | |
2774 } | |
2775 | |
2776 if (G1FixedTenuringThreshold) { | |
2777 _tenuring_threshold = MaxTenuringThreshold; | |
2778 } else { | |
2779 _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( | |
2780 HeapRegion::GrainWords * _max_survivor_regions); | |
2781 } | |
2782 } | |
2783 | |
2723 | 2784 |
2724 void | 2785 void |
2725 G1CollectorPolicy_BestRegionsFirst:: | 2786 G1CollectorPolicy_BestRegionsFirst:: |
2726 set_single_region_collection_set(HeapRegion* hr) { | 2787 set_single_region_collection_set(HeapRegion* hr) { |
2727 G1CollectorPolicy::set_single_region_collection_set(hr); | 2788 G1CollectorPolicy::set_single_region_collection_set(hr); |
2741 size_t used = _g1->used(); | 2802 size_t used = _g1->used(); |
2742 | 2803 |
2743 double max_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; | 2804 double max_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; |
2744 | 2805 |
2745 size_t young_list_length = _g1->young_list_length(); | 2806 size_t young_list_length = _g1->young_list_length(); |
2746 bool reached_target_length = young_list_length >= _young_list_target_length; | 2807 size_t young_list_max_length = _young_list_target_length; |
2808 if (G1FixedEdenSize) { | |
2809 young_list_max_length -= _max_survivor_regions; | |
2810 } | |
2811 bool reached_target_length = young_list_length >= young_list_max_length; | |
2747 | 2812 |
2748 if (in_young_gc_mode()) { | 2813 if (in_young_gc_mode()) { |
2749 if (reached_target_length) { | 2814 if (reached_target_length) { |
2750 assert( young_list_length > 0 && _g1->young_list_length() > 0, | 2815 assert( young_list_length > 0 && _g1->young_list_length() > 0, |
2751 "invariant" ); | 2816 "invariant" ); |