comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @ 677:96b229c54d1e

6543938: G1: remove the concept of popularity Reviewed-by: iveresov, tonyp
author apetrusenko
date Wed, 25 Mar 2009 13:10:54 -0700
parents 2314b7336582
children 20c6f43950b5
comparison
equal deleted inserted replaced
649:59f139e8a8d1 677:96b229c54d1e
89 _all_stop_world_times_ms(new NumberSeq()), 89 _all_stop_world_times_ms(new NumberSeq()),
90 _all_yield_times_ms(new NumberSeq()), 90 _all_yield_times_ms(new NumberSeq()),
91 91
92 _all_mod_union_times_ms(new NumberSeq()), 92 _all_mod_union_times_ms(new NumberSeq()),
93 93
94 _non_pop_summary(new NonPopSummary()), 94 _summary(new Summary()),
95 _pop_summary(new PopSummary()), 95 _abandoned_summary(new AbandonedSummary()),
96 _non_pop_abandoned_summary(new NonPopAbandonedSummary()),
97 _pop_abandoned_summary(new PopAbandonedSummary()),
98 96
99 _cur_clear_ct_time_ms(0.0), 97 _cur_clear_ct_time_ms(0.0),
100 98
101 _region_num_young(0), 99 _region_num_young(0),
102 _region_num_tenured(0), 100 _region_num_tenured(0),
106 _aux_num(10), 104 _aux_num(10),
107 _all_aux_times_ms(new NumberSeq[_aux_num]), 105 _all_aux_times_ms(new NumberSeq[_aux_num]),
108 _cur_aux_start_times_ms(new double[_aux_num]), 106 _cur_aux_start_times_ms(new double[_aux_num]),
109 _cur_aux_times_ms(new double[_aux_num]), 107 _cur_aux_times_ms(new double[_aux_num]),
110 _cur_aux_times_set(new bool[_aux_num]), 108 _cur_aux_times_set(new bool[_aux_num]),
111
112 _pop_compute_rc_start(0.0),
113 _pop_evac_start(0.0),
114 109
115 _concurrent_mark_init_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), 110 _concurrent_mark_init_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
116 _concurrent_mark_remark_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), 111 _concurrent_mark_remark_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
117 _concurrent_mark_cleanup_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)), 112 _concurrent_mark_cleanup_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
118 113
221 _par_last_scan_new_refs_times_ms = new double[_parallel_gc_threads]; 216 _par_last_scan_new_refs_times_ms = new double[_parallel_gc_threads];
222 217
223 _par_last_obj_copy_times_ms = new double[_parallel_gc_threads]; 218 _par_last_obj_copy_times_ms = new double[_parallel_gc_threads];
224 219
225 _par_last_termination_times_ms = new double[_parallel_gc_threads]; 220 _par_last_termination_times_ms = new double[_parallel_gc_threads];
226
227 // we store the data from the first pass during popularity pauses
228 _pop_par_last_update_rs_start_times_ms = new double[_parallel_gc_threads];
229 _pop_par_last_update_rs_times_ms = new double[_parallel_gc_threads];
230 _pop_par_last_update_rs_processed_buffers = new double[_parallel_gc_threads];
231
232 _pop_par_last_scan_rs_start_times_ms = new double[_parallel_gc_threads];
233 _pop_par_last_scan_rs_times_ms = new double[_parallel_gc_threads];
234
235 _pop_par_last_closure_app_times_ms = new double[_parallel_gc_threads];
236 221
237 // start conservatively 222 // start conservatively
238 _expensive_region_limit_ms = 0.5 * (double) G1MaxPauseTimeMS; 223 _expensive_region_limit_ms = 0.5 * (double) G1MaxPauseTimeMS;
239 224
240 // <NEW PREDICTION> 225 // <NEW PREDICTION>
1045 _survivor_surv_rate_group->reset(); 1030 _survivor_surv_rate_group->reset();
1046 calculate_young_list_min_length(); 1031 calculate_young_list_min_length();
1047 calculate_young_list_target_config(); 1032 calculate_young_list_target_config();
1048 } 1033 }
1049 1034
1050 void G1CollectorPolicy::record_pop_compute_rc_start() {
1051 _pop_compute_rc_start = os::elapsedTime();
1052 }
1053 void G1CollectorPolicy::record_pop_compute_rc_end() {
1054 double ms = (os::elapsedTime() - _pop_compute_rc_start)*1000.0;
1055 _cur_popular_compute_rc_time_ms = ms;
1056 _pop_compute_rc_start = 0.0;
1057 }
1058 void G1CollectorPolicy::record_pop_evac_start() {
1059 _pop_evac_start = os::elapsedTime();
1060 }
1061 void G1CollectorPolicy::record_pop_evac_end() {
1062 double ms = (os::elapsedTime() - _pop_evac_start)*1000.0;
1063 _cur_popular_evac_time_ms = ms;
1064 _pop_evac_start = 0.0;
1065 }
1066
1067 void G1CollectorPolicy::record_before_bytes(size_t bytes) { 1035 void G1CollectorPolicy::record_before_bytes(size_t bytes) {
1068 _bytes_in_to_space_before_gc += bytes; 1036 _bytes_in_to_space_before_gc += bytes;
1069 } 1037 }
1070 1038
1071 void G1CollectorPolicy::record_after_bytes(size_t bytes) { 1039 void G1CollectorPolicy::record_after_bytes(size_t bytes) {
1118 _par_last_scan_rs_start_times_ms[i] = -666.0; 1086 _par_last_scan_rs_start_times_ms[i] = -666.0;
1119 _par_last_scan_rs_times_ms[i] = -666.0; 1087 _par_last_scan_rs_times_ms[i] = -666.0;
1120 _par_last_scan_new_refs_times_ms[i] = -666.0; 1088 _par_last_scan_new_refs_times_ms[i] = -666.0;
1121 _par_last_obj_copy_times_ms[i] = -666.0; 1089 _par_last_obj_copy_times_ms[i] = -666.0;
1122 _par_last_termination_times_ms[i] = -666.0; 1090 _par_last_termination_times_ms[i] = -666.0;
1123
1124 _pop_par_last_update_rs_start_times_ms[i] = -666.0;
1125 _pop_par_last_update_rs_times_ms[i] = -666.0;
1126 _pop_par_last_update_rs_processed_buffers[i] = -666.0;
1127 _pop_par_last_scan_rs_start_times_ms[i] = -666.0;
1128 _pop_par_last_scan_rs_times_ms[i] = -666.0;
1129 _pop_par_last_closure_app_times_ms[i] = -666.0;
1130 } 1091 }
1131 #endif 1092 #endif
1132 1093
1133 for (int i = 0; i < _aux_num; ++i) { 1094 for (int i = 0; i < _aux_num; ++i) {
1134 _cur_aux_times_ms[i] = 0.0; 1095 _cur_aux_times_ms[i] = 0.0;
1181 if (finished_short_lived) 1142 if (finished_short_lived)
1182 return; 1143 return;
1183 } 1144 }
1184 1145
1185 guarantee( false, "we should never reach here" ); 1146 guarantee( false, "we should never reach here" );
1186 }
1187
1188 void G1CollectorPolicy::record_popular_pause_preamble_start() {
1189 _cur_popular_preamble_start_ms = os::elapsedTime() * 1000.0;
1190 }
1191
1192 void G1CollectorPolicy::record_popular_pause_preamble_end() {
1193 _cur_popular_preamble_time_ms =
1194 (os::elapsedTime() * 1000.0) - _cur_popular_preamble_start_ms;
1195
1196 // copy the recorded statistics of the first pass to temporary arrays
1197 for (int i = 0; i < _parallel_gc_threads; ++i) {
1198 _pop_par_last_update_rs_start_times_ms[i] = _par_last_update_rs_start_times_ms[i];
1199 _pop_par_last_update_rs_times_ms[i] = _par_last_update_rs_times_ms[i];
1200 _pop_par_last_update_rs_processed_buffers[i] = _par_last_update_rs_processed_buffers[i];
1201 _pop_par_last_scan_rs_start_times_ms[i] = _par_last_scan_rs_start_times_ms[i];
1202 _pop_par_last_scan_rs_times_ms[i] = _par_last_scan_rs_times_ms[i];
1203 _pop_par_last_closure_app_times_ms[i] = _par_last_obj_copy_times_ms[i];
1204 }
1205 } 1147 }
1206 1148
1207 void G1CollectorPolicy::record_mark_closure_time(double mark_closure_time_ms) { 1149 void G1CollectorPolicy::record_mark_closure_time(double mark_closure_time_ms) {
1208 _mark_closure_time_ms = mark_closure_time_ms; 1150 _mark_closure_time_ms = mark_closure_time_ms;
1209 } 1151 }
1463 } 1405 }
1464 1406
1465 // Anything below that is considered to be zero 1407 // Anything below that is considered to be zero
1466 #define MIN_TIMER_GRANULARITY 0.0000001 1408 #define MIN_TIMER_GRANULARITY 0.0000001
1467 1409
1468 void G1CollectorPolicy::record_collection_pause_end(bool popular, 1410 void G1CollectorPolicy::record_collection_pause_end(bool abandoned) {
1469 bool abandoned) {
1470 double end_time_sec = os::elapsedTime(); 1411 double end_time_sec = os::elapsedTime();
1471 double elapsed_ms = _last_pause_time_ms; 1412 double elapsed_ms = _last_pause_time_ms;
1472 bool parallel = ParallelGCThreads > 0; 1413 bool parallel = ParallelGCThreads > 0;
1473 double evac_ms = (end_time_sec - _cur_G1_strong_roots_end_sec) * 1000.0; 1414 double evac_ms = (end_time_sec - _cur_G1_strong_roots_end_sec) * 1000.0;
1474 size_t rs_size = 1415 size_t rs_size =
1585 if (G1PolicyVerbose > 1) { 1526 if (G1PolicyVerbose > 1) {
1586 gclog_or_tty->print_cr(" Recording collection pause(%d)", _n_pauses); 1527 gclog_or_tty->print_cr(" Recording collection pause(%d)", _n_pauses);
1587 } 1528 }
1588 1529
1589 PauseSummary* summary; 1530 PauseSummary* summary;
1590 if (!abandoned && !popular) 1531 if (abandoned) {
1591 summary = _non_pop_summary; 1532 summary = _abandoned_summary;
1592 else if (!abandoned && popular) 1533 } else {
1593 summary = _pop_summary; 1534 summary = _summary;
1594 else if (abandoned && !popular)
1595 summary = _non_pop_abandoned_summary;
1596 else if (abandoned && popular)
1597 summary = _pop_abandoned_summary;
1598 else
1599 guarantee(false, "should not get here!");
1600
1601 double pop_update_rs_time;
1602 double pop_update_rs_processed_buffers;
1603 double pop_scan_rs_time;
1604 double pop_closure_app_time;
1605 double pop_other_time;
1606
1607 if (popular) {
1608 PopPreambleSummary* preamble_summary = summary->pop_preamble_summary();
1609 guarantee(preamble_summary != NULL, "should not be null!");
1610
1611 pop_update_rs_time = avg_value(_pop_par_last_update_rs_times_ms);
1612 pop_update_rs_processed_buffers =
1613 sum_of_values(_pop_par_last_update_rs_processed_buffers);
1614 pop_scan_rs_time = avg_value(_pop_par_last_scan_rs_times_ms);
1615 pop_closure_app_time = avg_value(_pop_par_last_closure_app_times_ms);
1616 pop_other_time = _cur_popular_preamble_time_ms -
1617 (pop_update_rs_time + pop_scan_rs_time + pop_closure_app_time +
1618 _cur_popular_evac_time_ms);
1619
1620 preamble_summary->record_pop_preamble_time_ms(_cur_popular_preamble_time_ms);
1621 preamble_summary->record_pop_update_rs_time_ms(pop_update_rs_time);
1622 preamble_summary->record_pop_scan_rs_time_ms(pop_scan_rs_time);
1623 preamble_summary->record_pop_closure_app_time_ms(pop_closure_app_time);
1624 preamble_summary->record_pop_evacuation_time_ms(_cur_popular_evac_time_ms);
1625 preamble_summary->record_pop_other_time_ms(pop_other_time);
1626 } 1535 }
1627 1536
1628 double ext_root_scan_time = avg_value(_par_last_ext_root_scan_times_ms); 1537 double ext_root_scan_time = avg_value(_par_last_ext_root_scan_times_ms);
1629 double mark_stack_scan_time = avg_value(_par_last_mark_stack_scan_times_ms); 1538 double mark_stack_scan_time = avg_value(_par_last_mark_stack_scan_times_ms);
1630 double scan_only_time = avg_value(_par_last_scan_only_times_ms); 1539 double scan_only_time = avg_value(_par_last_scan_only_times_ms);
1692 gclog_or_tty->print_cr(" Recent %% gc pause time: %6.2f", 1601 gclog_or_tty->print_cr(" Recent %% gc pause time: %6.2f",
1693 recent_avg_pause_time_ratio() * 100.0); 1602 recent_avg_pause_time_ratio() * 100.0);
1694 } 1603 }
1695 1604
1696 double other_time_ms = elapsed_ms; 1605 double other_time_ms = elapsed_ms;
1697 if (popular)
1698 other_time_ms -= _cur_popular_preamble_time_ms;
1699 1606
1700 if (!abandoned) { 1607 if (!abandoned) {
1701 if (_satb_drain_time_set) 1608 if (_satb_drain_time_set)
1702 other_time_ms -= _cur_satb_drain_time_ms; 1609 other_time_ms -= _cur_satb_drain_time_ms;
1703 1610
1710 scan_rs_time + obj_copy_time; 1617 scan_rs_time + obj_copy_time;
1711 } 1618 }
1712 1619
1713 if (PrintGCDetails) { 1620 if (PrintGCDetails) {
1714 gclog_or_tty->print_cr("%s%s, %1.8lf secs]", 1621 gclog_or_tty->print_cr("%s%s, %1.8lf secs]",
1715 (popular && !abandoned) ? " (popular)" : 1622 abandoned ? " (abandoned)" : "",
1716 (!popular && abandoned) ? " (abandoned)" :
1717 (popular && abandoned) ? " (popular/abandoned)" : "",
1718 (last_pause_included_initial_mark) ? " (initial-mark)" : "", 1623 (last_pause_included_initial_mark) ? " (initial-mark)" : "",
1719 elapsed_ms / 1000.0); 1624 elapsed_ms / 1000.0);
1720 1625
1721 if (!abandoned) { 1626 if (!abandoned) {
1722 if (_satb_drain_time_set) 1627 if (_satb_drain_time_set) {
1723 print_stats(1, "SATB Drain Time", _cur_satb_drain_time_ms); 1628 print_stats(1, "SATB Drain Time", _cur_satb_drain_time_ms);
1724 if (_last_satb_drain_processed_buffers >= 0) 1629 }
1630 if (_last_satb_drain_processed_buffers >= 0) {
1725 print_stats(2, "Processed Buffers", _last_satb_drain_processed_buffers); 1631 print_stats(2, "Processed Buffers", _last_satb_drain_processed_buffers);
1726 } 1632 }
1727 if (popular) 1633 if (parallel) {
1728 print_stats(1, "Popularity Preamble", _cur_popular_preamble_time_ms); 1634 print_stats(1, "Parallel Time", _cur_collection_par_time_ms);
1729 if (parallel) { 1635 print_par_stats(2, "Update RS (Start)", _par_last_update_rs_start_times_ms, false);
1730 if (popular) { 1636 print_par_stats(2, "Update RS", _par_last_update_rs_times_ms);
1731 print_par_stats(2, "Update RS (Start)", _pop_par_last_update_rs_start_times_ms, false);
1732 print_par_stats(2, "Update RS", _pop_par_last_update_rs_times_ms);
1733 if (G1RSBarrierUseQueue) 1637 if (G1RSBarrierUseQueue)
1734 print_par_buffers(3, "Processed Buffers", 1638 print_par_buffers(3, "Processed Buffers",
1735 _pop_par_last_update_rs_processed_buffers, true); 1639 _par_last_update_rs_processed_buffers, true);
1736 print_par_stats(2, "Scan RS", _pop_par_last_scan_rs_times_ms);
1737 print_par_stats(2, "Closure app", _pop_par_last_closure_app_times_ms);
1738 print_stats(2, "Evacuation", _cur_popular_evac_time_ms);
1739 print_stats(2, "Other", pop_other_time);
1740 }
1741 if (!abandoned) {
1742 print_stats(1, "Parallel Time", _cur_collection_par_time_ms);
1743 if (!popular) {
1744 print_par_stats(2, "Update RS (Start)", _par_last_update_rs_start_times_ms, false);
1745 print_par_stats(2, "Update RS", _par_last_update_rs_times_ms);
1746 if (G1RSBarrierUseQueue)
1747 print_par_buffers(3, "Processed Buffers",
1748 _par_last_update_rs_processed_buffers, true);
1749 }
1750 print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms); 1640 print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms);
1751 print_par_stats(2, "Mark Stack Scanning", _par_last_mark_stack_scan_times_ms); 1641 print_par_stats(2, "Mark Stack Scanning", _par_last_mark_stack_scan_times_ms);
1752 print_par_stats(2, "Scan-Only Scanning", _par_last_scan_only_times_ms); 1642 print_par_stats(2, "Scan-Only Scanning", _par_last_scan_only_times_ms);
1753 print_par_buffers(3, "Scan-Only Regions", 1643 print_par_buffers(3, "Scan-Only Regions",
1754 _par_last_scan_only_regions_scanned, true); 1644 _par_last_scan_only_regions_scanned, true);
1755 print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms); 1645 print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms);
1756 print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms); 1646 print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms);
1757 print_par_stats(2, "Termination", _par_last_termination_times_ms); 1647 print_par_stats(2, "Termination", _par_last_termination_times_ms);
1758 print_stats(2, "Other", parallel_other_time); 1648 print_stats(2, "Other", parallel_other_time);
1759 print_stats(1, "Clear CT", _cur_clear_ct_time_ms); 1649 print_stats(1, "Clear CT", _cur_clear_ct_time_ms);
1760 } 1650 } else {
1761 } else { 1651 print_stats(1, "Update RS", update_rs_time);
1762 if (popular) {
1763 print_stats(2, "Update RS", pop_update_rs_time);
1764 if (G1RSBarrierUseQueue) 1652 if (G1RSBarrierUseQueue)
1765 print_stats(3, "Processed Buffers", 1653 print_stats(2, "Processed Buffers",
1766 (int)pop_update_rs_processed_buffers); 1654 (int)update_rs_processed_buffers);
1767 print_stats(2, "Scan RS", pop_scan_rs_time);
1768 print_stats(2, "Closure App", pop_closure_app_time);
1769 print_stats(2, "Evacuation", _cur_popular_evac_time_ms);
1770 print_stats(2, "Other", pop_other_time);
1771 }
1772 if (!abandoned) {
1773 if (!popular) {
1774 print_stats(1, "Update RS", update_rs_time);
1775 if (G1RSBarrierUseQueue)
1776 print_stats(2, "Processed Buffers",
1777 (int)update_rs_processed_buffers);
1778 }
1779 print_stats(1, "Ext Root Scanning", ext_root_scan_time); 1655 print_stats(1, "Ext Root Scanning", ext_root_scan_time);
1780 print_stats(1, "Mark Stack Scanning", mark_stack_scan_time); 1656 print_stats(1, "Mark Stack Scanning", mark_stack_scan_time);
1781 print_stats(1, "Scan-Only Scanning", scan_only_time); 1657 print_stats(1, "Scan-Only Scanning", scan_only_time);
1782 print_stats(1, "Scan RS", scan_rs_time); 1658 print_stats(1, "Scan RS", scan_rs_time);
1783 print_stats(1, "Object Copying", obj_copy_time); 1659 print_stats(1, "Object Copying", obj_copy_time);
1853 _short_lived_surv_rate_group->start_adding_regions(); 1729 _short_lived_surv_rate_group->start_adding_regions();
1854 // do that for any other surv rate groupsx 1730 // do that for any other surv rate groupsx
1855 1731
1856 // <NEW PREDICTION> 1732 // <NEW PREDICTION>
1857 1733
1858 if (!popular && update_stats) { 1734 if (update_stats) {
1859 double pause_time_ms = elapsed_ms; 1735 double pause_time_ms = elapsed_ms;
1860 1736
1861 size_t diff = 0; 1737 size_t diff = 0;
1862 if (_max_pending_cards >= _pending_cards) 1738 if (_max_pending_cards >= _pending_cards)
1863 diff = _max_pending_cards - _pending_cards; 1739 diff = _max_pending_cards - _pending_cards;
2452 } 2328 }
2453 2329
2454 void G1CollectorPolicy::print_summary(PauseSummary* summary) const { 2330 void G1CollectorPolicy::print_summary(PauseSummary* summary) const {
2455 bool parallel = ParallelGCThreads > 0; 2331 bool parallel = ParallelGCThreads > 0;
2456 MainBodySummary* body_summary = summary->main_body_summary(); 2332 MainBodySummary* body_summary = summary->main_body_summary();
2457 PopPreambleSummary* preamble_summary = summary->pop_preamble_summary();
2458
2459 if (summary->get_total_seq()->num() > 0) { 2333 if (summary->get_total_seq()->num() > 0) {
2460 print_summary_sd(0, 2334 print_summary_sd(0, "Evacuation Pauses", summary->get_total_seq());
2461 (preamble_summary == NULL) ? "Non-Popular Pauses" :
2462 "Popular Pauses",
2463 summary->get_total_seq());
2464 if (preamble_summary != NULL) {
2465 print_summary(1, "Popularity Preamble",
2466 preamble_summary->get_pop_preamble_seq());
2467 print_summary(2, "Update RS", preamble_summary->get_pop_update_rs_seq());
2468 print_summary(2, "Scan RS", preamble_summary->get_pop_scan_rs_seq());
2469 print_summary(2, "Closure App",
2470 preamble_summary->get_pop_closure_app_seq());
2471 print_summary(2, "Evacuation",
2472 preamble_summary->get_pop_evacuation_seq());
2473 print_summary(2, "Other", preamble_summary->get_pop_other_seq());
2474 {
2475 NumberSeq* other_parts[] = {
2476 preamble_summary->get_pop_update_rs_seq(),
2477 preamble_summary->get_pop_scan_rs_seq(),
2478 preamble_summary->get_pop_closure_app_seq(),
2479 preamble_summary->get_pop_evacuation_seq()
2480 };
2481 NumberSeq calc_other_times_ms(preamble_summary->get_pop_preamble_seq(),
2482 4, other_parts);
2483 check_other_times(2, preamble_summary->get_pop_other_seq(),
2484 &calc_other_times_ms);
2485 }
2486 }
2487 if (body_summary != NULL) { 2335 if (body_summary != NULL) {
2488 print_summary(1, "SATB Drain", body_summary->get_satb_drain_seq()); 2336 print_summary(1, "SATB Drain", body_summary->get_satb_drain_seq());
2489 if (parallel) { 2337 if (parallel) {
2490 print_summary(1, "Parallel Time", body_summary->get_parallel_seq()); 2338 print_summary(1, "Parallel Time", body_summary->get_parallel_seq());
2491 print_summary(2, "Update RS", body_summary->get_update_rs_seq()); 2339 print_summary(2, "Update RS", body_summary->get_update_rs_seq());
2535 // not abandoned 2383 // not abandoned
2536 if (parallel) { 2384 if (parallel) {
2537 // parallel 2385 // parallel
2538 NumberSeq* other_parts[] = { 2386 NumberSeq* other_parts[] = {
2539 body_summary->get_satb_drain_seq(), 2387 body_summary->get_satb_drain_seq(),
2540 (preamble_summary == NULL) ? NULL :
2541 preamble_summary->get_pop_preamble_seq(),
2542 body_summary->get_parallel_seq(), 2388 body_summary->get_parallel_seq(),
2543 body_summary->get_clear_ct_seq() 2389 body_summary->get_clear_ct_seq()
2544 }; 2390 };
2545 calc_other_times_ms = NumberSeq (summary->get_total_seq(), 2391 calc_other_times_ms = NumberSeq(summary->get_total_seq(),
2546 4, other_parts); 2392 3, other_parts);
2547 } else { 2393 } else {
2548 // serial 2394 // serial
2549 NumberSeq* other_parts[] = { 2395 NumberSeq* other_parts[] = {
2550 body_summary->get_satb_drain_seq(), 2396 body_summary->get_satb_drain_seq(),
2551 (preamble_summary == NULL) ? NULL :
2552 preamble_summary->get_pop_preamble_seq(),
2553 body_summary->get_update_rs_seq(), 2397 body_summary->get_update_rs_seq(),
2554 body_summary->get_ext_root_scan_seq(), 2398 body_summary->get_ext_root_scan_seq(),
2555 body_summary->get_mark_stack_scan_seq(), 2399 body_summary->get_mark_stack_scan_seq(),
2556 body_summary->get_scan_only_seq(), 2400 body_summary->get_scan_only_seq(),
2557 body_summary->get_scan_rs_seq(), 2401 body_summary->get_scan_rs_seq(),
2558 body_summary->get_obj_copy_seq() 2402 body_summary->get_obj_copy_seq()
2559 }; 2403 };
2560 calc_other_times_ms = NumberSeq(summary->get_total_seq(), 2404 calc_other_times_ms = NumberSeq(summary->get_total_seq(),
2561 8, other_parts); 2405 7, other_parts);
2562 } 2406 }
2563 } else { 2407 } else {
2564 // abandoned 2408 // abandoned
2565 NumberSeq* other_parts[] = { 2409 calc_other_times_ms = NumberSeq();
2566 (preamble_summary == NULL) ? NULL :
2567 preamble_summary->get_pop_preamble_seq()
2568 };
2569 calc_other_times_ms = NumberSeq(summary->get_total_seq(),
2570 1, other_parts);
2571 } 2410 }
2572 check_other_times(1, summary->get_other_seq(), &calc_other_times_ms); 2411 check_other_times(1, summary->get_other_seq(), &calc_other_times_ms);
2573 } 2412 }
2574 } else { 2413 } else {
2575 print_indent(0); 2414 print_indent(0);
2577 } 2416 }
2578 gclog_or_tty->print_cr(""); 2417 gclog_or_tty->print_cr("");
2579 } 2418 }
2580 2419
2581 void 2420 void
2582 G1CollectorPolicy::print_abandoned_summary(PauseSummary* non_pop_summary, 2421 G1CollectorPolicy::print_abandoned_summary(PauseSummary* summary) const {
2583 PauseSummary* pop_summary) const {
2584 bool printed = false; 2422 bool printed = false;
2585 if (non_pop_summary->get_total_seq()->num() > 0) { 2423 if (summary->get_total_seq()->num() > 0) {
2586 printed = true; 2424 printed = true;
2587 print_summary(non_pop_summary); 2425 print_summary(summary);
2588 } 2426 }
2589 if (pop_summary->get_total_seq()->num() > 0) {
2590 printed = true;
2591 print_summary(pop_summary);
2592 }
2593
2594 if (!printed) { 2427 if (!printed) {
2595 print_indent(0); 2428 print_indent(0);
2596 gclog_or_tty->print_cr("none"); 2429 gclog_or_tty->print_cr("none");
2597 gclog_or_tty->print_cr(""); 2430 gclog_or_tty->print_cr("");
2598 } 2431 }
2606 gclog_or_tty->print_cr(""); 2439 gclog_or_tty->print_cr("");
2607 gclog_or_tty->print_cr(" Full Young GC Pauses: %8d", _full_young_pause_num); 2440 gclog_or_tty->print_cr(" Full Young GC Pauses: %8d", _full_young_pause_num);
2608 gclog_or_tty->print_cr(" Partial Young GC Pauses: %8d", _partial_young_pause_num); 2441 gclog_or_tty->print_cr(" Partial Young GC Pauses: %8d", _partial_young_pause_num);
2609 gclog_or_tty->print_cr(""); 2442 gclog_or_tty->print_cr("");
2610 2443
2611 gclog_or_tty->print_cr("NON-POPULAR PAUSES"); 2444 gclog_or_tty->print_cr("EVACUATION PAUSES");
2612 print_summary(_non_pop_summary); 2445 print_summary(_summary);
2613
2614 gclog_or_tty->print_cr("POPULAR PAUSES");
2615 print_summary(_pop_summary);
2616 2446
2617 gclog_or_tty->print_cr("ABANDONED PAUSES"); 2447 gclog_or_tty->print_cr("ABANDONED PAUSES");
2618 print_abandoned_summary(_non_pop_abandoned_summary, 2448 print_abandoned_summary(_abandoned_summary);
2619 _pop_abandoned_summary);
2620 2449
2621 gclog_or_tty->print_cr("MISC"); 2450 gclog_or_tty->print_cr("MISC");
2622 print_summary_sd(0, "Stop World", _all_stop_world_times_ms); 2451 print_summary_sd(0, "Stop World", _all_stop_world_times_ms);
2623 print_summary_sd(0, "Yields", _all_yield_times_ms); 2452 print_summary_sd(0, "Yields", _all_yield_times_ms);
2624 for (int i = 0; i < _aux_num; ++i) { 2453 for (int i = 0; i < _aux_num; ++i) {
2700 gclog_or_tty->print_cr("%d regions.", _conc_refine_current_delta); 2529 gclog_or_tty->print_cr("%d regions.", _conc_refine_current_delta);
2701 } 2530 }
2702 _conc_refine_enabled++; 2531 _conc_refine_enabled++;
2703 } 2532 }
2704 2533
2705 void G1CollectorPolicy::set_single_region_collection_set(HeapRegion* hr) {
2706 assert(collection_set() == NULL, "Must be no current CS.");
2707 _collection_set_size = 0;
2708 _collection_set_bytes_used_before = 0;
2709 add_to_collection_set(hr);
2710 count_CS_bytes_used();
2711 }
2712
2713 bool 2534 bool
2714 G1CollectorPolicy::should_add_next_region_to_young_list() { 2535 G1CollectorPolicy::should_add_next_region_to_young_list() {
2715 assert(in_young_gc_mode(), "should be in young GC mode"); 2536 assert(in_young_gc_mode(), "should be in young GC mode");
2716 bool ret; 2537 bool ret;
2717 size_t young_list_length = _g1->young_list_length(); 2538 size_t young_list_length = _g1->young_list_length();
2784 } else { 2605 } else {
2785 _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( 2606 _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(
2786 HeapRegion::GrainWords * _max_survivor_regions); 2607 HeapRegion::GrainWords * _max_survivor_regions);
2787 } 2608 }
2788 } 2609 }
2789
2790
2791 void
2792 G1CollectorPolicy_BestRegionsFirst::
2793 set_single_region_collection_set(HeapRegion* hr) {
2794 G1CollectorPolicy::set_single_region_collection_set(hr);
2795 _collectionSetChooser->removeRegion(hr);
2796 }
2797
2798 2610
2799 bool 2611 bool
2800 G1CollectorPolicy_BestRegionsFirst::should_do_collection_pause(size_t 2612 G1CollectorPolicy_BestRegionsFirst::should_do_collection_pause(size_t
2801 word_size) { 2613 word_size) {
2802 assert(_g1->regions_accounted_for(), "Region leakage!"); 2614 assert(_g1->regions_accounted_for(), "Region leakage!");
3059 _g1->register_region_with_in_cset_fast_test(hr); 2871 _g1->register_region_with_in_cset_fast_test(hr);
3060 } 2872 }
3061 2873
3062 void 2874 void
3063 G1CollectorPolicy_BestRegionsFirst:: 2875 G1CollectorPolicy_BestRegionsFirst::
3064 choose_collection_set(HeapRegion* pop_region) { 2876 choose_collection_set() {
3065 double non_young_start_time_sec; 2877 double non_young_start_time_sec;
3066 start_recording_regions(); 2878 start_recording_regions();
3067 2879
3068 if (pop_region != NULL) { 2880 guarantee(_target_pause_time_ms > -1.0,
3069 _target_pause_time_ms = (double) G1MaxPauseTimeMS; 2881 "_target_pause_time_ms should have been set!");
3070 } else { 2882 assert(_collection_set == NULL, "Precondition");
3071 guarantee(_target_pause_time_ms > -1.0,
3072 "_target_pause_time_ms should have been set!");
3073 }
3074
3075 // pop region is either null (and so is CS), or else it *is* the CS.
3076 assert(_collection_set == pop_region, "Precondition");
3077 2883
3078 double base_time_ms = predict_base_elapsed_time_ms(_pending_cards); 2884 double base_time_ms = predict_base_elapsed_time_ms(_pending_cards);
3079 double predicted_pause_time_ms = base_time_ms; 2885 double predicted_pause_time_ms = base_time_ms;
3080 2886
3081 double target_time_ms = _target_pause_time_ms; 2887 double target_time_ms = _target_pause_time_ms;
3098 size_t max_live_bytes = _g1->free_regions() * HeapRegion::GrainBytes; 2904 size_t max_live_bytes = _g1->free_regions() * HeapRegion::GrainBytes;
3099 2905
3100 size_t expansion_bytes = 2906 size_t expansion_bytes =
3101 _g1->expansion_regions() * HeapRegion::GrainBytes; 2907 _g1->expansion_regions() * HeapRegion::GrainBytes;
3102 2908
3103 if (pop_region == NULL) { 2909 _collection_set_bytes_used_before = 0;
3104 _collection_set_bytes_used_before = 0; 2910 _collection_set_size = 0;
3105 _collection_set_size = 0;
3106 }
3107 2911
3108 // Adjust for expansion and slop. 2912 // Adjust for expansion and slop.
3109 max_live_bytes = max_live_bytes + expansion_bytes; 2913 max_live_bytes = max_live_bytes + expansion_bytes;
3110 2914
3111 assert(pop_region != NULL || _g1->regions_accounted_for(), "Region leakage!"); 2915 assert(_g1->regions_accounted_for(), "Region leakage!");
3112 2916
3113 HeapRegion* hr; 2917 HeapRegion* hr;
3114 if (in_young_gc_mode()) { 2918 if (in_young_gc_mode()) {
3115 double young_start_time_sec = os::elapsedTime(); 2919 double young_start_time_sec = os::elapsedTime();
3116 2920
3133 2937
3134 ++_young_cset_length; 2938 ++_young_cset_length;
3135 double predicted_time_ms = predict_region_elapsed_time_ms(hr, true); 2939 double predicted_time_ms = predict_region_elapsed_time_ms(hr, true);
3136 time_remaining_ms -= predicted_time_ms; 2940 time_remaining_ms -= predicted_time_ms;
3137 predicted_pause_time_ms += predicted_time_ms; 2941 predicted_pause_time_ms += predicted_time_ms;
3138 if (hr == pop_region) { 2942 assert(!hr->in_collection_set(), "invariant");
3139 // The popular region was young. Skip over it. 2943 add_to_collection_set(hr);
3140 assert(hr->in_collection_set(), "It's the pop region."); 2944 record_cset_region(hr, true);
3141 } else {
3142 assert(!hr->in_collection_set(), "It's not the pop region.");
3143 add_to_collection_set(hr);
3144 record_cset_region(hr, true);
3145 }
3146 max_live_bytes -= MIN2(hr->max_live_bytes(), max_live_bytes); 2945 max_live_bytes -= MIN2(hr->max_live_bytes(), max_live_bytes);
3147 if (G1PolicyVerbose > 0) { 2946 if (G1PolicyVerbose > 0) {
3148 gclog_or_tty->print_cr(" Added [" PTR_FORMAT ", " PTR_FORMAT") to CS.", 2947 gclog_or_tty->print_cr(" Added [" PTR_FORMAT ", " PTR_FORMAT") to CS.",
3149 hr->bottom(), hr->end()); 2948 hr->bottom(), hr->end());
3150 gclog_or_tty->print_cr(" (" SIZE_FORMAT " KB left in heap.)", 2949 gclog_or_tty->print_cr(" (" SIZE_FORMAT " KB left in heap.)",
3163 2962
3164 if (_young_cset_length > 0 && _last_young_gc_full) { 2963 if (_young_cset_length > 0 && _last_young_gc_full) {
3165 // don't bother adding more regions... 2964 // don't bother adding more regions...
3166 goto choose_collection_set_end; 2965 goto choose_collection_set_end;
3167 } 2966 }
3168 } else if (pop_region != NULL) {
3169 // We're not in young mode, and we chose a popular region; don't choose
3170 // any more.
3171 return;
3172 } 2967 }
3173 2968
3174 if (!in_young_gc_mode() || !full_young_gcs()) { 2969 if (!in_young_gc_mode() || !full_young_gcs()) {
3175 bool should_continue = true; 2970 bool should_continue = true;
3176 NumberSeq seq; 2971 NumberSeq seq;
3177 double avg_prediction = 100000000000000000.0; // something very large 2972 double avg_prediction = 100000000000000000.0; // something very large
3178 do { 2973 do {
3179 hr = _collectionSetChooser->getNextMarkedRegion(time_remaining_ms, 2974 hr = _collectionSetChooser->getNextMarkedRegion(time_remaining_ms,
3180 avg_prediction); 2975 avg_prediction);
3181 if (hr != NULL && !hr->popular()) { 2976 if (hr != NULL) {
3182 double predicted_time_ms = predict_region_elapsed_time_ms(hr, false); 2977 double predicted_time_ms = predict_region_elapsed_time_ms(hr, false);
3183 time_remaining_ms -= predicted_time_ms; 2978 time_remaining_ms -= predicted_time_ms;
3184 predicted_pause_time_ms += predicted_time_ms; 2979 predicted_pause_time_ms += predicted_time_ms;
3185 add_to_collection_set(hr); 2980 add_to_collection_set(hr);
3186 record_cset_region(hr, false); 2981 record_cset_region(hr, false);
3223 size_t expansion_bytes = numRegions * HeapRegion::GrainBytes; 3018 size_t expansion_bytes = numRegions * HeapRegion::GrainBytes;
3224 _g1->expand(expansion_bytes); 3019 _g1->expand(expansion_bytes);
3225 } 3020 }
3226 3021
3227 void G1CollectorPolicy_BestRegionsFirst:: 3022 void G1CollectorPolicy_BestRegionsFirst::
3228 record_collection_pause_end(bool popular, bool abandoned) { 3023 record_collection_pause_end(bool abandoned) {
3229 G1CollectorPolicy::record_collection_pause_end(popular, abandoned); 3024 G1CollectorPolicy::record_collection_pause_end(abandoned);
3230 assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end."); 3025 assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end.");
3231 } 3026 }
3232 3027
3233 // Local Variables: *** 3028 // Local Variables: ***
3234 // c-indentation-style: gnu *** 3029 // c-indentation-style: gnu ***