comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 6595:aaf61e68b255

6818524: G1: use ergonomic resizing of PLABs Summary: Employ PLABStats instances to record information about survivor and old PLABs, and use the recorded stats to adjust the sizes of survivor and old PLABS. Reviewed-by: johnc, ysr Contributed-by: Brandon Mitchell <brandon@twitter.com>
author johnc
date Mon, 06 Aug 2012 12:20:14 -0700
parents a2f7274eb6ef
children f99a36499b8c
comparison
equal deleted inserted replaced
6265:ef437ea56651 6595:aaf61e68b255
1889 _humongous_set("Master Humongous Set"), 1889 _humongous_set("Master Humongous Set"),
1890 _free_regions_coming(false), 1890 _free_regions_coming(false),
1891 _young_list(new YoungList(this)), 1891 _young_list(new YoungList(this)),
1892 _gc_time_stamp(0), 1892 _gc_time_stamp(0),
1893 _retained_old_gc_alloc_region(NULL), 1893 _retained_old_gc_alloc_region(NULL),
1894 _survivor_plab_stats(YoungPLABSize, PLABWeight),
1895 _old_plab_stats(OldPLABSize, PLABWeight),
1894 _expand_heap_after_alloc_failure(true), 1896 _expand_heap_after_alloc_failure(true),
1895 _surviving_young_words(NULL), 1897 _surviving_young_words(NULL),
1896 _old_marking_cycles_started(0), 1898 _old_marking_cycles_started(0),
1897 _old_marking_cycles_completed(0), 1899 _old_marking_cycles_completed(0),
1898 _in_cset_fast_test(NULL), 1900 _in_cset_fast_test(NULL),
4097 size_t G1CollectedHeap::desired_plab_sz(GCAllocPurpose purpose) 4099 size_t G1CollectedHeap::desired_plab_sz(GCAllocPurpose purpose)
4098 { 4100 {
4099 size_t gclab_word_size; 4101 size_t gclab_word_size;
4100 switch (purpose) { 4102 switch (purpose) {
4101 case GCAllocForSurvived: 4103 case GCAllocForSurvived:
4102 gclab_word_size = YoungPLABSize; 4104 gclab_word_size = _survivor_plab_stats.desired_plab_sz();
4103 break; 4105 break;
4104 case GCAllocForTenured: 4106 case GCAllocForTenured:
4105 gclab_word_size = OldPLABSize; 4107 gclab_word_size = _old_plab_stats.desired_plab_sz();
4106 break; 4108 break;
4107 default: 4109 default:
4108 assert(false, "unknown GCAllocPurpose"); 4110 assert(false, "unknown GCAllocPurpose");
4109 gclab_word_size = OldPLABSize; 4111 gclab_word_size = _old_plab_stats.desired_plab_sz();
4110 break; 4112 break;
4111 } 4113 }
4112 return gclab_word_size; 4114
4115 // Prevent humongous PLAB sizes for two reasons:
4116 // * PLABs are allocated using a similar paths as oops, but should
4117 // never be in a humongous region
4118 // * Allowing humongous PLABs needlessly churns the region free lists
4119 return MIN2(_humongous_object_threshold_in_words, gclab_word_size);
4113 } 4120 }
4114 4121
4115 void G1CollectedHeap::init_mutator_alloc_region() { 4122 void G1CollectedHeap::init_mutator_alloc_region() {
4116 assert(_mutator_alloc_region.get() == NULL, "pre-condition"); 4123 assert(_mutator_alloc_region.get() == NULL, "pre-condition");
4117 _mutator_alloc_region.init(); 4124 _mutator_alloc_region.init();
4163 // _retained_old_gc_alloc_region. If we don't 4170 // _retained_old_gc_alloc_region. If we don't
4164 // _retained_old_gc_alloc_region will become NULL. This is what we 4171 // _retained_old_gc_alloc_region will become NULL. This is what we
4165 // want either way so no reason to check explicitly for either 4172 // want either way so no reason to check explicitly for either
4166 // condition. 4173 // condition.
4167 _retained_old_gc_alloc_region = _old_gc_alloc_region.release(); 4174 _retained_old_gc_alloc_region = _old_gc_alloc_region.release();
4175
4176 if (ResizePLAB) {
4177 _survivor_plab_stats.adjust_desired_plab_sz();
4178 _old_plab_stats.adjust_desired_plab_sz();
4179 }
4168 } 4180 }
4169 4181
4170 void G1CollectedHeap::abandon_gc_alloc_regions() { 4182 void G1CollectedHeap::abandon_gc_alloc_regions() {
4171 assert(_survivor_gc_alloc_region.get() == NULL, "pre-condition"); 4183 assert(_survivor_gc_alloc_region.get() == NULL, "pre-condition");
4172 assert(_old_gc_alloc_region.get() == NULL, "pre-condition"); 4184 assert(_old_gc_alloc_region.get() == NULL, "pre-condition");