comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp @ 1973:631f79e71e90

6974966: G1: unnecessary direct-to-old allocations Summary: This change revamps the slow allocation path of G1. Improvements include the following: a) Allocations directly to old regions are now totally banned. G1 now only allows allocations out of young regions (with the only exception being humongous regions). b) The thread that allocates a new region (which is now guaranteed to be young) does not dirty all its cards. Each thread that successfully allocates out of a young region is now responsible for dirtying the cards that corresponding to the "block" that just got allocated. c) allocate_new_tlab() and mem_allocate() are now implemented differently and TLAB allocations are only done by allocate_new_tlab(). d) If a thread schedules an evacuation pause in order to satisfy an allocation request, it will perform the allocation at the end of the safepoint so that the thread that initiated the GC also gets "first pick" of any space made available by the GC. e) If a thread is unable to allocate a humongous object it will schedule an evacuation pause in case it reclaims enough regions so that the humongous allocation can be satisfied aftewards. f) The G1 policy is more careful to set the young list target length to be the survivor number +1. g) Lots of code tidy up, removal, refactoring to make future changes easier. Reviewed-by: johnc, ysr
author tonyp
date Tue, 24 Aug 2010 17:24:33 -0400
parents f95d63e2154a
children 016a3628c885
comparison
equal deleted inserted replaced
1972:f95d63e2154a 1973:631f79e71e90
991 991
992 // Record the fact that "bytes" bytes allocated in a region. 992 // Record the fact that "bytes" bytes allocated in a region.
993 void record_before_bytes(size_t bytes); 993 void record_before_bytes(size_t bytes);
994 void record_after_bytes(size_t bytes); 994 void record_after_bytes(size_t bytes);
995 995
996 // Returns "true" if this is a good time to do a collection pause.
997 // The "word_size" argument, if non-zero, indicates the size of an
998 // allocation request that is prompting this query.
999 virtual bool should_do_collection_pause(size_t word_size) = 0;
1000
1001 // Choose a new collection set. Marks the chosen regions as being 996 // Choose a new collection set. Marks the chosen regions as being
1002 // "in_collection_set", and links them together. The head and number of 997 // "in_collection_set", and links them together. The head and number of
1003 // the collection set are available via access methods. 998 // the collection set are available via access methods.
1004 virtual void choose_collection_set(double target_pause_time_ms) = 0; 999 virtual void choose_collection_set(double target_pause_time_ms) = 0;
1005 1000
1114 _short_lived_surv_rate_group->finished_recalculating_age_indexes(); 1109 _short_lived_surv_rate_group->finished_recalculating_age_indexes();
1115 } 1110 }
1116 // do that for any other surv rate groups 1111 // do that for any other surv rate groups
1117 } 1112 }
1118 1113
1119 bool should_add_next_region_to_young_list(); 1114 bool is_young_list_full() {
1115 size_t young_list_length = _g1->young_list()->length();
1116 size_t young_list_max_length = _young_list_target_length;
1117 if (G1FixedEdenSize) {
1118 young_list_max_length -= _max_survivor_regions;
1119 }
1120
1121 return young_list_length >= young_list_max_length;
1122 }
1123 void update_region_num(bool young);
1120 1124
1121 bool in_young_gc_mode() { 1125 bool in_young_gc_mode() {
1122 return _in_young_gc_mode; 1126 return _in_young_gc_mode;
1123 } 1127 }
1124 void set_in_young_gc_mode(bool in_young_gc_mode) { 1128 void set_in_young_gc_mode(bool in_young_gc_mode) {
1268 public: 1272 public:
1269 G1CollectorPolicy_BestRegionsFirst() { 1273 G1CollectorPolicy_BestRegionsFirst() {
1270 _collectionSetChooser = new CollectionSetChooser(); 1274 _collectionSetChooser = new CollectionSetChooser();
1271 } 1275 }
1272 void record_collection_pause_end(); 1276 void record_collection_pause_end();
1273 bool should_do_collection_pause(size_t word_size);
1274 // This is not needed any more, after the CSet choosing code was 1277 // This is not needed any more, after the CSet choosing code was
1275 // changed to use the pause prediction work. But let's leave the 1278 // changed to use the pause prediction work. But let's leave the
1276 // hook in just in case. 1279 // hook in just in case.
1277 void note_change_in_marked_bytes(HeapRegion* r) { } 1280 void note_change_in_marked_bytes(HeapRegion* r) { }
1278 #ifndef PRODUCT 1281 #ifndef PRODUCT