annotate src/share/vm/gc_implementation/g1/survRateGroup.cpp @ 6197:d2a62e0f25eb

6995781: Native Memory Tracking (Phase 1) 7151532: DCmd for hotspot native memory tracking Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
author zgu
date Thu, 28 Jun 2012 17:03:16 -0400
parents 2c0751569716
children 78bbf4d43a14
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
1 /*
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
4 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
8 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
13 * accompanied this code).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
14 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1394
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1394
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1394
diff changeset
21 * questions.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
22 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
23 */
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/g1/heapRegion.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "gc_implementation/g1/survRateGroup.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/allocation.hpp"
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
31
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
32 SurvRateGroup::SurvRateGroup(G1CollectorPolicy* g1p,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
33 const char* name,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
34 size_t summary_surv_rates_len) :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
35 _g1p(g1p), _name(name),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
36 _summary_surv_rates_len(summary_surv_rates_len),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
37 _summary_surv_rates_max_len(0),
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
38 _summary_surv_rates(NULL),
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
39 _surv_rate(NULL),
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
40 _accum_surv_rate_pred(NULL),
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
41 _surv_rate_pred(NULL),
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
42 _stats_arrays_length(0) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
43 reset();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
44 if (summary_surv_rates_len > 0) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
45 size_t length = summary_surv_rates_len;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 5938
diff changeset
46 _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length, mtGC);
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
47 for (size_t i = 0; i < length; ++i) {
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
48 _summary_surv_rates[i] = new NumberSeq();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
49 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
50 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
51
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
52 start_adding_regions();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
53 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
54
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
55 void SurvRateGroup::reset() {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
56 _all_regions_allocated = 0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
57 _setup_seq_num = 0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
58 _accum_surv_rate = 0.0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
59 _last_pred = 0.0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
60 // the following will set up the arrays with length 1
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
61 _region_num = 1;
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
62
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
63 // The call to stop_adding_regions() will use "new" to refill
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
64 // the _surv_rate_pred array, so we need to make sure to call
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
65 // "delete".
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
66 for (size_t i = 0; i < _stats_arrays_length; ++i) {
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
67 delete _surv_rate_pred[i];
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
68 }
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
69 _stats_arrays_length = 0;
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
70
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
71 stop_adding_regions();
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
72 guarantee( _stats_arrays_length == 1, "invariant" );
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
73 guarantee( _surv_rate_pred[0] != NULL, "invariant" );
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
74 _surv_rate_pred[0]->add(0.4);
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
75 all_surviving_words_recorded(false);
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
76 _region_num = 0;
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
77 }
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
78
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
79 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
80 SurvRateGroup::start_adding_regions() {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
81 _setup_seq_num = _stats_arrays_length;
1394
1316cec51b4d 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 579
diff changeset
82 _region_num = 0;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
83 _accum_surv_rate = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
84 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
85
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
86 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
87 SurvRateGroup::stop_adding_regions() {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
88 if (_region_num > _stats_arrays_length) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
89 double* old_surv_rate = _surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
90 double* old_accum_surv_rate_pred = _accum_surv_rate_pred;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
91 TruncatedSeq** old_surv_rate_pred = _surv_rate_pred;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
92
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 5938
diff changeset
93 _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num, mtGC);
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 5938
diff changeset
94 _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num, mtGC);
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 5938
diff changeset
95 _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num, mtGC);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
96
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
97 for (size_t i = 0; i < _stats_arrays_length; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
98 _surv_rate_pred[i] = old_surv_rate_pred[i];
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
99 }
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
100 for (size_t i = _stats_arrays_length; i < _region_num; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
101 _surv_rate_pred[i] = new TruncatedSeq(10);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
102 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
103
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
104 _stats_arrays_length = _region_num;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
105
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
106 if (old_surv_rate != NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 5938
diff changeset
107 FREE_C_HEAP_ARRAY(double, old_surv_rate, mtGC);
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
108 }
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
109 if (old_accum_surv_rate_pred != NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 5938
diff changeset
110 FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred, mtGC);
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
111 }
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
112 if (old_surv_rate_pred != NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 5938
diff changeset
113 FREE_C_HEAP_ARRAY(TruncatedSeq*, old_surv_rate_pred, mtGC);
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
114 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
115 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
116
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
117 for (size_t i = 0; i < _stats_arrays_length; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
118 _surv_rate[i] = 0.0;
5938
2c0751569716 7152954: G1: Native memory leak during full GCs
brutisso
parents: 1972
diff changeset
119 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
120 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
121
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
122 double
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
123 SurvRateGroup::accum_surv_rate(size_t adjustment) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
124 // we might relax this one in the future...
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
125 guarantee( adjustment == 0 || adjustment == 1, "pre-condition" );
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
126
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
127 double ret = _accum_surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
128 if (adjustment > 0) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
129 TruncatedSeq* seq = get_seq(_region_num+1);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
130 double surv_rate = _g1p->get_new_prediction(seq);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
131 ret += surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
132 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
133
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
134 return ret;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
135 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
137 int
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 SurvRateGroup::next_age_index() {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
139 TruncatedSeq* seq = get_seq(_region_num);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
140 double surv_rate = _g1p->get_new_prediction(seq);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
141 _accum_surv_rate += surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
142
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
143 ++_region_num;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
144 return (int) ++_all_regions_allocated;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
145 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
146
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
147 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
148 SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
149 guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num,
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
150 "pre-condition" );
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
151 guarantee( _surv_rate[age_in_group] <= 0.00001,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
152 "should only update each slot once" );
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
153
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
154 double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
155 _surv_rate[age_in_group] = surv_rate;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
156 _surv_rate_pred[age_in_group]->add(surv_rate);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
157 if ((size_t)age_in_group < _summary_surv_rates_len) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
158 _summary_surv_rates[age_in_group]->add(surv_rate);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
159 if ((size_t)(age_in_group+1) > _summary_surv_rates_max_len)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
160 _summary_surv_rates_max_len = age_in_group+1;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
161 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
162 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
163
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
164 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
165 SurvRateGroup::all_surviving_words_recorded(bool propagate) {
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
166 if (propagate && _region_num > 0) { // conservative
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
167 double surv_rate = _surv_rate_pred[_region_num-1]->last();
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
168 for (size_t i = _region_num; i < _stats_arrays_length; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169 guarantee( _surv_rate[i] <= 0.00001,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
170 "the slot should not have been updated" );
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
171 _surv_rate_pred[i]->add(surv_rate);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
172 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
173 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
174
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
175 double accum = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
176 double pred = 0.0;
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
177 for (size_t i = 0; i < _stats_arrays_length; ++i) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
178 pred = _g1p->get_new_prediction(_surv_rate_pred[i]);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
179 if (pred > 1.0) pred = 1.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180 accum += pred;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
181 _accum_surv_rate_pred[i] = accum;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182 // gclog_or_tty->print_cr("age %3d, accum %10.2lf", i, accum);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
183 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
184 _last_pred = pred;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
185 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
186
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
187 #ifndef PRODUCT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
188 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
189 SurvRateGroup::print() {
1394
1316cec51b4d 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 579
diff changeset
190 gclog_or_tty->print_cr("Surv Rate Group: %s (%d entries)",
1316cec51b4d 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 579
diff changeset
191 _name, _region_num);
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 342
diff changeset
192 for (size_t i = 0; i < _region_num; ++i) {
1394
1316cec51b4d 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 579
diff changeset
193 gclog_or_tty->print_cr(" age %4d surv rate %6.2lf %% pred %6.2lf %%",
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
194 i, _surv_rate[i] * 100.0,
1394
1316cec51b4d 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 579
diff changeset
195 _g1p->get_new_prediction(_surv_rate_pred[i]) * 100.0);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
196 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
197 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
198
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
199 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
200 SurvRateGroup::print_surv_rate_summary() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
201 size_t length = _summary_surv_rates_max_len;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
202 if (length == 0)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
203 return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
204
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
205 gclog_or_tty->print_cr("");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
206 gclog_or_tty->print_cr("%s Rate Summary (for up to age %d)", _name, length-1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
207 gclog_or_tty->print_cr(" age range survival rate (avg) samples (avg)");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
208 gclog_or_tty->print_cr(" ---------------------------------------------------------");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
209
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
210 size_t index = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
211 size_t limit = MIN2((int) length, 10);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
212 while (index < limit) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
213 gclog_or_tty->print_cr(" %4d %6.2lf%% %6.2lf",
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
214 index, _summary_surv_rates[index]->avg() * 100.0,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
215 (double) _summary_surv_rates[index]->num());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
216 ++index;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
217 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
218
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
219 gclog_or_tty->print_cr(" ---------------------------------------------------------");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
220
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
221 int num = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
222 double sum = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
223 int samples = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
224 while (index < length) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
225 ++num;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
226 sum += _summary_surv_rates[index]->avg() * 100.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
227 samples += _summary_surv_rates[index]->num();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
228 ++index;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
229
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
230 if (index == length || num % 10 == 0) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
231 gclog_or_tty->print_cr(" %4d .. %4d %6.2lf%% %6.2lf",
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
232 (index-1) / 10 * 10, index-1, sum / (double) num,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
233 (double) samples / (double) num);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
234 sum = 0.0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
235 num = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
236 samples = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
237 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
238 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
239
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
240 gclog_or_tty->print_cr(" ---------------------------------------------------------");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
241 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
242 #endif // PRODUCT