src/share/vm/gc_implementation/g1/survRateGroup.hpp

Mon, 03 Aug 2009 12:59:30 -0700

author
johnc
date
Mon, 03 Aug 2009 12:59:30 -0700
changeset 1324
15c5903cf9e1
parent 1014
0fbdb4381b99
child 1829
1316cec51b4d
permissions
-rw-r--r--

6865703: G1: Parallelize hot card cache cleanup
Summary: Have the GC worker threads clear the hot card cache in parallel by having each worker thread claim a chunk of the card cache and process the cards in that chunk. The size of the chunks that each thread will claim is determined at VM initialization from the size of the card cache and the number of worker threads.
Reviewed-by: jmasa, tonyp

ysr@777 1 /*
xdono@1014 2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
ysr@777 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ysr@777 20 * CA 95054 USA or visit www.sun.com if you need additional information or
ysr@777 21 * have any questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
ysr@777 25 class G1CollectorPolicy;
ysr@777 26
ysr@777 27 class SurvRateGroup : public CHeapObj {
ysr@777 28 private:
ysr@777 29 G1CollectorPolicy* _g1p;
ysr@777 30 const char* _name;
ysr@777 31
apetrusenko@980 32 size_t _stats_arrays_length;
ysr@777 33 double* _surv_rate;
ysr@777 34 double* _accum_surv_rate_pred;
ysr@777 35 double _last_pred;
ysr@777 36 double _accum_surv_rate;
ysr@777 37 TruncatedSeq** _surv_rate_pred;
ysr@777 38 NumberSeq** _summary_surv_rates;
ysr@777 39 size_t _summary_surv_rates_len;
ysr@777 40 size_t _summary_surv_rates_max_len;
ysr@777 41
ysr@777 42 int _all_regions_allocated;
apetrusenko@980 43 size_t _region_num;
ysr@777 44 size_t _scan_only_prefix;
ysr@777 45 size_t _setup_seq_num;
ysr@777 46
ysr@777 47 public:
ysr@777 48 SurvRateGroup(G1CollectorPolicy* g1p,
ysr@777 49 const char* name,
ysr@777 50 size_t summary_surv_rates_len);
apetrusenko@980 51 void reset();
ysr@777 52 void start_adding_regions();
ysr@777 53 void stop_adding_regions();
ysr@777 54 void record_scan_only_prefix(size_t scan_only_prefix);
ysr@777 55 void record_surviving_words(int age_in_group, size_t surv_words);
ysr@777 56 void all_surviving_words_recorded(bool propagate);
ysr@777 57 const char* name() { return _name; }
ysr@777 58
apetrusenko@980 59 size_t region_num() { return _region_num; }
ysr@777 60 size_t scan_only_length() { return _scan_only_prefix; }
ysr@777 61 double accum_surv_rate_pred(int age) {
ysr@777 62 assert(age >= 0, "must be");
apetrusenko@980 63 if ((size_t)age < _stats_arrays_length)
ysr@777 64 return _accum_surv_rate_pred[age];
ysr@777 65 else {
apetrusenko@980 66 double diff = (double) (age - _stats_arrays_length + 1);
apetrusenko@980 67 return _accum_surv_rate_pred[_stats_arrays_length-1] + diff * _last_pred;
ysr@777 68 }
ysr@777 69 }
ysr@777 70
ysr@777 71 double accum_surv_rate(size_t adjustment);
ysr@777 72
ysr@777 73 TruncatedSeq* get_seq(size_t age) {
ysr@777 74 if (age >= _setup_seq_num) {
ysr@777 75 guarantee( _setup_seq_num > 0, "invariant" );
ysr@777 76 age = _setup_seq_num-1;
ysr@777 77 }
ysr@777 78 TruncatedSeq* seq = _surv_rate_pred[age];
ysr@777 79 guarantee( seq != NULL, "invariant" );
ysr@777 80 return seq;
ysr@777 81 }
ysr@777 82
ysr@777 83 int next_age_index();
ysr@777 84 int age_in_group(int age_index) {
ysr@777 85 int ret = (int) (_all_regions_allocated - age_index);
ysr@777 86 assert( ret >= 0, "invariant" );
ysr@777 87 return ret;
ysr@777 88 }
ysr@777 89 int recalculate_age_index(int age_index) {
ysr@777 90 int new_age_index = (int) _scan_only_prefix - age_in_group(age_index);
ysr@777 91 guarantee( new_age_index >= 0, "invariant" );
ysr@777 92 return new_age_index;
ysr@777 93 }
ysr@777 94 void finished_recalculating_age_indexes() {
ysr@777 95 _all_regions_allocated = (int) _scan_only_prefix;
ysr@777 96 }
ysr@777 97
ysr@777 98 #ifndef PRODUCT
ysr@777 99 void print();
ysr@777 100 void print_surv_rate_summary();
ysr@777 101 #endif // PRODUCT
ysr@777 102 };

mercurial