comparison src/share/vm/gc_implementation/g1/collectionSetChooser.cpp @ 8681:27714220e50e

8007036: G1: Too many old regions added to last mixed GC Summary: Stop adding old regions to collection set when the remaining reclaimable bytes reaches, or goes below, G1HeapWastePercent. Changes were also reviewed by Vitaly Davidovich <vitalyd@gmail.com>. Reviewed-by: brutisso
author johnc
date Mon, 04 Mar 2013 12:42:14 -0800
parents 37f7535e5f18
children de6a9e811145
comparison
equal deleted inserted replaced
8680:0624b9d81255 8681:27714220e50e
144 } 144 }
145 } 145 }
146 verify(); 146 verify();
147 } 147 }
148 148
149 uint CollectionSetChooser::calc_min_old_cset_length() {
150 // The min old CSet region bound is based on the maximum desired
151 // number of mixed GCs after a cycle. I.e., even if some old regions
152 // look expensive, we should add them to the CSet anyway to make
153 // sure we go through the available old regions in no more than the
154 // maximum desired number of mixed GCs.
155 //
156 // The calculation is based on the number of marked regions we added
157 // to the CSet chooser in the first place, not how many remain, so
158 // that the result is the same during all mixed GCs that follow a cycle.
159
160 const size_t region_num = (size_t) _length;
161 const size_t gc_num = (size_t) G1MixedGCCountTarget;
162 size_t result = region_num / gc_num;
163 // emulate ceiling
164 if (result * gc_num < region_num) {
165 result += 1;
166 }
167 return (uint) result;
168 }
169
170 uint CollectionSetChooser::calc_max_old_cset_length() {
171 // The max old CSet region bound is based on the threshold expressed
172 // as a percentage of the heap size. I.e., it should bound the
173 // number of old regions added to the CSet irrespective of how many
174 // of them are available.
175
176 G1CollectedHeap* g1h = G1CollectedHeap::heap();
177 const size_t region_num = g1h->n_regions();
178 const size_t perc = (size_t) G1OldCSetRegionThresholdPercent;
179 size_t result = region_num * perc / 100;
180 // emulate ceiling
181 if (100 * result < region_num * perc) {
182 result += 1;
183 }
184 return (uint) result;
185 }
186 149
187 void CollectionSetChooser::add_region(HeapRegion* hr) { 150 void CollectionSetChooser::add_region(HeapRegion* hr) {
188 assert(!hr->isHumongous(), 151 assert(!hr->isHumongous(),
189 "Humongous regions shouldn't be added to the collection set"); 152 "Humongous regions shouldn't be added to the collection set");
190 assert(!hr->is_young(), "should not be young!"); 153 assert(!hr->is_young(), "should not be young!");