11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/shared/ageTable.hpp"
27 #include "gc/shared/collectedHeap.hpp"
28 #include "gc/shared/collectorPolicy.hpp"
29 #include "gc/shared/gcPolicyCounters.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "utilities/copy.hpp"
32
33 /* Copyright (c) 1992, 2015, Oracle and/or its affiliates, and Stanford University.
34 See the LICENSE file for license information. */
35
36 ageTable::ageTable(bool global) {
37
38 clear();
39
40 if (UsePerfData && global) {
41
42 ResourceMark rm;
43 EXCEPTION_MARK;
44
45 const char* agetable_ns = "generation.0.agetable";
46 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
47
48 for(int age = 0; age < table_size; age ++) {
49 char age_name[10];
50 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age);
77 uint result;
78
79 if (AlwaysTenure || NeverTenure) {
80 assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1,
81 "MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is " UINTX_FORMAT, MaxTenuringThreshold);
82 result = MaxTenuringThreshold;
83 } else {
84 size_t total = 0;
85 uint age = 1;
86 assert(sizes[0] == 0, "no objects with age zero should be recorded");
87 while (age < table_size) {
88 total += sizes[age];
89 // check if including objects of age 'age' made us pass the desired
90 // size, if so 'age' is the new threshold
91 if (total > desired_survivor_size) break;
92 age++;
93 }
94 result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
95 }
96
97 if (PrintTenuringDistribution || UsePerfData) {
98
99 if (PrintTenuringDistribution) {
100 gclog_or_tty->cr();
101 gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold "
102 UINTX_FORMAT " (max threshold " UINTX_FORMAT ")",
103 desired_survivor_size*oopSize, (uintx) result, MaxTenuringThreshold);
104 }
105
106 size_t total = 0;
107 uint age = 1;
108 while (age < table_size) {
109 total += sizes[age];
110 if (sizes[age] > 0) {
111 if (PrintTenuringDistribution) {
112 gclog_or_tty->print_cr("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
113 age, sizes[age]*oopSize, total*oopSize);
114 }
115 }
116 if (UsePerfData) {
117 _perf_sizes[age]->set_value(sizes[age]*oopSize);
118 }
119 age++;
120 }
121 if (UsePerfData) {
122 gc_counters->tenuring_threshold()->set_value(result);
123 gc_counters->desired_survivor_size()->set_value(
124 desired_survivor_size*oopSize);
125 }
126 }
127
128 return result;
129 }
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/shared/ageTable.hpp"
27 #include "gc/shared/collectedHeap.hpp"
28 #include "gc/shared/collectorPolicy.hpp"
29 #include "gc/shared/gcPolicyCounters.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "logging/log.hpp"
32 #include "utilities/copy.hpp"
33
34 /* Copyright (c) 1992, 2015, Oracle and/or its affiliates, and Stanford University.
35 See the LICENSE file for license information. */
36
37 ageTable::ageTable(bool global) {
38
39 clear();
40
41 if (UsePerfData && global) {
42
43 ResourceMark rm;
44 EXCEPTION_MARK;
45
46 const char* agetable_ns = "generation.0.agetable";
47 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
48
49 for(int age = 0; age < table_size; age ++) {
50 char age_name[10];
51 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age);
78 uint result;
79
80 if (AlwaysTenure || NeverTenure) {
81 assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1,
82 "MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is " UINTX_FORMAT, MaxTenuringThreshold);
83 result = MaxTenuringThreshold;
84 } else {
85 size_t total = 0;
86 uint age = 1;
87 assert(sizes[0] == 0, "no objects with age zero should be recorded");
88 while (age < table_size) {
89 total += sizes[age];
90 // check if including objects of age 'age' made us pass the desired
91 // size, if so 'age' is the new threshold
92 if (total > desired_survivor_size) break;
93 age++;
94 }
95 result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
96 }
97
98
99 log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold " UINTX_FORMAT " (max threshold " UINTX_FORMAT ")",
100 desired_survivor_size*oopSize, (uintx) result, MaxTenuringThreshold);
101
102 if (Log<LOG_TAGS(gc, age)>::is_trace() || UsePerfData) {
103 size_t total = 0;
104 uint age = 1;
105 while (age < table_size) {
106 total += sizes[age];
107 if (sizes[age] > 0) {
108 log_trace(gc, age)("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
109 age, sizes[age]*oopSize, total*oopSize);
110 }
111 if (UsePerfData) {
112 _perf_sizes[age]->set_value(sizes[age]*oopSize);
113 }
114 age++;
115 }
116 if (UsePerfData) {
117 gc_counters->tenuring_threshold()->set_value(result);
118 gc_counters->desired_survivor_size()->set_value(
119 desired_survivor_size*oopSize);
120 }
121 }
122
123 return result;
124 }
|