Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp @ 1394:1316cec51b4d
6819061: G1: eliminate serial Other times that are proportional to the collection set length
6871109: G1: remove the concept of the scan only prefix
Summary: Removed scan only regions and associated code. The young portion of the collection set is now constructed incrementally - when a young region is retired as the current allocation region it is added to the collection set.
Reviewed-by: apetrusenko, iveresov, tonyp
author | johnc |
---|---|
date | Thu, 22 Apr 2010 10:02:38 -0700 |
parents | 23b1b27ac76c |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1393:6ecb6e6de3d6 | 1394:1316cec51b4d |
---|---|
1 /* | 1 /* |
2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2001-2010 Sun Microsystems, Inc. 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. |
59 class MainBodySummary: public CHeapObj { | 59 class MainBodySummary: public CHeapObj { |
60 define_num_seq(satb_drain) // optional | 60 define_num_seq(satb_drain) // optional |
61 define_num_seq(parallel) // parallel only | 61 define_num_seq(parallel) // parallel only |
62 define_num_seq(ext_root_scan) | 62 define_num_seq(ext_root_scan) |
63 define_num_seq(mark_stack_scan) | 63 define_num_seq(mark_stack_scan) |
64 define_num_seq(scan_only) | |
65 define_num_seq(update_rs) | 64 define_num_seq(update_rs) |
66 define_num_seq(scan_rs) | 65 define_num_seq(scan_rs) |
67 define_num_seq(scan_new_refs) // Only for temp use; added to | 66 define_num_seq(scan_new_refs) // Only for temp use; added to |
68 // in parallel case. | 67 // in parallel case. |
69 define_num_seq(obj_copy) | 68 define_num_seq(obj_copy) |
172 double* _cur_aux_times_ms; | 171 double* _cur_aux_times_ms; |
173 bool* _cur_aux_times_set; | 172 bool* _cur_aux_times_set; |
174 | 173 |
175 double* _par_last_ext_root_scan_times_ms; | 174 double* _par_last_ext_root_scan_times_ms; |
176 double* _par_last_mark_stack_scan_times_ms; | 175 double* _par_last_mark_stack_scan_times_ms; |
177 double* _par_last_scan_only_times_ms; | |
178 double* _par_last_scan_only_regions_scanned; | |
179 double* _par_last_update_rs_start_times_ms; | 176 double* _par_last_update_rs_start_times_ms; |
180 double* _par_last_update_rs_times_ms; | 177 double* _par_last_update_rs_times_ms; |
181 double* _par_last_update_rs_processed_buffers; | 178 double* _par_last_update_rs_processed_buffers; |
182 double* _par_last_scan_rs_start_times_ms; | 179 double* _par_last_scan_rs_start_times_ms; |
183 double* _par_last_scan_rs_times_ms; | 180 double* _par_last_scan_rs_times_ms; |
194 // if true, then it tries to dynamically adjust the length of the | 191 // if true, then it tries to dynamically adjust the length of the |
195 // young list | 192 // young list |
196 bool _adaptive_young_list_length; | 193 bool _adaptive_young_list_length; |
197 size_t _young_list_min_length; | 194 size_t _young_list_min_length; |
198 size_t _young_list_target_length; | 195 size_t _young_list_target_length; |
199 size_t _young_list_so_prefix_length; | |
200 size_t _young_list_fixed_length; | 196 size_t _young_list_fixed_length; |
201 | 197 |
202 size_t _young_cset_length; | 198 size_t _young_cset_length; |
203 bool _last_young_gc_full; | 199 bool _last_young_gc_full; |
204 | 200 |
232 double _prev_collection_pause_end_ms; | 228 double _prev_collection_pause_end_ms; |
233 | 229 |
234 TruncatedSeq* _pending_card_diff_seq; | 230 TruncatedSeq* _pending_card_diff_seq; |
235 TruncatedSeq* _rs_length_diff_seq; | 231 TruncatedSeq* _rs_length_diff_seq; |
236 TruncatedSeq* _cost_per_card_ms_seq; | 232 TruncatedSeq* _cost_per_card_ms_seq; |
237 TruncatedSeq* _cost_per_scan_only_region_ms_seq; | |
238 TruncatedSeq* _fully_young_cards_per_entry_ratio_seq; | 233 TruncatedSeq* _fully_young_cards_per_entry_ratio_seq; |
239 TruncatedSeq* _partially_young_cards_per_entry_ratio_seq; | 234 TruncatedSeq* _partially_young_cards_per_entry_ratio_seq; |
240 TruncatedSeq* _cost_per_entry_ms_seq; | 235 TruncatedSeq* _cost_per_entry_ms_seq; |
241 TruncatedSeq* _partially_young_cost_per_entry_ms_seq; | 236 TruncatedSeq* _partially_young_cost_per_entry_ms_seq; |
242 TruncatedSeq* _cost_per_byte_ms_seq; | 237 TruncatedSeq* _cost_per_byte_ms_seq; |
247 TruncatedSeq* _pending_cards_seq; | 242 TruncatedSeq* _pending_cards_seq; |
248 TruncatedSeq* _scanned_cards_seq; | 243 TruncatedSeq* _scanned_cards_seq; |
249 TruncatedSeq* _rs_lengths_seq; | 244 TruncatedSeq* _rs_lengths_seq; |
250 | 245 |
251 TruncatedSeq* _cost_per_byte_ms_during_cm_seq; | 246 TruncatedSeq* _cost_per_byte_ms_during_cm_seq; |
252 TruncatedSeq* _cost_per_scan_only_region_ms_during_cm_seq; | |
253 | 247 |
254 TruncatedSeq* _young_gc_eff_seq; | 248 TruncatedSeq* _young_gc_eff_seq; |
255 | 249 |
256 TruncatedSeq* _max_conc_overhead_seq; | 250 TruncatedSeq* _max_conc_overhead_seq; |
257 | 251 |
258 size_t _recorded_young_regions; | 252 size_t _recorded_young_regions; |
259 size_t _recorded_scan_only_regions; | |
260 size_t _recorded_non_young_regions; | 253 size_t _recorded_non_young_regions; |
261 size_t _recorded_region_num; | 254 size_t _recorded_region_num; |
262 | 255 |
263 size_t _free_regions_at_end_of_collection; | 256 size_t _free_regions_at_end_of_collection; |
264 size_t _scan_only_regions_at_end_of_collection; | |
265 | 257 |
266 size_t _recorded_rs_lengths; | 258 size_t _recorded_rs_lengths; |
267 size_t _max_rs_lengths; | 259 size_t _max_rs_lengths; |
268 | 260 |
269 size_t _recorded_marked_bytes; | 261 size_t _recorded_marked_bytes; |
275 size_t _predicted_bytes_to_copy; | 267 size_t _predicted_bytes_to_copy; |
276 | 268 |
277 double _predicted_survival_ratio; | 269 double _predicted_survival_ratio; |
278 double _predicted_rs_update_time_ms; | 270 double _predicted_rs_update_time_ms; |
279 double _predicted_rs_scan_time_ms; | 271 double _predicted_rs_scan_time_ms; |
280 double _predicted_scan_only_scan_time_ms; | |
281 double _predicted_object_copy_time_ms; | 272 double _predicted_object_copy_time_ms; |
282 double _predicted_constant_other_time_ms; | 273 double _predicted_constant_other_time_ms; |
283 double _predicted_young_other_time_ms; | 274 double _predicted_young_other_time_ms; |
284 double _predicted_non_young_other_time_ms; | 275 double _predicted_non_young_other_time_ms; |
285 double _predicted_pause_time_ms; | 276 double _predicted_pause_time_ms; |
341 } | 332 } |
342 | 333 |
343 #ifndef PRODUCT | 334 #ifndef PRODUCT |
344 bool verify_young_ages(); | 335 bool verify_young_ages(); |
345 #endif // PRODUCT | 336 #endif // PRODUCT |
346 | |
347 void tag_scan_only(size_t short_lived_scan_only_length); | |
348 | 337 |
349 double get_new_prediction(TruncatedSeq* seq) { | 338 double get_new_prediction(TruncatedSeq* seq) { |
350 return MAX2(seq->davg() + sigma() * seq->dsd(), | 339 return MAX2(seq->davg() + sigma() * seq->dsd(), |
351 seq->davg() * confidence_factor(seq->num())); | 340 seq->davg() * confidence_factor(seq->num())); |
352 } | 341 } |
429 else | 418 else |
430 return (double) card_num * | 419 return (double) card_num * |
431 get_new_prediction(_partially_young_cost_per_entry_ms_seq); | 420 get_new_prediction(_partially_young_cost_per_entry_ms_seq); |
432 } | 421 } |
433 | 422 |
434 double predict_scan_only_time_ms_during_cm(size_t scan_only_region_num) { | |
435 if (_cost_per_scan_only_region_ms_during_cm_seq->num() < 3) | |
436 return 1.5 * (double) scan_only_region_num * | |
437 get_new_prediction(_cost_per_scan_only_region_ms_seq); | |
438 else | |
439 return (double) scan_only_region_num * | |
440 get_new_prediction(_cost_per_scan_only_region_ms_during_cm_seq); | |
441 } | |
442 | |
443 double predict_scan_only_time_ms(size_t scan_only_region_num) { | |
444 if (_in_marking_window_im) | |
445 return predict_scan_only_time_ms_during_cm(scan_only_region_num); | |
446 else | |
447 return (double) scan_only_region_num * | |
448 get_new_prediction(_cost_per_scan_only_region_ms_seq); | |
449 } | |
450 | |
451 double predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) { | 423 double predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) { |
452 if (_cost_per_byte_ms_during_cm_seq->num() < 3) | 424 if (_cost_per_byte_ms_during_cm_seq->num() < 3) |
453 return 1.1 * (double) bytes_to_copy * | 425 return 1.1 * (double) bytes_to_copy * |
454 get_new_prediction(_cost_per_byte_ms_seq); | 426 get_new_prediction(_cost_per_byte_ms_seq); |
455 else | 427 else |
488 double predict_base_elapsed_time_ms(size_t pending_cards, | 460 double predict_base_elapsed_time_ms(size_t pending_cards, |
489 size_t scanned_cards); | 461 size_t scanned_cards); |
490 size_t predict_bytes_to_copy(HeapRegion* hr); | 462 size_t predict_bytes_to_copy(HeapRegion* hr); |
491 double predict_region_elapsed_time_ms(HeapRegion* hr, bool young); | 463 double predict_region_elapsed_time_ms(HeapRegion* hr, bool young); |
492 | 464 |
493 // for use by: calculate_optimal_so_length(length) | 465 // for use by: calculate_young_list_target_length(rs_length) |
494 void predict_gc_eff(size_t young_region_num, | 466 bool predict_will_fit(size_t young_region_num, |
495 size_t so_length, | 467 double base_time_ms, |
496 double base_time_ms, | 468 size_t init_free_regions, |
497 double *gc_eff, | 469 double target_pause_time_ms); |
498 double *pause_time_ms); | |
499 | |
500 // for use by: calculate_young_list_target_config(rs_length) | |
501 bool predict_gc_eff(size_t young_region_num, | |
502 size_t so_length, | |
503 double base_time_with_so_ms, | |
504 size_t init_free_regions, | |
505 double target_pause_time_ms, | |
506 double* gc_eff); | |
507 | 470 |
508 void start_recording_regions(); | 471 void start_recording_regions(); |
509 void record_cset_region(HeapRegion* hr, bool young); | 472 void record_cset_region_info(HeapRegion* hr, bool young); |
510 void record_scan_only_regions(size_t scan_only_length); | 473 void record_non_young_cset_region(HeapRegion* hr); |
474 | |
475 void set_recorded_young_regions(size_t n_regions); | |
476 void set_recorded_young_bytes(size_t bytes); | |
477 void set_recorded_rs_lengths(size_t rs_lengths); | |
478 void set_predicted_bytes_to_copy(size_t bytes); | |
479 | |
511 void end_recording_regions(); | 480 void end_recording_regions(); |
512 | 481 |
513 void record_vtime_diff_ms(double vtime_diff_ms) { | 482 void record_vtime_diff_ms(double vtime_diff_ms) { |
514 _vtime_diff_ms = vtime_diff_ms; | 483 _vtime_diff_ms = vtime_diff_ms; |
515 } | 484 } |
636 | 605 |
637 // Add a new GC of the given duration and end time to the record. | 606 // Add a new GC of the given duration and end time to the record. |
638 void update_recent_gc_times(double end_time_sec, double elapsed_ms); | 607 void update_recent_gc_times(double end_time_sec, double elapsed_ms); |
639 | 608 |
640 // The head of the list (via "next_in_collection_set()") representing the | 609 // The head of the list (via "next_in_collection_set()") representing the |
641 // current collection set. | 610 // current collection set. Set from the incrementally built collection |
611 // set at the start of the pause. | |
642 HeapRegion* _collection_set; | 612 HeapRegion* _collection_set; |
613 | |
614 // The number of regions in the collection set. Set from the incrementally | |
615 // built collection set at the start of an evacuation pause. | |
643 size_t _collection_set_size; | 616 size_t _collection_set_size; |
617 | |
618 // The number of bytes in the collection set before the pause. Set from | |
619 // the incrementally built collection set at the start of an evacuation | |
620 // pause. | |
644 size_t _collection_set_bytes_used_before; | 621 size_t _collection_set_bytes_used_before; |
622 | |
623 // The associated information that is maintained while the incremental | |
624 // collection set is being built with young regions. Used to populate | |
625 // the recorded info for the evacuation pause. | |
626 | |
627 enum CSetBuildType { | |
628 Active, // We are actively building the collection set | |
629 Inactive // We are not actively building the collection set | |
630 }; | |
631 | |
632 CSetBuildType _inc_cset_build_state; | |
633 | |
634 // The head of the incrementally built collection set. | |
635 HeapRegion* _inc_cset_head; | |
636 | |
637 // The tail of the incrementally built collection set. | |
638 HeapRegion* _inc_cset_tail; | |
639 | |
640 // The number of regions in the incrementally built collection set. | |
641 // Used to set _collection_set_size at the start of an evacuation | |
642 // pause. | |
643 size_t _inc_cset_size; | |
644 | |
645 // Used as the index in the surving young words structure | |
646 // which tracks the amount of space, for each young region, | |
647 // that survives the pause. | |
648 size_t _inc_cset_young_index; | |
649 | |
650 // The number of bytes in the incrementally built collection set. | |
651 // Used to set _collection_set_bytes_used_before at the start of | |
652 // an evacuation pause. | |
653 size_t _inc_cset_bytes_used_before; | |
654 | |
655 // Used to record the highest end of heap region in collection set | |
656 HeapWord* _inc_cset_max_finger; | |
657 | |
658 // The number of recorded used bytes in the young regions | |
659 // of the collection set. This is the sum of the used() bytes | |
660 // of retired young regions in the collection set. | |
661 size_t _inc_cset_recorded_young_bytes; | |
662 | |
663 // The RSet lengths recorded for regions in the collection set | |
664 // (updated by the periodic sampling of the regions in the | |
665 // young list/collection set). | |
666 size_t _inc_cset_recorded_rs_lengths; | |
667 | |
668 // The predicted elapsed time it will take to collect the regions | |
669 // in the collection set (updated by the periodic sampling of the | |
670 // regions in the young list/collection set). | |
671 double _inc_cset_predicted_elapsed_time_ms; | |
672 | |
673 // The predicted bytes to copy for the regions in the collection | |
674 // set (updated by the periodic sampling of the regions in the | |
675 // young list/collection set). | |
676 size_t _inc_cset_predicted_bytes_to_copy; | |
645 | 677 |
646 // Info about marking. | 678 // Info about marking. |
647 int _n_marks; // Sticky at 2, so we know when we've done at least 2. | 679 int _n_marks; // Sticky at 2, so we know when we've done at least 2. |
648 | 680 |
649 // The number of collection pauses at the end of the last mark. | 681 // The number of collection pauses at the end of the last mark. |
759 double _mark_remark_start_sec; | 791 double _mark_remark_start_sec; |
760 double _mark_cleanup_start_sec; | 792 double _mark_cleanup_start_sec; |
761 double _mark_closure_time_ms; | 793 double _mark_closure_time_ms; |
762 | 794 |
763 void calculate_young_list_min_length(); | 795 void calculate_young_list_min_length(); |
764 void calculate_young_list_target_config(); | 796 void calculate_young_list_target_length(); |
765 void calculate_young_list_target_config(size_t rs_lengths); | 797 void calculate_young_list_target_length(size_t rs_lengths); |
766 size_t calculate_optimal_so_length(size_t young_list_length); | |
767 | 798 |
768 public: | 799 public: |
769 | 800 |
770 G1CollectorPolicy(); | 801 G1CollectorPolicy(); |
771 | 802 |
864 _par_last_ext_root_scan_times_ms[worker_i] = ms; | 895 _par_last_ext_root_scan_times_ms[worker_i] = ms; |
865 } | 896 } |
866 | 897 |
867 void record_mark_stack_scan_time(int worker_i, double ms) { | 898 void record_mark_stack_scan_time(int worker_i, double ms) { |
868 _par_last_mark_stack_scan_times_ms[worker_i] = ms; | 899 _par_last_mark_stack_scan_times_ms[worker_i] = ms; |
869 } | |
870 | |
871 void record_scan_only_time(int worker_i, double ms, int n) { | |
872 _par_last_scan_only_times_ms[worker_i] = ms; | |
873 _par_last_scan_only_regions_scanned[worker_i] = (double) n; | |
874 } | 900 } |
875 | 901 |
876 void record_satb_drain_time(double ms) { | 902 void record_satb_drain_time(double ms) { |
877 _cur_satb_drain_time_ms = ms; | 903 _cur_satb_drain_time_ms = ms; |
878 _satb_drain_time_set = true; | 904 _satb_drain_time_set = true; |
985 virtual bool should_do_collection_pause(size_t word_size) = 0; | 1011 virtual bool should_do_collection_pause(size_t word_size) = 0; |
986 | 1012 |
987 // Choose a new collection set. Marks the chosen regions as being | 1013 // Choose a new collection set. Marks the chosen regions as being |
988 // "in_collection_set", and links them together. The head and number of | 1014 // "in_collection_set", and links them together. The head and number of |
989 // the collection set are available via access methods. | 1015 // the collection set are available via access methods. |
990 virtual void choose_collection_set() = 0; | 1016 virtual bool choose_collection_set() = 0; |
991 | |
992 void clear_collection_set() { _collection_set = NULL; } | |
993 | 1017 |
994 // The head of the list (via "next_in_collection_set()") representing the | 1018 // The head of the list (via "next_in_collection_set()") representing the |
995 // current collection set. | 1019 // current collection set. |
996 HeapRegion* collection_set() { return _collection_set; } | 1020 HeapRegion* collection_set() { return _collection_set; } |
997 | 1021 |
1022 void clear_collection_set() { _collection_set = NULL; } | |
1023 | |
998 // The number of elements in the current collection set. | 1024 // The number of elements in the current collection set. |
999 size_t collection_set_size() { return _collection_set_size; } | 1025 size_t collection_set_size() { return _collection_set_size; } |
1000 | 1026 |
1001 // Add "hr" to the CS. | 1027 // Add "hr" to the CS. |
1002 void add_to_collection_set(HeapRegion* hr); | 1028 void add_to_collection_set(HeapRegion* hr); |
1029 | |
1030 // Incremental CSet Support | |
1031 | |
1032 // The head of the incrementally built collection set. | |
1033 HeapRegion* inc_cset_head() { return _inc_cset_head; } | |
1034 | |
1035 // The tail of the incrementally built collection set. | |
1036 HeapRegion* inc_set_tail() { return _inc_cset_tail; } | |
1037 | |
1038 // The number of elements in the incrementally built collection set. | |
1039 size_t inc_cset_size() { return _inc_cset_size; } | |
1040 | |
1041 // Initialize incremental collection set info. | |
1042 void start_incremental_cset_building(); | |
1043 | |
1044 void clear_incremental_cset() { | |
1045 _inc_cset_head = NULL; | |
1046 _inc_cset_tail = NULL; | |
1047 } | |
1048 | |
1049 // Stop adding regions to the incremental collection set | |
1050 void stop_incremental_cset_building() { _inc_cset_build_state = Inactive; } | |
1051 | |
1052 // Add/remove information about hr to the aggregated information | |
1053 // for the incrementally built collection set. | |
1054 void add_to_incremental_cset_info(HeapRegion* hr, size_t rs_length); | |
1055 void remove_from_incremental_cset_info(HeapRegion* hr); | |
1056 | |
1057 // Update information about hr in the aggregated information for | |
1058 // the incrementally built collection set. | |
1059 void update_incremental_cset_info(HeapRegion* hr, size_t new_rs_length); | |
1060 | |
1061 private: | |
1062 // Update the incremental cset information when adding a region | |
1063 // (should not be called directly). | |
1064 void add_region_to_incremental_cset_common(HeapRegion* hr); | |
1065 | |
1066 public: | |
1067 // Add hr to the LHS of the incremental collection set. | |
1068 void add_region_to_incremental_cset_lhs(HeapRegion* hr); | |
1069 | |
1070 // Add hr to the RHS of the incremental collection set. | |
1071 void add_region_to_incremental_cset_rhs(HeapRegion* hr); | |
1072 | |
1073 #ifndef PRODUCT | |
1074 void print_collection_set(HeapRegion* list_head, outputStream* st); | |
1075 #endif // !PRODUCT | |
1003 | 1076 |
1004 bool initiate_conc_mark_if_possible() { return _initiate_conc_mark_if_possible; } | 1077 bool initiate_conc_mark_if_possible() { return _initiate_conc_mark_if_possible; } |
1005 void set_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = true; } | 1078 void set_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = true; } |
1006 void clear_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = false; } | 1079 void clear_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = false; } |
1007 | 1080 |
1189 class G1CollectorPolicy_BestRegionsFirst: public G1CollectorPolicy { | 1262 class G1CollectorPolicy_BestRegionsFirst: public G1CollectorPolicy { |
1190 CollectionSetChooser* _collectionSetChooser; | 1263 CollectionSetChooser* _collectionSetChooser; |
1191 // If the estimated is less then desirable, resize if possible. | 1264 // If the estimated is less then desirable, resize if possible. |
1192 void expand_if_possible(size_t numRegions); | 1265 void expand_if_possible(size_t numRegions); |
1193 | 1266 |
1194 virtual void choose_collection_set(); | 1267 virtual bool choose_collection_set(); |
1195 virtual void record_collection_pause_start(double start_time_sec, | 1268 virtual void record_collection_pause_start(double start_time_sec, |
1196 size_t start_used); | 1269 size_t start_used); |
1197 virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes, | 1270 virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes, |
1198 size_t max_live_bytes); | 1271 size_t max_live_bytes); |
1199 virtual void record_full_collection_end(); | 1272 virtual void record_full_collection_end(); |