comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @ 4787:2ace1c4ee8da

6888336: G1: avoid explicitly marking and pushing objects in survivor spaces Summary: This change simplifies the interaction between GC and concurrent marking. By disabling survivor spaces during the initial-mark pause we don't need to propagate marks of objects we copy during each GC (since we never need to copy an explicitly marked object). Reviewed-by: johnc, brutisso
author tonyp
date Tue, 10 Jan 2012 18:58:13 -0500
parents 1cbe7978b021
children 9509c20bba28
comparison
equal deleted inserted replaced
4786:1d6185f732aa 4787:2ace1c4ee8da
1 /* 1 /*
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
279 _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime()); 279 _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime());
280 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0; 280 _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0;
281 281
282 _par_last_gc_worker_start_times_ms = new double[_parallel_gc_threads]; 282 _par_last_gc_worker_start_times_ms = new double[_parallel_gc_threads];
283 _par_last_ext_root_scan_times_ms = new double[_parallel_gc_threads]; 283 _par_last_ext_root_scan_times_ms = new double[_parallel_gc_threads];
284 _par_last_mark_stack_scan_times_ms = new double[_parallel_gc_threads]; 284 _par_last_satb_filtering_times_ms = new double[_parallel_gc_threads];
285 285
286 _par_last_update_rs_times_ms = new double[_parallel_gc_threads]; 286 _par_last_update_rs_times_ms = new double[_parallel_gc_threads];
287 _par_last_update_rs_processed_buffers = new double[_parallel_gc_threads]; 287 _par_last_update_rs_processed_buffers = new double[_parallel_gc_threads];
288 288
289 _par_last_scan_rs_times_ms = new double[_parallel_gc_threads]; 289 _par_last_scan_rs_times_ms = new double[_parallel_gc_threads];
903 gclog_or_tty->stamp(PrintGCTimeStamps); 903 gclog_or_tty->stamp(PrintGCTimeStamps);
904 gclog_or_tty->print("[GC pause"); 904 gclog_or_tty->print("[GC pause");
905 gclog_or_tty->print(" (%s)", gcs_are_young() ? "young" : "mixed"); 905 gclog_or_tty->print(" (%s)", gcs_are_young() ? "young" : "mixed");
906 } 906 }
907 907
908 // We only need to do this here as the policy will only be applied 908 if (!during_initial_mark_pause()) {
909 // to the GC we're about to start. so, no point is calculating this 909 // We only need to do this here as the policy will only be applied
910 // every time we calculate / recalculate the target young length. 910 // to the GC we're about to start. so, no point is calculating this
911 update_survivors_policy(); 911 // every time we calculate / recalculate the target young length.
912 update_survivors_policy();
913 } else {
914 // The marking phase has a "we only copy implicitly live
915 // objects during marking" invariant. The easiest way to ensure it
916 // holds is not to allocate any survivor regions and tenure all
917 // objects. In the future we might change this and handle survivor
918 // regions specially during marking.
919 tenure_all_objects();
920 }
912 921
913 assert(_g1->used() == _g1->recalculate_used(), 922 assert(_g1->used() == _g1->recalculate_used(),
914 err_msg("sanity, used: "SIZE_FORMAT" recalculate_used: "SIZE_FORMAT, 923 err_msg("sanity, used: "SIZE_FORMAT" recalculate_used: "SIZE_FORMAT,
915 _g1->used(), _g1->recalculate_used())); 924 _g1->used(), _g1->recalculate_used()));
916 925
937 // if they are not set properly 946 // if they are not set properly
938 947
939 for (int i = 0; i < _parallel_gc_threads; ++i) { 948 for (int i = 0; i < _parallel_gc_threads; ++i) {
940 _par_last_gc_worker_start_times_ms[i] = -1234.0; 949 _par_last_gc_worker_start_times_ms[i] = -1234.0;
941 _par_last_ext_root_scan_times_ms[i] = -1234.0; 950 _par_last_ext_root_scan_times_ms[i] = -1234.0;
942 _par_last_mark_stack_scan_times_ms[i] = -1234.0; 951 _par_last_satb_filtering_times_ms[i] = -1234.0;
943 _par_last_update_rs_times_ms[i] = -1234.0; 952 _par_last_update_rs_times_ms[i] = -1234.0;
944 _par_last_update_rs_processed_buffers[i] = -1234.0; 953 _par_last_update_rs_processed_buffers[i] = -1234.0;
945 _par_last_scan_rs_times_ms[i] = -1234.0; 954 _par_last_scan_rs_times_ms[i] = -1234.0;
946 _par_last_obj_copy_times_ms[i] = -1234.0; 955 _par_last_obj_copy_times_ms[i] = -1234.0;
947 _par_last_termination_times_ms[i] = -1234.0; 956 _par_last_termination_times_ms[i] = -1234.0;
1225 // These values are used to update the summary information that is 1234 // These values are used to update the summary information that is
1226 // displayed when TraceGen0Time is enabled, and are output as part 1235 // displayed when TraceGen0Time is enabled, and are output as part
1227 // of the PrintGCDetails output, in the non-parallel case. 1236 // of the PrintGCDetails output, in the non-parallel case.
1228 1237
1229 double ext_root_scan_time = avg_value(_par_last_ext_root_scan_times_ms); 1238 double ext_root_scan_time = avg_value(_par_last_ext_root_scan_times_ms);
1230 double mark_stack_scan_time = avg_value(_par_last_mark_stack_scan_times_ms); 1239 double satb_filtering_time = avg_value(_par_last_satb_filtering_times_ms);
1231 double update_rs_time = avg_value(_par_last_update_rs_times_ms); 1240 double update_rs_time = avg_value(_par_last_update_rs_times_ms);
1232 double update_rs_processed_buffers = 1241 double update_rs_processed_buffers =
1233 sum_of_values(_par_last_update_rs_processed_buffers); 1242 sum_of_values(_par_last_update_rs_processed_buffers);
1234 double scan_rs_time = avg_value(_par_last_scan_rs_times_ms); 1243 double scan_rs_time = avg_value(_par_last_scan_rs_times_ms);
1235 double obj_copy_time = avg_value(_par_last_obj_copy_times_ms); 1244 double obj_copy_time = avg_value(_par_last_obj_copy_times_ms);
1236 double termination_time = avg_value(_par_last_termination_times_ms); 1245 double termination_time = avg_value(_par_last_termination_times_ms);
1237 1246
1238 double known_time = ext_root_scan_time + 1247 double known_time = ext_root_scan_time +
1239 mark_stack_scan_time + 1248 satb_filtering_time +
1240 update_rs_time + 1249 update_rs_time +
1241 scan_rs_time + 1250 scan_rs_time +
1242 obj_copy_time; 1251 obj_copy_time;
1243 1252
1244 double other_time_ms = elapsed_ms; 1253 double other_time_ms = elapsed_ms;
1280 // each other. Therefore we unconditionally record the SATB drain 1289 // each other. Therefore we unconditionally record the SATB drain
1281 // time - even if it's zero. 1290 // time - even if it's zero.
1282 body_summary->record_satb_drain_time_ms(_cur_satb_drain_time_ms); 1291 body_summary->record_satb_drain_time_ms(_cur_satb_drain_time_ms);
1283 1292
1284 body_summary->record_ext_root_scan_time_ms(ext_root_scan_time); 1293 body_summary->record_ext_root_scan_time_ms(ext_root_scan_time);
1285 body_summary->record_mark_stack_scan_time_ms(mark_stack_scan_time); 1294 body_summary->record_satb_filtering_time_ms(satb_filtering_time);
1286 body_summary->record_update_rs_time_ms(update_rs_time); 1295 body_summary->record_update_rs_time_ms(update_rs_time);
1287 body_summary->record_scan_rs_time_ms(scan_rs_time); 1296 body_summary->record_scan_rs_time_ms(scan_rs_time);
1288 body_summary->record_obj_copy_time_ms(obj_copy_time); 1297 body_summary->record_obj_copy_time_ms(obj_copy_time);
1289 1298
1290 if (parallel) { 1299 if (parallel) {
1374 1383
1375 gclog_or_tty->print_cr("%s, %1.8lf secs]", 1384 gclog_or_tty->print_cr("%s, %1.8lf secs]",
1376 (last_pause_included_initial_mark) ? " (initial-mark)" : "", 1385 (last_pause_included_initial_mark) ? " (initial-mark)" : "",
1377 elapsed_ms / 1000.0); 1386 elapsed_ms / 1000.0);
1378 1387
1379 if (print_marking_info) {
1380 print_stats(1, "SATB Drain Time", _cur_satb_drain_time_ms);
1381 }
1382
1383 if (parallel) { 1388 if (parallel) {
1384 print_stats(1, "Parallel Time", _cur_collection_par_time_ms); 1389 print_stats(1, "Parallel Time", _cur_collection_par_time_ms);
1385 print_par_stats(2, "GC Worker Start", _par_last_gc_worker_start_times_ms); 1390 print_par_stats(2, "GC Worker Start", _par_last_gc_worker_start_times_ms);
1386 print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms); 1391 print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms);
1387 if (print_marking_info) { 1392 if (print_marking_info) {
1388 print_par_stats(2, "Mark Stack Scanning", _par_last_mark_stack_scan_times_ms); 1393 print_par_stats(2, "SATB Filtering", _par_last_satb_filtering_times_ms);
1389 } 1394 }
1390 print_par_stats(2, "Update RS", _par_last_update_rs_times_ms); 1395 print_par_stats(2, "Update RS", _par_last_update_rs_times_ms);
1391 print_par_sizes(3, "Processed Buffers", _par_last_update_rs_processed_buffers); 1396 print_par_sizes(3, "Processed Buffers", _par_last_update_rs_processed_buffers);
1392 print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms); 1397 print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms);
1393 print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms); 1398 print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms);
1397 1402
1398 for (int i = 0; i < _parallel_gc_threads; i++) { 1403 for (int i = 0; i < _parallel_gc_threads; i++) {
1399 _par_last_gc_worker_times_ms[i] = _par_last_gc_worker_end_times_ms[i] - _par_last_gc_worker_start_times_ms[i]; 1404 _par_last_gc_worker_times_ms[i] = _par_last_gc_worker_end_times_ms[i] - _par_last_gc_worker_start_times_ms[i];
1400 1405
1401 double worker_known_time = _par_last_ext_root_scan_times_ms[i] + 1406 double worker_known_time = _par_last_ext_root_scan_times_ms[i] +
1402 _par_last_mark_stack_scan_times_ms[i] + 1407 _par_last_satb_filtering_times_ms[i] +
1403 _par_last_update_rs_times_ms[i] + 1408 _par_last_update_rs_times_ms[i] +
1404 _par_last_scan_rs_times_ms[i] + 1409 _par_last_scan_rs_times_ms[i] +
1405 _par_last_obj_copy_times_ms[i] + 1410 _par_last_obj_copy_times_ms[i] +
1406 _par_last_termination_times_ms[i]; 1411 _par_last_termination_times_ms[i];
1407 1412
1410 print_par_stats(2, "GC Worker", _par_last_gc_worker_times_ms); 1415 print_par_stats(2, "GC Worker", _par_last_gc_worker_times_ms);
1411 print_par_stats(2, "GC Worker Other", _par_last_gc_worker_other_times_ms); 1416 print_par_stats(2, "GC Worker Other", _par_last_gc_worker_other_times_ms);
1412 } else { 1417 } else {
1413 print_stats(1, "Ext Root Scanning", ext_root_scan_time); 1418 print_stats(1, "Ext Root Scanning", ext_root_scan_time);
1414 if (print_marking_info) { 1419 if (print_marking_info) {
1415 print_stats(1, "Mark Stack Scanning", mark_stack_scan_time); 1420 print_stats(1, "SATB Filtering", satb_filtering_time);
1416 } 1421 }
1417 print_stats(1, "Update RS", update_rs_time); 1422 print_stats(1, "Update RS", update_rs_time);
1418 print_stats(2, "Processed Buffers", (int)update_rs_processed_buffers); 1423 print_stats(2, "Processed Buffers", (int)update_rs_processed_buffers);
1419 print_stats(1, "Scan RS", scan_rs_time); 1424 print_stats(1, "Scan RS", scan_rs_time);
1420 print_stats(1, "Object Copying", obj_copy_time); 1425 print_stats(1, "Object Copying", obj_copy_time);
1981 bool parallel = G1CollectedHeap::use_parallel_gc_threads(); 1986 bool parallel = G1CollectedHeap::use_parallel_gc_threads();
1982 MainBodySummary* body_summary = summary->main_body_summary(); 1987 MainBodySummary* body_summary = summary->main_body_summary();
1983 if (summary->get_total_seq()->num() > 0) { 1988 if (summary->get_total_seq()->num() > 0) {
1984 print_summary_sd(0, "Evacuation Pauses", summary->get_total_seq()); 1989 print_summary_sd(0, "Evacuation Pauses", summary->get_total_seq());
1985 if (body_summary != NULL) { 1990 if (body_summary != NULL) {
1986 print_summary(1, "SATB Drain", body_summary->get_satb_drain_seq());
1987 if (parallel) { 1991 if (parallel) {
1988 print_summary(1, "Parallel Time", body_summary->get_parallel_seq()); 1992 print_summary(1, "Parallel Time", body_summary->get_parallel_seq());
1989 print_summary(2, "Ext Root Scanning", body_summary->get_ext_root_scan_seq()); 1993 print_summary(2, "Ext Root Scanning", body_summary->get_ext_root_scan_seq());
1990 print_summary(2, "Mark Stack Scanning", body_summary->get_mark_stack_scan_seq()); 1994 print_summary(2, "SATB Filtering", body_summary->get_satb_filtering_seq());
1991 print_summary(2, "Update RS", body_summary->get_update_rs_seq()); 1995 print_summary(2, "Update RS", body_summary->get_update_rs_seq());
1992 print_summary(2, "Scan RS", body_summary->get_scan_rs_seq()); 1996 print_summary(2, "Scan RS", body_summary->get_scan_rs_seq());
1993 print_summary(2, "Object Copy", body_summary->get_obj_copy_seq()); 1997 print_summary(2, "Object Copy", body_summary->get_obj_copy_seq());
1994 print_summary(2, "Termination", body_summary->get_termination_seq()); 1998 print_summary(2, "Termination", body_summary->get_termination_seq());
1995 print_summary(2, "Parallel Other", body_summary->get_parallel_other_seq()); 1999 print_summary(2, "Parallel Other", body_summary->get_parallel_other_seq());
1996 { 2000 {
1997 NumberSeq* other_parts[] = { 2001 NumberSeq* other_parts[] = {
1998 body_summary->get_ext_root_scan_seq(), 2002 body_summary->get_ext_root_scan_seq(),
1999 body_summary->get_mark_stack_scan_seq(), 2003 body_summary->get_satb_filtering_seq(),
2000 body_summary->get_update_rs_seq(), 2004 body_summary->get_update_rs_seq(),
2001 body_summary->get_scan_rs_seq(), 2005 body_summary->get_scan_rs_seq(),
2002 body_summary->get_obj_copy_seq(), 2006 body_summary->get_obj_copy_seq(),
2003 body_summary->get_termination_seq() 2007 body_summary->get_termination_seq()
2004 }; 2008 };
2007 check_other_times(2, body_summary->get_parallel_other_seq(), 2011 check_other_times(2, body_summary->get_parallel_other_seq(),
2008 &calc_other_times_ms); 2012 &calc_other_times_ms);
2009 } 2013 }
2010 } else { 2014 } else {
2011 print_summary(1, "Ext Root Scanning", body_summary->get_ext_root_scan_seq()); 2015 print_summary(1, "Ext Root Scanning", body_summary->get_ext_root_scan_seq());
2012 print_summary(1, "Mark Stack Scanning", body_summary->get_mark_stack_scan_seq()); 2016 print_summary(1, "SATB Filtering", body_summary->get_satb_filtering_seq());
2013 print_summary(1, "Update RS", body_summary->get_update_rs_seq()); 2017 print_summary(1, "Update RS", body_summary->get_update_rs_seq());
2014 print_summary(1, "Scan RS", body_summary->get_scan_rs_seq()); 2018 print_summary(1, "Scan RS", body_summary->get_scan_rs_seq());
2015 print_summary(1, "Object Copy", body_summary->get_obj_copy_seq()); 2019 print_summary(1, "Object Copy", body_summary->get_obj_copy_seq());
2016 } 2020 }
2017 } 2021 }
2034 // serial 2038 // serial
2035 NumberSeq* other_parts[] = { 2039 NumberSeq* other_parts[] = {
2036 body_summary->get_satb_drain_seq(), 2040 body_summary->get_satb_drain_seq(),
2037 body_summary->get_update_rs_seq(), 2041 body_summary->get_update_rs_seq(),
2038 body_summary->get_ext_root_scan_seq(), 2042 body_summary->get_ext_root_scan_seq(),
2039 body_summary->get_mark_stack_scan_seq(), 2043 body_summary->get_satb_filtering_seq(),
2040 body_summary->get_scan_rs_seq(), 2044 body_summary->get_scan_rs_seq(),
2041 body_summary->get_obj_copy_seq() 2045 body_summary->get_obj_copy_seq()
2042 }; 2046 };
2043 calc_other_times_ms = NumberSeq(summary->get_total_seq(), 2047 calc_other_times_ms = NumberSeq(summary->get_total_seq(),
2044 6, other_parts); 2048 6, other_parts);
2431 // Add the heap region at the head of the non-incremental collection set 2435 // Add the heap region at the head of the non-incremental collection set
2432 void G1CollectorPolicy::add_old_region_to_cset(HeapRegion* hr) { 2436 void G1CollectorPolicy::add_old_region_to_cset(HeapRegion* hr) {
2433 assert(_inc_cset_build_state == Active, "Precondition"); 2437 assert(_inc_cset_build_state == Active, "Precondition");
2434 assert(!hr->is_young(), "non-incremental add of young region"); 2438 assert(!hr->is_young(), "non-incremental add of young region");
2435 2439
2436 if (_g1->mark_in_progress())
2437 _g1->concurrent_mark()->registerCSetRegion(hr);
2438
2439 assert(!hr->in_collection_set(), "should not already be in the CSet"); 2440 assert(!hr->in_collection_set(), "should not already be in the CSet");
2440 hr->set_in_collection_set(true); 2441 hr->set_in_collection_set(true);
2441 hr->set_next_in_collection_set(_collection_set); 2442 hr->set_next_in_collection_set(_collection_set);
2442 _collection_set = hr; 2443 _collection_set = hr;
2443 _collection_set_bytes_used_before += hr->used(); 2444 _collection_set_bytes_used_before += hr->used();
2702 hr = hr->get_next_young_region(); 2703 hr = hr->get_next_young_region();
2703 } 2704 }
2704 2705
2705 // Clear the fields that point to the survivor list - they are all young now. 2706 // Clear the fields that point to the survivor list - they are all young now.
2706 young_list->clear_survivors(); 2707 young_list->clear_survivors();
2707
2708 if (_g1->mark_in_progress())
2709 _g1->concurrent_mark()->register_collection_set_finger(_inc_cset_max_finger);
2710 2708
2711 _collection_set = _inc_cset_head; 2709 _collection_set = _inc_cset_head;
2712 _collection_set_bytes_used_before = _inc_cset_bytes_used_before; 2710 _collection_set_bytes_used_before = _inc_cset_bytes_used_before;
2713 time_remaining_ms -= _inc_cset_predicted_elapsed_time_ms; 2711 time_remaining_ms -= _inc_cset_predicted_elapsed_time_ms;
2714 predicted_pause_time_ms += _inc_cset_predicted_elapsed_time_ms; 2712 predicted_pause_time_ms += _inc_cset_predicted_elapsed_time_ms;