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.inline.hpp"
27 #include "gc/shared/ageTableTracer.hpp"
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/gc_globals.hpp"
30 #include "jvm.h"
31 #include "logging/log.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "runtime/perfData.hpp"
35 #include "utilities/copy.hpp"
36
37 /* Copyright (c) 1992, 2021, Oracle and/or its affiliates, and Stanford University.
38 See the LICENSE file for license information. */
39
40 AgeTable::AgeTable(bool global) {
41
42 clear();
43
44 if (UsePerfData && global) {
45
46 ResourceMark rm;
47 EXCEPTION_MARK;
48
49 const char* agetable_ns = "generation.0.agetable";
50 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
51
52 for(int age = 0; age < table_size; age ++) {
53 char age_name[10];
54 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age);
55 const char* cname = PerfDataManager::counter_name(bytes_ns, age_name);
56 _perf_sizes[age] = PerfDataManager::create_variable(SUN_GC, cname,
57 PerfData::U_Bytes,
58 CHECK);
59 }
60
61 const char* cname = PerfDataManager::counter_name(agetable_ns, "size");
62 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
63 table_size, CHECK);
64 }
65 }
66
67 void AgeTable::clear() {
68 for (size_t* p = sizes; p < sizes + table_size; ++p) {
69 *p = 0;
70 }
71 }
72
73 void AgeTable::merge(AgeTable* subTable) {
74 for (int i = 0; i < table_size; i++) {
75 sizes[i]+= subTable->sizes[i];
76 }
77 }
78
79 uint AgeTable::compute_tenuring_threshold(size_t desired_survivor_size) {
80 uint result;
81
82 if (AlwaysTenure || NeverTenure) {
83 assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markWord::max_age + 1,
84 "MaxTenuringThreshold should be 0 or markWord::max_age + 1, but is " UINTX_FORMAT, MaxTenuringThreshold);
85 result = MaxTenuringThreshold;
86 } else {
87 size_t total = 0;
88 uint age = 1;
89 assert(sizes[0] == 0, "no objects with age zero should be recorded");
90 while (age < table_size) {
91 total += sizes[age];
92 // check if including objects of age 'age' made us pass the desired
93 // size, if so 'age' is the new threshold
94 if (total > desired_survivor_size) break;
95 age++;
96 }
97 result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
98 }
99
100
101 log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold " UINTX_FORMAT " (max threshold " UINTX_FORMAT ")",
102 desired_survivor_size * oopSize, (uintx) result, MaxTenuringThreshold);
103
104 return result;
105 }
106
107 void AgeTable::print_age_table(uint tenuring_threshold) {
108 if (log_is_enabled(Trace, gc, age) || UsePerfData || AgeTableTracer::is_tenuring_distribution_event_enabled()) {
109 log_trace(gc, age)("Age table with threshold %u (max threshold " UINTX_FORMAT ")",
110 tenuring_threshold, MaxTenuringThreshold);
111
112 size_t total = 0;
113 uint age = 1;
114 while (age < table_size) {
115 size_t wordSize = sizes[age];
116 total += wordSize;
117 if (wordSize > 0) {
118 log_trace(gc, age)("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
119 age, wordSize * oopSize, total * oopSize);
120 }
121 AgeTableTracer::send_tenuring_distribution_event(age, wordSize * oopSize);
122 if (UsePerfData) {
123 _perf_sizes[age]->set_value(wordSize * oopSize);
124 }
125 age++;
126 }
127 }
128 }
129
|
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.inline.hpp"
27 #include "gc/shared/ageTableTracer.hpp"
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/gc_globals.hpp"
30 #include "jvm.h"
31 #include "logging/log.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "runtime/perfData.hpp"
35 #include "utilities/copy.hpp"
36 #include "logging/logStream.hpp"
37
38 /* Copyright (c) 1992, 2021, Oracle and/or its affiliates, and Stanford University.
39 See the LICENSE file for license information. */
40
41 AgeTable::AgeTable(bool global) : _use_perf_data(UsePerfData && global) {
42
43 clear();
44
45 if (_use_perf_data) {
46
47 ResourceMark rm;
48 EXCEPTION_MARK;
49
50 const char* agetable_ns = "generation.0.agetable";
51 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
52
53 for(int age = 0; age < table_size; age ++) {
54 char age_name[10];
55 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age);
56 const char* cname = PerfDataManager::counter_name(bytes_ns, age_name);
57 _perf_sizes[age] = PerfDataManager::create_variable(SUN_GC, cname,
58 PerfData::U_Bytes,
59 CHECK);
60 }
61
62 const char* cname = PerfDataManager::counter_name(agetable_ns, "size");
63 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
64 table_size, CHECK);
65 }
66 }
67
68 void AgeTable::clear() {
69 for (size_t* p = sizes; p < sizes + table_size; ++p) {
70 *p = 0;
71 }
72 }
73
74 void AgeTable::merge(const AgeTable* subTable) {
75 for (int i = 0; i < table_size; i++) {
76 sizes[i]+= subTable->sizes[i];
77 }
78 }
79
80 uint AgeTable::compute_tenuring_threshold(size_t desired_survivor_size) {
81 uint result;
82
83 if (AlwaysTenure || NeverTenure) {
84 assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markWord::max_age + 1,
85 "MaxTenuringThreshold should be 0 or markWord::max_age + 1, but is " UINTX_FORMAT, MaxTenuringThreshold);
86 result = MaxTenuringThreshold;
87 } else {
88 size_t total = 0;
89 uint age = 1;
90 assert(sizes[0] == 0, "no objects with age zero should be recorded");
91 while (age < table_size) {
92 total += sizes[age];
93 // check if including objects of age 'age' made us pass the desired
94 // size, if so 'age' is the new threshold
95 if (total > desired_survivor_size) break;
96 age++;
97 }
98 result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
99 }
100
101
102 log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold " UINTX_FORMAT " (max threshold " UINTX_FORMAT ")",
103 desired_survivor_size * oopSize, (uintx) result, MaxTenuringThreshold);
104
105 return result;
106 }
107
108 void AgeTable::print_age_table(uint tenuring_threshold) {
109 LogTarget(Trace, gc, age) lt;
110 if (lt.is_enabled() || _use_perf_data || AgeTableTracer::is_tenuring_distribution_event_enabled()) {
111 LogStream st(lt);
112 print_on(&st, tenuring_threshold);
113 }
114 }
115
116 void AgeTable::print_on(outputStream* st, uint tenuring_threshold) {
117 st->print_cr("Age table with threshold %u (max threshold " UINTX_FORMAT ")",
118 tenuring_threshold, MaxTenuringThreshold);
119
120 size_t total = 0;
121 uint age = 1;
122 while (age < table_size) {
123 size_t word_size = sizes[age];
124 total += word_size;
125 if (word_size > 0) {
126 st->print_cr("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
127 age, word_size * oopSize, total * oopSize);
128 }
129 AgeTableTracer::send_tenuring_distribution_event(age, word_size * oopSize);
130 if (_use_perf_data) {
131 _perf_sizes[age]->set_value(word_size * oopSize);
132 }
133 age++;
134 }
135 }
|